Skip to content

Commit

Permalink
Merge pull request #85 from Darginec05/82-selecting-list-item-shows-w…
Browse files Browse the repository at this point in the history
…rong-element-type

82 selecting list item shows wrong element type
  • Loading branch information
Darginec05 authored Sep 22, 2023
2 parents 835bfe8 + 3823bbd commit b4470da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/yoopta-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yoopta/editor",
"version": "1.9.22-rc",
"version": "1.9.24-rc",
"license": "MIT",
"private": false,
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Editor, Element, NodeEntry, Path, Text, Transforms } from 'slate';
import React, { ReactElement, ReactNode, useContext, useMemo, useRef } from 'react';
import { useSlate } from 'slate-react';
import { YooptaBaseElement } from '../../types';
import { ParentYooptaPlugin, YooptaPluginType } from '../../utils/plugins';
import { YooptaBaseElement, YooptaTools } from '../../types';
import { YooptaPluginType } from '../../utils/plugins';
import { YooptaMark } from '../../utils/marks';
import { getDefaultParagraphLine } from '../../components/Editor/utils';
import { generateId } from '../../utils/generateId';
import { YooptaTools } from '../../components/YooptaEditor/YooptaEditor';

const defaultValues: YooptaContextReturnValues = { marks: {}, elements: {} };

Expand Down Expand Up @@ -34,7 +33,7 @@ export type YooptaContextType = YooptaContextReturnValues;

type Props = {
children: ReactNode;
plugins: ParentYooptaPlugin[];
plugins: Omit<YooptaPluginType, 'childPlugin'>[];
marks?: YooptaMark[];
tools?: YooptaTools | undefined;
};
Expand Down Expand Up @@ -115,7 +114,7 @@ const YooptaContextProvider = ({ children, plugins: pluginList, marks: markList,

const [element] = Editor.nodes(editor, {
at: Editor.unhangRange(editor, editor.selection),
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === type,
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && !Editor.isInline(editor, n) && n.type === type,
mode: 'highest',
});

Expand All @@ -127,13 +126,13 @@ const YooptaContextProvider = ({ children, plugins: pluginList, marks: markList,
const ELEMENTS_MAP: ElementsMap = {};

pluginList.forEach((plugin) => {
const { createElement, defineElement, type, options, ...rest } = plugin;
const { createElement, defineElement, type, options, hasParent } = plugin;
ELEMENTS_MAP[plugin.type] = {
create: createElement,
define: defineElement,
toggle: (options) => toggleNodeElement(plugin, options),
type,
isActive: isElementActive(type),
isActive: !hasParent && isElementActive(type),
options: { displayLabel: options?.displayLabel },
};
});
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@yoopta/callout": "^1.9.15-rc",
"@yoopta/chat-gpt-assistant": "^1.9.16-rc",
"@yoopta/code": "^1.9.15-rc",
"@yoopta/editor": "^1.9.22-rc",
"@yoopta/editor": "^1.9.24-rc",
"@yoopta/embed": "^1.9.18-rc",
"@yoopta/exports": "^1.9.17-rc",
"@yoopta/headings": "^1.9.15-rc",
Expand Down
8 changes: 4 additions & 4 deletions web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1615,10 +1615,10 @@
prism-material-themes "^1.0.4"
prismjs "^1.29.0"

"@yoopta/editor@^1.9.22-rc":
version "1.9.22-rc"
resolved "https://registry.yarnpkg.com/@yoopta/editor/-/editor-1.9.22-rc.tgz#3074393d3c3f316658c706c9492d207ba1e8632a"
integrity sha512-pnQsS7kT2ux++4QaS+rJ34ZOOqmRXq/drJsSI69t6rhjXS5jSWwRoNeiCeK0STJM3bz348hWs3UPRm35qXrwdQ==
"@yoopta/editor@^1.9.23-rc":
version "1.9.23-rc"
resolved "https://registry.yarnpkg.com/@yoopta/editor/-/editor-1.9.23-rc.tgz#aa6f829149a3225d56c2031d21f6c94fc5e4c950"
integrity sha512-+ms9OVWUoio8taYfwe9CaMeKjvQfupwFroVuIUqaXIh6xuZSadhBe12wtuf2I2MJyWKEgifZjiPQ3LrnwemV3Q==
dependencies:
body-scroll-lock "^4.0.0-beta.0"
classnames "^2.3.1"
Expand Down

1 comment on commit b4470da

@vercel
Copy link

@vercel vercel bot commented on b4470da Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yopta-editor – ./

yopta-editor.vercel.app
yopta-editor-darginec05.vercel.app
yopta-editor-git-master-darginec05.vercel.app

Please sign in to comment.