@yoopta/editor 1.9.1-rc → 1.9.2-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/YooptaEditor.d.ts +4 -0
- package/dist/components/Editor/Editor.d.ts +9 -9
- package/dist/components/Editor/TextLeaf/TextLeaf.d.ts +2 -2
- package/dist/components/Editor/utils.d.ts +5 -5
- package/dist/components/ElementWrapper/ElementActions.d.ts +2 -2
- package/dist/components/ElementWrapper/ElementWrapper.d.ts +2 -2
- package/dist/components/{YoptaEditor/YoptaEditor.d.ts → YooptaEditor/YooptaEditor.d.ts} +9 -9
- package/dist/contexts/NodeSettingsContext/NodeSettingsContext.d.ts +3 -3
- package/dist/contexts/YooptaContext/YooptaContext.d.ts +28 -0
- package/dist/hooks/useDragDrop.d.ts +3 -3
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/types.d.ts +6 -6
- package/dist/utils/deserializeHTML.d.ts +4 -4
- package/dist/utils/marks.d.ts +3 -3
- package/dist/utils/plugins.d.ts +20 -20
- package/dist/utils/validate.d.ts +1 -1
- package/package.json +5 -5
- package/dist/YoptaEditor.d.ts +0 -4
- package/dist/contexts/YoptaEditor/YoptaContext.d.ts +0 -28
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<h2 align="center">
|
|
2
|
-
<p align="center">
|
|
1
|
+
<h2 align="center">Yoopta-Editor v1 🎉</h2>
|
|
2
|
+
<p align="center">Yoopta-Editor - is an open source notion-like editor 💥</p>
|
|
3
3
|
<div align="center">
|
|
4
4
|
<img width="574" alt="Screen Shot 2023-01-25 at 16 04 29" src="https://user-images.githubusercontent.com/29093118/215324525-882bf403-646c-4267-bb5f-c0f37509ac09.png">
|
|
5
5
|
</div>
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
- Offline ready mode
|
|
25
25
|
- Shortcuts
|
|
26
26
|
- A cool representation of the data in JSON format, so you can easily save the content data to the database and validate
|
|
27
|
-
You can import two plugins from library: `<
|
|
28
|
-
`<
|
|
29
|
-
`<
|
|
27
|
+
You can import two plugins from library: `<YooptaEditor />` and `<YooptaRender />`. <br>
|
|
28
|
+
`<YooptaEditor />` - it's for building beautiful content <br>
|
|
29
|
+
`<YooptaRender />` - it's just for rendering from your saved data, without any editor tools and libraries, so it make you page loading faster
|
|
30
30
|
- Custom styling
|
|
31
31
|
...and other
|
|
32
32
|
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
### Quickstart
|
|
46
46
|
|
|
47
47
|
```jsx
|
|
48
|
-
import {
|
|
48
|
+
import { YooptaEditor } from '@yoopta/editor';
|
|
49
49
|
import { useState } from 'react';
|
|
50
50
|
|
|
51
51
|
import 'yoopta-editor/dist/index.css';
|
|
@@ -57,7 +57,7 @@ function App() {
|
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
59
|
<div>
|
|
60
|
-
<
|
|
60
|
+
<YooptaEditor value={editorValue} onChange={onChange} />
|
|
61
61
|
</div>
|
|
62
62
|
);
|
|
63
63
|
}
|
|
@@ -73,7 +73,7 @@ function App() {
|
|
|
73
73
|
<br>
|
|
74
74
|
<br>
|
|
75
75
|
|
|
76
|
-
<div style="padding: 10px">❗
|
|
76
|
+
<div style="padding: 10px">❗ Yoopta-Editor is on <span style="color: #007aff">BETA</span> version now. The core functionality works, but you may encounter some bugs.
|
|
77
77
|
I have big plans for the v2 version with a lot of cool features and improvements.
|
|
78
78
|
Let's build together the best open source editor ever ☝ <br>
|
|
79
79
|
Read more about future plans <a target="_blank" rel="noopener noreferrer" href="https://yopage.co/blog/0zntIA46L4/5iK8VNiBI8">"What's next Lebovski?"</a>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { YoEditor,
|
|
5
|
-
type
|
|
2
|
+
import { ParentYooptaPlugin, YooptaPluginType } from '../../utils/plugins';
|
|
3
|
+
import { YooptaMark } from '../../utils/marks';
|
|
4
|
+
import { YoEditor, YooptaBaseElement } from '../../types';
|
|
5
|
+
type YooptaProps = {
|
|
6
6
|
editor: YoEditor;
|
|
7
7
|
placeholder?: string;
|
|
8
8
|
readOnly?: boolean;
|
|
9
|
-
plugins:
|
|
9
|
+
plugins: ParentYooptaPlugin[];
|
|
10
10
|
children: ReactNode | ReactNode[];
|
|
11
|
-
marks?:
|
|
12
|
-
PLUGINS_MAP: Record<
|
|
11
|
+
marks?: YooptaMark[];
|
|
12
|
+
PLUGINS_MAP: Record<YooptaBaseElement<string>['type'], YooptaPluginType<any, YooptaBaseElement<string>>>;
|
|
13
13
|
};
|
|
14
|
-
declare const
|
|
15
|
-
export {
|
|
14
|
+
declare const EditorYoopta: ({ editor, placeholder, marks, readOnly, children, plugins, PLUGINS_MAP }: YooptaProps) => JSX.Element;
|
|
15
|
+
export { EditorYoopta };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { RenderLeafProps } from 'slate-react';
|
|
3
|
-
import {
|
|
3
|
+
import { YooptaPluginType } from '../../../utils/plugins';
|
|
4
4
|
type LeafProps = RenderLeafProps & {
|
|
5
|
-
placeholder?:
|
|
5
|
+
placeholder?: YooptaPluginType['placeholder'];
|
|
6
6
|
leaf: any;
|
|
7
7
|
};
|
|
8
8
|
declare const TextLeaf: import("react").MemoExoticComponent<({ attributes, children, placeholder, leaf }: LeafProps) => JSX.Element>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const getDefaultParagraphLine: (id: string) =>
|
|
4
|
-
export declare function getRenderFunctionFactory(plugin:
|
|
5
|
-
export declare function isElementHasText(element:
|
|
1
|
+
import { YooptaBaseElement } from '../../types';
|
|
2
|
+
import { YooptaPluginType, YooptaRenderElementFunc } from '../../utils/plugins';
|
|
3
|
+
export declare const getDefaultParagraphLine: (id: string) => YooptaBaseElement<'paragraph'>;
|
|
4
|
+
export declare function getRenderFunctionFactory(plugin: YooptaPluginType): YooptaRenderElementFunc;
|
|
5
|
+
export declare function isElementHasText(element: YooptaBaseElement<string>): boolean;
|
|
6
6
|
export declare function toggleMark(editor: any, mark: any, only?: boolean): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { NodeSettingsContextHandlers, NodeSettingsContextValues } from '../../contexts/NodeSettingsContext/NodeSettingsContext';
|
|
3
3
|
import { Editor } from 'slate';
|
|
4
|
-
import {
|
|
4
|
+
import { YooptaBaseElement } from '../../types';
|
|
5
5
|
type Props = {
|
|
6
6
|
editor: Editor;
|
|
7
|
-
element:
|
|
7
|
+
element: YooptaBaseElement<string>;
|
|
8
8
|
values: NodeSettingsContextValues;
|
|
9
9
|
handlers: NodeSettingsContextHandlers;
|
|
10
10
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { RenderElementProps } from 'slate-react';
|
|
3
|
-
import {
|
|
3
|
+
import { YooptaElementConfig } from '../../types';
|
|
4
4
|
type Props = RenderElementProps & {
|
|
5
|
-
nodeType:
|
|
5
|
+
nodeType: YooptaElementConfig['nodeType'];
|
|
6
6
|
render: (props: RenderElementProps) => ReactElement;
|
|
7
7
|
};
|
|
8
8
|
declare const ElementWrapper: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Key, ReactNode } from 'react';
|
|
2
2
|
import { Descendant } from 'slate';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { YooptaMark } from '../../utils/marks';
|
|
4
|
+
import { YooptaPlugin } from '../../utils/plugins';
|
|
5
5
|
import { LOCAL_STORAGE_NAME_TYPE } from '../../utils/storage';
|
|
6
|
-
export type
|
|
6
|
+
export type YooptaNodeElementSettings = {
|
|
7
7
|
options?: {
|
|
8
8
|
handlers?: {
|
|
9
9
|
onCopy?: () => void;
|
|
@@ -14,18 +14,18 @@ export type YoptaNodeElementSettings = {
|
|
|
14
14
|
drag?: boolean;
|
|
15
15
|
plus?: boolean;
|
|
16
16
|
};
|
|
17
|
-
export type
|
|
17
|
+
export type YooptaEditorProps = {
|
|
18
18
|
onChange: (_value: Descendant[]) => void;
|
|
19
19
|
value: Descendant[];
|
|
20
20
|
key?: Key;
|
|
21
21
|
placeholder?: string;
|
|
22
|
-
plugins:
|
|
22
|
+
plugins: YooptaPlugin<any, any>[];
|
|
23
23
|
children?: ReactNode | ReactNode[];
|
|
24
24
|
readOnly?: boolean;
|
|
25
25
|
autoFocus?: boolean;
|
|
26
26
|
shouldStoreInLocalStorage?: LOCAL_STORAGE_NAME_TYPE;
|
|
27
|
-
marks?:
|
|
28
|
-
nodeElementSettings?:
|
|
27
|
+
marks?: YooptaMark[];
|
|
28
|
+
nodeElementSettings?: YooptaNodeElementSettings;
|
|
29
29
|
};
|
|
30
|
-
declare const
|
|
31
|
-
export {
|
|
30
|
+
declare const YooptaEditor: ({ key, value, plugins, marks, readOnly, children, onChange, placeholder, autoFocus, shouldStoreInLocalStorage, }: YooptaEditorProps) => JSX.Element;
|
|
31
|
+
export { YooptaEditor };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { YooptaBaseElement } from '../../types';
|
|
3
3
|
import { DragDropValues, DragDropHandlers } from '../../hooks/useDragDrop';
|
|
4
|
-
export type HoveredElement =
|
|
4
|
+
export type HoveredElement = YooptaBaseElement<string> | null;
|
|
5
5
|
export type NodeSettingsContextValues = DragDropValues & {
|
|
6
6
|
hoveredElement: HoveredElement;
|
|
7
7
|
isElementOptionsOpen: boolean;
|
|
@@ -10,7 +10,7 @@ export type NodeSettingsContextValues = DragDropValues & {
|
|
|
10
10
|
export type NodeSettingsContextHandlers = DragDropHandlers & {
|
|
11
11
|
openNodeSettings: (_dragRef: any, _node: HoveredElement) => void;
|
|
12
12
|
closeNodeSettings: () => void;
|
|
13
|
-
hoverIn: (_e: MouseEvent<HTMLDivElement>, _node:
|
|
13
|
+
hoverIn: (_e: MouseEvent<HTMLDivElement>, _node: YooptaBaseElement<string>) => void;
|
|
14
14
|
triggerPlusButton: (_node: HoveredElement) => void;
|
|
15
15
|
deleteNode: () => void;
|
|
16
16
|
duplicateNode: () => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { YooptaBaseElement } from '../../types';
|
|
3
|
+
import { YooptaPlugin, YooptaPluginType } from '../../utils/plugins';
|
|
4
|
+
import { YooptaMark } from '../../utils/marks';
|
|
5
|
+
export type HoveredElement = YooptaBaseElement<string> | null;
|
|
6
|
+
export type YooptaContextValues = {
|
|
7
|
+
marks: MarksMap;
|
|
8
|
+
plugins: PluginsMap;
|
|
9
|
+
};
|
|
10
|
+
export type YooptaContextHandlers = {};
|
|
11
|
+
export type YooptaContextType = YooptaContextValues;
|
|
12
|
+
type NodeSettingsProps = {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
plugins: YooptaPlugin<any, any>[];
|
|
15
|
+
marks?: YooptaMark[];
|
|
16
|
+
};
|
|
17
|
+
type PluginsMap = Record<string, Pick<YooptaPluginType, 'type' | 'createElement' | 'defineElement'>>;
|
|
18
|
+
type MarksMap = {
|
|
19
|
+
[x: string]: {
|
|
20
|
+
toggle: (options?: {
|
|
21
|
+
only: boolean;
|
|
22
|
+
}) => void;
|
|
23
|
+
isActive: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
declare const YooptaContextProvider: ({ children, plugins: pluginList, marks: markList }: NodeSettingsProps) => JSX.Element;
|
|
27
|
+
declare const useYoopta: () => YooptaContextValues;
|
|
28
|
+
export { YooptaContextProvider, useYoopta };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DragEvent } from 'react';
|
|
2
2
|
import { Node, NodeEntry } from 'slate';
|
|
3
|
-
import { YoEditor,
|
|
3
|
+
import { YoEditor, YooptaBaseElement } from '../types';
|
|
4
4
|
export type DraggedNode = {
|
|
5
5
|
path: number[] | null;
|
|
6
|
-
element: Pick<
|
|
6
|
+
element: Pick<YooptaBaseElement<string>, 'id' | 'type'> | null;
|
|
7
7
|
parent: NodeEntry<Node> | null;
|
|
8
8
|
};
|
|
9
9
|
export type DndState = {
|
|
@@ -13,7 +13,7 @@ export type DndState = {
|
|
|
13
13
|
export type DragDropValues = {
|
|
14
14
|
dndState: DndState;
|
|
15
15
|
disableWhileDrag: boolean;
|
|
16
|
-
DRAG_MAP: Map<
|
|
16
|
+
DRAG_MAP: Map<YooptaBaseElement<string>['id'], YooptaBaseElement<string>>;
|
|
17
17
|
};
|
|
18
18
|
export type DragDropHandlers = {
|
|
19
19
|
onDrop: (_e: DragEvent<HTMLDivElement>) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { YooptaPlugin, mergePlugins, createYooptaPlugin } from './utils/plugins';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { useElementSettings } from './contexts/NodeSettingsContext/NodeSettingsContext';
|
|
5
5
|
export { classnames as cx };
|
|
6
6
|
export { isKeyHotkey, isHotkey, isCodeHotkey } from 'is-hotkey';
|
|
7
|
-
|
|
8
|
-
export {
|
|
7
|
+
import { YooptaEditor } from './YooptaEditor';
|
|
8
|
+
export { isValidYooptaNodes } from './utils/validate';
|
|
9
9
|
export { generateId } from './utils/generateId';
|
|
10
10
|
export { HOTKEYS } from './utils/hotkeys';
|
|
11
|
-
export { useYopta } from './contexts/YoptaEditor/YoptaContext';
|
|
12
11
|
export { deepClone } from './utils/deepClone';
|
|
13
|
-
export {
|
|
12
|
+
export { createYooptaMark } from './utils/marks';
|
|
14
13
|
export { isElementActive, getElementByPath } from './utils/nodes';
|
|
15
|
-
export type {
|
|
16
|
-
export type {
|
|
17
|
-
export type { YoEditor, RenderElementProps,
|
|
14
|
+
export type { YooptaPluginType, YooptaPluginEventHandlers, HandlersOptions } from './utils/plugins';
|
|
15
|
+
export type { YooptaMarksConfig, YooptaMark } from './utils/marks';
|
|
16
|
+
export type { YoEditor, RenderElementProps, YooptaBaseElement, Modify } from './types';
|
|
18
17
|
declare const UI_HELPERS: {
|
|
19
18
|
ElementOptions: ({ onClose, style, element, render, ...props }: {
|
|
20
19
|
style: import("react").CSSProperties | undefined;
|
|
@@ -35,4 +34,5 @@ declare const UI_HELPERS: {
|
|
|
35
34
|
children: import("react").ReactNode;
|
|
36
35
|
}) => import("react").ReactPortal;
|
|
37
36
|
};
|
|
38
|
-
export {
|
|
37
|
+
export { YooptaPlugin, mergePlugins, createYooptaPlugin, useElementSettings, UI_HELPERS };
|
|
38
|
+
export default YooptaEditor;
|
package/dist/index.js
CHANGED
|
@@ -10,4 +10,4 @@ be={get exports(){return we},set exports(e){we=e}},function(){var e={}.hasOwnPro
|
|
|
10
10
|
*
|
|
11
11
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
12
12
|
* Released under the MIT License.
|
|
13
|
-
*/function Mt(e){return"[object Object]"===Object.prototype.toString.call(e)}function It(e){var t,n;return!1!==Mt(e)&&(void 0===(t=e.constructor)||!1!==Mt(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var Rt={isHistory:e=>It(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||x.isOperationList(e.redos[0]))&&(0===e.undos.length||x.isOperationList(e.undos[0]))},zt=new WeakMap,Ht=new WeakMap,Wt={isHistoryEditor:e=>Rt.isHistory(e.history)&&m.isEditor(e),isMerging:e=>Ht.get(e),isSaving:e=>zt.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=Wt.isMerging(e);Ht.set(e,!1),t(),Ht.set(e,n)},withoutSaving(e,t){var n=Wt.isSaving(e);zt.set(e,!1),t(),zt.set(e,n)}},Ut=(e,t)=>"set_selection"===e.type||(!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!b.equals(e.path,t.path))||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!b.equals(e.path,t.path))),Vt=(e,t)=>"set_selection"!==e.type||null!=e.properties&&null!=e.newProperties,Zt=(e,t)=>!(!t||"set_selection"!==e.type||"set_selection"!==t.type),$t=e=>"set_selection"!==e.type;function qt(e){return!!Array.isArray(e)&&0!==e.length}const Kt="yoopta-content";var Gt="u-OdDyDx";xe(".u-OdDyDx:after{color:#aaa;content:attr(data-placeholder);font-size:75%;font-style:inherit;font-weight:inherit;padding-left:5px;position:absolute;text-indent:2px;top:50%;transform:translateY(-50%);user-select:none}");const Jt={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},Xt=l((({attributes:e,children:n,placeholder:r,leaf:o})=>{const i=h();return t("span",Object.assign({},e,{"data-placeholder":r,style:Jt,className:_e({[Gt]:o.withPlaceholder&&r&&i})},{children:n}))}));Xt.displayName="TextLeaf";var Qt;function Yt(){return Yt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Yt.apply(this,arguments)}var en,tn=function(e){return n.createElement("svg",Yt({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),Qt||(Qt=n.createElement("path",{d:"M3 2a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm4-8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})))};function nn(){return nn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nn.apply(this,arguments)}var rn=function(e){return n.createElement("svg",nn({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),en||(en=n.createElement("path",{d:"M7.977 14.963c.407 0 .747-.324.747-.723V8.72h5.362c.399 0 .74-.34.74-.747a.746.746 0 0 0-.74-.738H8.724V1.706c0-.398-.34-.722-.747-.722a.732.732 0 0 0-.739.722v5.529h-5.37a.746.746 0 0 0-.74.738c0 .407.341.747.74.747h5.37v5.52c0 .399.332.723.739.723z"})))},on="yCQ-VdE5",an="b--398nS",sn="_6VhqH6wy",ln="k9i48GWd",cn="TNeDy6y5",dn="jVfkavqE",un="_87oFW01f";xe('.yCQ-VdE5{display:flex;left:-50px;opacity:0;position:absolute;top:2px;transition:opacity .18s ease-in}.b--398nS{opacity:1}._6VhqH6wy{all:unset;align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;color:rgba(55,53,47,.35);cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition:background-color .18s cubic-bezier(.4,0,.2,1);width:auto;width:18px}._6VhqH6wy:active,._6VhqH6wy:focus,._6VhqH6wy:hover{background-color:rgba(55,54,47,.08)}.k9i48GWd{width:24px}.TNeDy6y5{position:relative;transition:opacity .18s cubic-bezier(.4,0,.2,1)}.jVfkavqE:after{background-color:#007aff;bottom:-7px;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:before{top:-5px}._87oFW01f:after,._87oFW01f:before{background-color:inherit;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:after{bottom:-7px}');const fn=({element:n,editor:r,values:o,handlers:i})=>{const a=c(null),{hoveredElement:s,isElementOptionsOpen:l,nodeSettingsPos:d}=o,{onDragEnd:u,onDragStart:p,openNodeSettings:h,closeNodeSettings:g,triggerPlusButton:v}=i,y=e=>{e.stopPropagation();const t=a.current,o=document.querySelector(`[data-element-id="${null==n?void 0:n.id}"]`),i=f.findPath(r,n),s=m.parent(r,i);_.isElement(n)&&(null==t||t.setAttribute("draggable","false"),o&&(o.setAttribute("draggable","true"),o.ondragstart=e=>{const t={path:i,element:{id:n.id,type:n.type},parent:s};p(e,t)},o.ondragend=u))},b=(null==s?void 0:s.id)===n.id;return e("div",Object.assign({contentEditable:!1,className:_e(on,{[an]:b})},{children:[b&&l&&t(_t,{element:n,style:d||void 0,onClose:g}),t("button",Object.assign({type:"button",onMouseDown:y,className:_e(sn,ln),onClick:()=>v(n)},{children:t(rn,{})})),t("button",Object.assign({type:"button",onMouseDown:y,className:sn,onClick:()=>h(a,n),ref:a},{children:t(tn,{})}))]}))},pn=({children:n,element:r,attributes:o,nodeType:i,render:a})=>{var l;const c=p(),[d,u]=ht(),f="inline"===i,{hoverIn:h,onDrop:g}=u,{dndState:v,DRAG_MAP:y}=d,m=s((()=>{var e,t;if(null===v.from.element||null===v.to.element)return{isDragging:!1,isDragOver:!1,isDragSelf:!1};const n=(null===(e=d.dndState.from.element)||void 0===e?void 0:e.id)===r.id,o=(null===(t=d.dndState.to.element)||void 0===t?void 0:t.id)===r.id;return{isDragging:n,isDragOver:o,isDragSelf:n&&o}}),[d.dndState.from,d.dndState.to]),b=null===(l=r.data)||void 0===l?void 0:l.skipSettings,{isDragging:w,isDragOver:_,isDragSelf:x}=m,O={opacity:w?.7:1};return y.set(r.id,r),f?a({attributes:o,element:r,children:n}):e("div",Object.assign({"data-element-id":r.id,"data-element-type":r.type,onMouseEnter:e=>{b||h(e,r)},onDrop:g,className:_e(cn,{[dn]:_,[un]:x}),style:O},o,{children:[b?null:t(fn,{editor:c,element:r,handlers:u,values:d}),a({attributes:o,element:r,children:n})]}))};pn.displayName="ElementWrapper";const hn={bold:"mod+b",italic:"mod+i",compose:["down","left","right","up","backspace","enter"],arrowLeft:"left",arrowUp:"up",arrowDown:"down",arrowRight:"right",ctrlLeft:"ctrl+left",escape:"esc",ctrlRight:"ctrl+right",deleteBackward:"shift?+backspace",backspace:"backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",shiftEnter:"shift+enter",enter:"enter",space:"space",undo:"mod+z",select:"mod+a",shiftTab:"shift+tab",tab:"tab",cmd:"mod",cmdEnter:"mod+enter",kekCeburek:"mod+enter"},gn={moveLineBackward:"opt+up",moveLineForward:"opt+down",ctrlLeft:"opt+left",ctrlRight:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},vn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},yn=e=>{const t=hn[e],n=gn[e],r=vn[e],o=t&&Lt(t),i=n&&Lt(n),a=r&&Lt(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},mn={isBold:yn("bold"),isCompose:yn("compose"),isArrowLeft:yn("arrowLeft"),isArrowRight:yn("arrowRight"),isArrowUp:yn("arrowUp"),isArrowDown:yn("arrowDown"),isDeleteBackward:yn("deleteBackward"),isDeleteForward:yn("deleteForward"),isDeleteLineBackward:yn("deleteLineBackward"),isDeleteLineForward:yn("deleteLineForward"),isDeleteWordBackward:yn("deleteWordBackward"),isDeleteWordForward:yn("deleteWordForward"),isExtendBackward:yn("extendBackward"),isExtendForward:yn("extendForward"),isExtendLineBackward:yn("extendLineBackward"),isExtendLineForward:yn("extendLineForward"),isItalic:yn("italic"),isMoveLineBackward:yn("moveLineBackward"),isMoveLineForward:yn("moveLineForward"),isCtrlLeft:yn("ctrlLeft"),isCtrlRight:yn("ctrlRight"),isRedo:yn("redo"),isShiftEnter:yn("shiftEnter"),isEnter:yn("enter"),isTransposeCharacter:yn("transposeCharacter"),isUndo:yn("undo"),isSpace:yn("space"),isSelect:yn("select"),isTab:yn("tab"),isShiftTab:yn("shiftTab"),isBackspace:yn("backspace"),isCmdEnter:yn("cmdEnter"),isCmd:yn("cmd"),isEscape:yn("escape"),isKekceburek:yn("kekCeburek")},bn=(e,t)=>!!((e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(m.nodes(e,{at:m.unhangRange(e,n),match:e=>!m.isEditor(e)&&_.isElement(e)&&e.type===t}));return r})(e,t),wn=(e,t,n="lowest")=>{var r;const o=Array.from(m.nodes(e,{match:t=>m.isEditor(e)&&_.isElement(t),at:t||(null===(r=e.selection)||void 0===r?void 0:r.anchor.path),mode:n}))[0];return o?o[0]:e.children[0]};function _n(e,t){var n,r;if(O.isText(e))return function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>_n(e,t))).join(""),i=t[e.type];return"function"==typeof(null===(r=null===(n=i.exports)||void 0===n?void 0:n.html)||void 0===r?void 0:r.serialize)?i.exports.html.serialize(e,o):o}function xn(e,t){return e.map((e=>_n(e,t))).join("")}const On={hotkeys:mn,defaultNode:ct(Ze())},jn=({editor:n,placeholder:o,marks:a,readOnly:l,children:u,plugins:p,PLUGINS_MAP:h})=>{i((()=>{const e=window.location.hash.length>0?window.location.hash.replace("#",""):null;if(e){const t=document.getElementById(e)||document.querySelector(`[data-element-id="${e}"]`);t&&window.scrollTo({top:t.offsetTop,behavior:"smooth"})}}),[]);const v=c(null),[{disableWhileDrag:y},{changeHoveredNode:x}]=ht(),O=y||l,E=s((()=>e=>{const r=h[e.element.type],o=function(e){return"function"==typeof e.renderer?e.renderer:e.renderer.editor}(r)(n,r);return t(pn,Object.assign({element:e.element,attributes:e.attributes,nodeType:e.element.nodeType,render:o},{children:e.children}))}),[p,n]),k=s((()=>e=>{const t=[],[r,o]=e;return p.forEach((o=>{const i=o.decorator;"function"==typeof i&&_.isElement(r)&&r.type===o.type&&t.push(...i(n)(e))})),n.selection&&!m.isEditor(r)&&""===m.string(n,[o[0]])&&j.includes(n.selection,o)&&j.isCollapsed(n.selection)&&t.push(Object.assign(Object.assign({},n.selection),{withPlaceholder:!0})),t}),[p,n]),N=s((()=>e=>{var r;const i=Object.assign({},e);let s;p.forEach((e=>{if(e.leaf){const t=e.leaf(n)(i);t&&(i.children=t)}})),null==a||a.forEach((e=>{i.leaf[e.type]&&(i.children=e.render(i))}));const l=null===(r=i.children.props)||void 0===r?void 0:r.parent;if(!function(e){var t,n;return 1!==(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)||0!==(null===(n=null==e?void 0:e.children[0])||void 0===n?void 0:n.text.length)}(l)){const e=h[null==l?void 0:l.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||o}return t(Xt,Object.assign({},i,{placeholder:s}))}),[p,n]),S=s((()=>{const e=p.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){p.forEach((r=>{var o;if(null===(o=r.events)||void 0===o?void 0:o[e]){r.events[e](n,On)(t)}}))}})),t}),[p,n]),D=d((e=>{m.withoutNormalizing(n,(()=>{var t;if(!n.selection)return;const r=ct(Ze());null==a||a.forEach((t=>{t.hotkey&&Lt(t.hotkey)(e)&&(e.preventDefault(),dt(n,t.type,!1))})),null===(t=S.onKeyDown)||void 0===t||t.call(S,e);const o=m.above(n,{match:e=>!m.isEditor(e),mode:"lowest"});if(mn.isEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=Object.keys(m.marks(n)||{});t.length>0&&t.forEach((e=>m.removeMark(n,e)));const i=b.parent(n.selection.anchor.path),a=m.string(n,i),s=o&&o[0].type!==r.type;if(s&&0===a.length)return void w.setNodes(n,r,{at:i});if(m.isStart(n,n.selection.anchor,n.selection.anchor.path)&&s){const[e]=o;return w.setNodes(n,r,{at:i}),w.delete(n,{unit:"block"}),w.insertNodes(n,ze(e),{at:b.next(i)}),void w.select(n,{path:[b.next(n.selection.anchor.path)[0]+1,0],offset:0})}return w.splitNodes(n,{always:!0}),w.setNodes(n,r),void x(r)}if(mn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),n.insertText("\n")}if(mn.isSelect(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=m.above(n,{at:n.selection.anchor.path,match:e=>!m.isEditor(e)&&_.isElement(e)});if(!t)return;const r=m.string(n,t[1]);return j.isExpanded(n.selection)||0===r.length?void w.select(n,[]):void w.select(n,t[1])}}))}),[]),P=s((()=>r.Children.count(u)>0?r.Children.map(u,(e=>r.isValidElement(e)?r.cloneElement(e,Object.assign(Object.assign({},e.props),{plugins:p,marks:null==a?void 0:a.map((e=>e.type)),editorRef:v,PLUGINS_MAP:h})):null)):null),[p,a,v.current]);return e("div",Object.assign({id:"yoopta-editor",ref:v,onMouseDown:e=>{l||(e.preventDefault(),e.currentTarget===e.target&&n.selection&&m.withoutNormalizing(n,(()=>{const e=[n.children.length-1,0],t=wn(n,e,"highest"),r=m.string(n,e);console.log("lastNode",t),console.log("lastNodeText",r);const o={anchor:{path:e,offset:0},focus:{path:e,offset:0}};if("paragraph"===t.type&&0===r.length)return w.select(n,{path:o.anchor.path,offset:0}),x(t),f.focus(n);const i=ct(Ze());x(i),w.insertNodes(n,i,{at:[n.children.length],select:!0}),f.focus(n)})))}},{children:[P,t(g,Object.assign({id:"yoopta-contenteditable",renderLeaf:N,renderElement:E,readOnly:O,decorate:k,onCopy:e=>{if(e.preventDefault(),!n.selection)return;if(j.isCollapsed(n.selection))return;const t=xn(m.fragment(n,n.selection),n.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},autoFocus:!0,spellCheck:!0},S,{onKeyDown:D,onMouseDown:e=>{var t;null===(t=S.onMouseDown)||void 0===t||t.call(S,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)}}))]}))};function En(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=new WeakMap,Nn=new WeakMap;class Sn{}class Dn extends Sn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}class Pn extends Sn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}var Cn=e=>Nn.get(e);function An(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?An(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):An(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Bn=new WeakSet,Ln=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};Bn.add(o),e=o}if(O.isText(e)){var i=e;O.isText(r)&&Bn.has(r)&&Bn.has(i)&&O.equals(r,i,{loose:!0})?r.text+=i.text:t.push(i)}else if(_.isElement(e))t.push(e);else{if(!(e instanceof Sn))throw new Error("Unexpected hyperscript child object: ".concat(e));var a=t[t.length-1];O.isText(a)||(n(""),a=t[t.length-1]),e instanceof Dn?((e,t)=>{var n=e.text.length;kn.set(e,[n,t])})(a,e):e instanceof Pn&&((e,t)=>{var n=e.text.length;Nn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function Fn(e,t,n){return Tn(Tn({},t),{},{children:Ln(n)})}function Mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function In(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Mn(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Rn,zn={anchor:function(e,t,n){return new Dn(t)},cursor:function(e,t,n){return[new Dn(t),new Pn(t)]},editor:(Rn=k,(e,t,n)=>{var r,o=[];for(var i of n)j.isRange(i)?r=i:o.push(i);var a,s=Ln(o),l={},c=Rn();for(var[d,u]of(Object.assign(c,t),c.children=s,E.texts(c))){var f=(a=d,kn.get(a)),p=Cn(d);if(null!=f){var[h]=f;l.anchor={path:u,offset:h}}if(null!=p){var[g]=p;l.focus={path:u,offset:g}}}if(l.anchor&&!l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");if(!l.anchor&&l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");return null!=r?c.selection=r:j.isRange(l)&&(c.selection=l),c}),element:Fn,focus:function(e,t,n){return new Pn(t)},fragment:function(e,t,n){return Ln(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof Dn)),o=n.find((e=>e instanceof Pn));if(!r||null==r.offset||null==r.path)throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");if(!o||null==o.offset||null==o.path)throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");return Tn({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Ln(n);if(r.length>1)throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");var[o]=r;if(null==o&&(o={text:""}),!O.isText(o))throw new Error("\n The <text> hyperscript tag can only contain text content as children.");return Bn.delete(o),Object.assign(o,t),o}},Hn=e=>function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var a=e[t];if(!a)throw new Error("No hyperscript creator found for tag: <".concat(t,">"));return null==n&&(n={}),It(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},Wn=e=>{var t={},n=function(n){var r=e[n];if("object"!=typeof r)throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(n,"> tag you passed: ").concat(r));t[n]=(e,t,n)=>Fn(0,In(In({},r),t),n)};for(var r in e)n(r);return t},Un=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=Wn(t),r=In(In(In({},zn),n),e.creators);return Hn(r)}();const Vn={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},Zn=(e,t)=>{var n,r,o,i;if(3===e.nodeType)return e.textContent;if(1!==e.nodeType)return null;if("BR"===e.nodeName)return"\n";const{nodeName:a}=e;let s=e,l=Array.from(s.childNodes).map((e=>Zn(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return Un("fragment",{},l);if(t[a]){const s=t[a];if(s){let t=s.defineElement();if("function"==typeof(null===(r=null===(n=s.exports)||void 0===n?void 0:n.html.deserialize)||void 0===r?void 0:r.parse)){const n=null===(i=null===(o=s.exports)||void 0===o?void 0:o.html.deserialize)||void 0===i?void 0:i.parse(e);t=Object.assign(Object.assign({},t),{data:n})}return Un("element",t,l)}}if(O.isTextList(l))return Un("element",t.P.defineElement(),l);if(Vn[a]){const t=Vn[a](e);return l.map((e=>O.isText(e)?Un("text",t,e):e))}return l};function $n(e,t){const n=function(e){const t={};return Object.keys(e).forEach((n=>{var r,o,i,a,s,l,c,d;const u=e[n];if(null===(o=null===(r=u.exports)||void 0===r?void 0:r.html.deserialize)||void 0===o?void 0:o.nodeName){if(Array.isArray(null===(a=null===(i=u.exports)||void 0===i?void 0:i.html.deserialize)||void 0===a?void 0:a.nodeName))return void(null===(l=null===(s=u.exports)||void 0===s?void 0:s.html.deserialize)||void 0===l||l.nodeName.forEach((e=>{t[e]=u})));t[null===(d=null===(c=u.exports)||void 0===c?void 0:c.html.deserialize)||void 0===d?void 0:d.nodeName]=u}})),t}(t),r=(new DOMParser).parseFromString(e,"text/html");return Zn(r.body,n)}const qn=r.createContext({marks:{},plugins:{}}),Kn=({children:e,plugins:n,marks:r})=>{const o=p(),i=s((()=>{const e=me(n),t={};return e.forEach((e=>{const{createElement:n,defineElement:r,type:o,options:i}=e;t[e.type]={createElement:n,defineElement:r,type:o,options:i}})),t}),[n]),a=e=>{const t=m.marks(o);return!!(null==t?void 0:t[e])},l=s((()=>{const e={};return null==r||r.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(m.marks(o)||{}).forEach((e=>{m.removeMark(o,e)})),a(e)?m.removeMark(o,e):m.addMark(o,e,!0)})(t.type,null==e?void 0:e.only),isActive:a(t.type)}})),e}),[r,o.selection]),c=s((()=>({plugins:i,marks:l})),[o.selection,l,i]);return t(qn.Provider,Object.assign({value:c},{children:e}))},Gn=()=>a(qn),Jn=({key:e,value:n,plugins:r,marks:a,readOnly:l,children:c,onChange:u,placeholder:p,autoFocus:h=!0,shouldStoreInLocalStorage:g})=>{const N=function(e){return"object"==typeof e&&e.name?e.name:Kt}(g),[S,D]=o((()=>function(e,t,n){const r=[{id:Ze(),type:"paragraph",children:[{text:""}]}],o=qt(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return qt(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(N,g,n))),P=d((e=>{if(u(e),D(e),!g)return;if(B.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(N,t)}catch(e){}}),[g]),C=s((()=>{const e=me(r),t=function(e){const t={};return e.forEach((e=>t[e.type]=e)),t}(e);return{yoptaPlugins:e,PLUGINS_MAP:t}}),[r]),{yoptaPlugins:A,PLUGINS_MAP:T}=C,B=s((()=>{let e=(e=>{const{insertData:t}=e;return e.insertData=n=>{if(e.selection&&j.isExpanded(e.selection))return;const r=n.getData("text/html");if(r){const t=$n(r,e.plugins);w.insertFragment(e,t)}else t(n)},e})((e=>{const{deleteFragment:t}=e;return e.deleteFragment=()=>{const{selection:n}=e;if(!n)return;const[,r]=m.first(e,[0]),[,o]=m.last(e,[e.children.length-1]),i=m.range(e,r,o),a=j.equals(n,i);if(console.log({isAllNodesSelected:a,fullRange:i}),a)return w.removeNodes(e,{mode:"highest",hanging:!0}),void w.select(e,[0]);t()},e})((e=>{const{normalizeNode:t}=e;return e.normalizeNode=n=>{const[r]=n;if(m.isEditor(r)&&0===e.children.length){const t=ct(Ze());w.insertNodes(e,t,{at:[0]})}else t(n)},e})((e=>{const{insertBreak:t,deleteBackward:n}=e;return e.insertBreak=()=>{if(!e.selection||!j.isCollapsed(e.selection))return t();const n=b.parent(e.selection.anchor.path),r=E.get(e,n);_.isElement(r)&&m.isVoid(e,r)?m.insertNode(e,{id:Ze(),type:"paragraph",children:[{text:""}],nodeType:"block"}):t()},e.deleteBackward=t=>{if(!e.selection||!j.isCollapsed(e.selection)||0!==e.selection.anchor.offset)return n(t);const r=b.parent(e.selection.anchor.path),o=E.get(e,r);if(0===E.string(o).length&&b.hasPrevious(r)){const t=b.previous(r),n=E.get(e,t);if(_.isElement(n)&&m.isVoid(e,n))return w.removeNodes(e),w.select(e,t)}n(t)},e})((e=>{var t=e,{apply:n}=t;return t.history={undos:[],redos:[]},t.redo=()=>{var{history:e}=t,{redos:n}=e;if(n.length>0){var r=n[n.length-1];Wt.withoutSaving(t,(()=>{m.withoutNormalizing(t,(()=>{for(var e of r)t.apply(e)}))})),e.redos.pop(),e.undos.push(r)}},t.undo=()=>{var{history:e}=t,{undos:n}=e;if(n.length>0){var r=n[n.length-1];Wt.withoutSaving(t,(()=>{m.withoutNormalizing(t,(()=>{var e=r.map(x.inverse).reverse();for(var n of e)t.apply(n)}))})),e.redos.push(r),e.undos.pop()}},t.apply=e=>{var{operations:r,history:o}=t,{undos:i}=o,a=i[i.length-1],s=a&&a[a.length-1],l=Zt(e,s),c=Wt.isSaving(t),d=Wt.isMerging(t);if(null==c&&(c=Vt(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||Ut(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();$t(e)&&(o.redos=[])}n(e)},t})((e=>{const{insertText:t}=e;return e.insertText=n=>{var r,o;const{selection:i}=e;if(" "===n&&i&&j.isCollapsed(i)){const{anchor:a}=i,s=m.above(e,{match:t=>_.isElement(t)&&m.isBlock(e,t),mode:"lowest"});if(!s)return;const[,l]=s,c=m.parent(e,l),[d]=c;if(_.isElement(d)&&!O.isText(d.children[0]))return t(n);const u=s?l:[],f={anchor:a,focus:m.start(e,u)},p=m.string(e,f),h=null===(r=e.shortcuts)||void 0===r?void 0:r[p];if(h)return w.select(e,f),w.delete(e),void(null===(o=h.createElement)||void 0===o||o.call(h,e))}t(n)},e})(v(k())))))));e.plugins=T;const t={};return A.forEach((n=>{var r;n.shortcut&&(Array.isArray(n.shortcut)?n.shortcut.forEach((e=>t[e]=n)):t[n.shortcut]=n),e=(null===(r=n.extendEditor)||void 0===r?void 0:r.call(n,e))||e})),e.shortcuts=t,e}),[A]);return i((()=>{if(h)try{const[,e]=m.first(B,[0]);w.select(B,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),f.focus(B)}catch(e){}}),[h,B]),t(y,Object.assign({editor:B,value:S,onChange:P},{children:t(Kn,Object.assign({plugins:r,marks:a},{children:t(pt,{children:t(jn,{editor:B,readOnly:l,placeholder:p,plugins:A,children:c,marks:a,PLUGINS_MAP:T})})}))}),e)},Xn=e=>t(Ft,{children:t(Jn,Object.assign({},e,{value:e.value,onChange:e.onChange}))});function Qn({type:e,hotkey:n,className:r}){return{type:e,hotkey:n,render:e=>t("span",Object.assign({},e.attributes,{className:r},{children:e.children}))}}const Yn={ElementOptions:_t,Overlay:Se};export{mn as HOTKEYS,Yn as UI_HELPERS,Xn as YoptaEditor,ve as YoptaPlugin,Qn as createYoptaMark,ye as createYoptaPlugin,_e as cx,ze as deepClone,Ze as generateId,wn as getElementByPath,Bt as isCodeHotkey,bn as isElementActive,Tt as isHotkey,Lt as isKeyHotkey,qt as isValidYoptaNodes,me as mergePlugins,ht as useElementSettings,Gn as useYopta};
|
|
13
|
+
*/function Mt(e){return"[object Object]"===Object.prototype.toString.call(e)}function It(e){var t,n;return!1!==Mt(e)&&(void 0===(t=e.constructor)||!1!==Mt(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var Rt={isHistory:e=>It(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||x.isOperationList(e.redos[0]))&&(0===e.undos.length||x.isOperationList(e.undos[0]))},zt=new WeakMap,Ht=new WeakMap,Wt={isHistoryEditor:e=>Rt.isHistory(e.history)&&m.isEditor(e),isMerging:e=>Ht.get(e),isSaving:e=>zt.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=Wt.isMerging(e);Ht.set(e,!1),t(),Ht.set(e,n)},withoutSaving(e,t){var n=Wt.isSaving(e);zt.set(e,!1),t(),zt.set(e,n)}},Ut=(e,t)=>"set_selection"===e.type||(!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!b.equals(e.path,t.path))||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!b.equals(e.path,t.path))),Vt=(e,t)=>"set_selection"!==e.type||null!=e.properties&&null!=e.newProperties,Zt=(e,t)=>!(!t||"set_selection"!==e.type||"set_selection"!==t.type),$t=e=>"set_selection"!==e.type;function qt(e){return!!Array.isArray(e)&&0!==e.length}const Kt="yoopta-content";var Gt="u-OdDyDx";xe(".u-OdDyDx:after{color:#aaa;content:attr(data-placeholder);font-size:75%;font-style:inherit;font-weight:inherit;padding-left:5px;position:absolute;text-indent:2px;top:50%;transform:translateY(-50%);user-select:none}");const Jt={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},Xt=l((({attributes:e,children:n,placeholder:r,leaf:o})=>{const i=h();return t("span",Object.assign({},e,{"data-placeholder":r,style:Jt,className:_e({[Gt]:o.withPlaceholder&&r&&i})},{children:n}))}));Xt.displayName="TextLeaf";var Qt;function Yt(){return Yt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Yt.apply(this,arguments)}var en,tn=function(e){return n.createElement("svg",Yt({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),Qt||(Qt=n.createElement("path",{d:"M3 2a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm4-8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})))};function nn(){return nn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nn.apply(this,arguments)}var rn=function(e){return n.createElement("svg",nn({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),en||(en=n.createElement("path",{d:"M7.977 14.963c.407 0 .747-.324.747-.723V8.72h5.362c.399 0 .74-.34.74-.747a.746.746 0 0 0-.74-.738H8.724V1.706c0-.398-.34-.722-.747-.722a.732.732 0 0 0-.739.722v5.529h-5.37a.746.746 0 0 0-.74.738c0 .407.341.747.74.747h5.37v5.52c0 .399.332.723.739.723z"})))},on="yCQ-VdE5",an="b--398nS",sn="_6VhqH6wy",ln="k9i48GWd",cn="TNeDy6y5",dn="jVfkavqE",un="_87oFW01f";xe('.yCQ-VdE5{display:flex;left:-50px;opacity:0;position:absolute;top:2px;transition:opacity .18s ease-in}.b--398nS{opacity:1}._6VhqH6wy{all:unset;align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;color:rgba(55,53,47,.35);cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition:background-color .18s cubic-bezier(.4,0,.2,1);width:auto;width:18px}._6VhqH6wy:active,._6VhqH6wy:focus,._6VhqH6wy:hover{background-color:rgba(55,54,47,.08)}.k9i48GWd{width:24px}.TNeDy6y5{position:relative;transition:opacity .18s cubic-bezier(.4,0,.2,1)}.jVfkavqE:after{background-color:#007aff;bottom:-7px;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:before{top:-5px}._87oFW01f:after,._87oFW01f:before{background-color:inherit;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:after{bottom:-7px}');const fn=({element:n,editor:r,values:o,handlers:i})=>{const a=c(null),{hoveredElement:s,isElementOptionsOpen:l,nodeSettingsPos:d}=o,{onDragEnd:u,onDragStart:p,openNodeSettings:h,closeNodeSettings:g,triggerPlusButton:v}=i,y=e=>{e.stopPropagation();const t=a.current,o=document.querySelector(`[data-element-id="${null==n?void 0:n.id}"]`),i=f.findPath(r,n),s=m.parent(r,i);_.isElement(n)&&(null==t||t.setAttribute("draggable","false"),o&&(o.setAttribute("draggable","true"),o.ondragstart=e=>{const t={path:i,element:{id:n.id,type:n.type},parent:s};p(e,t)},o.ondragend=u))},b=(null==s?void 0:s.id)===n.id;return e("div",Object.assign({contentEditable:!1,className:_e(on,{[an]:b})},{children:[b&&l&&t(_t,{element:n,style:d||void 0,onClose:g}),t("button",Object.assign({type:"button",onMouseDown:y,className:_e(sn,ln),onClick:()=>v(n)},{children:t(rn,{})})),t("button",Object.assign({type:"button",onMouseDown:y,className:sn,onClick:()=>h(a,n),ref:a},{children:t(tn,{})}))]}))},pn=({children:n,element:r,attributes:o,nodeType:i,render:a})=>{var l;const c=p(),[d,u]=ht(),f="inline"===i,{hoverIn:h,onDrop:g}=u,{dndState:v,DRAG_MAP:y}=d,m=s((()=>{var e,t;if(null===v.from.element||null===v.to.element)return{isDragging:!1,isDragOver:!1,isDragSelf:!1};const n=(null===(e=d.dndState.from.element)||void 0===e?void 0:e.id)===r.id,o=(null===(t=d.dndState.to.element)||void 0===t?void 0:t.id)===r.id;return{isDragging:n,isDragOver:o,isDragSelf:n&&o}}),[d.dndState.from,d.dndState.to]),b=null===(l=r.data)||void 0===l?void 0:l.skipSettings,{isDragging:w,isDragOver:_,isDragSelf:x}=m,O={opacity:w?.7:1};return y.set(r.id,r),f?a({attributes:o,element:r,children:n}):e("div",Object.assign({"data-element-id":r.id,"data-element-type":r.type,onMouseEnter:e=>{b||h(e,r)},onDrop:g,className:_e(cn,{[dn]:_,[un]:x}),style:O},o,{children:[b?null:t(fn,{editor:c,element:r,handlers:u,values:d}),a({attributes:o,element:r,children:n})]}))};pn.displayName="ElementWrapper";const hn={bold:"mod+b",italic:"mod+i",compose:["down","left","right","up","backspace","enter"],arrowLeft:"left",arrowUp:"up",arrowDown:"down",arrowRight:"right",ctrlLeft:"ctrl+left",escape:"esc",ctrlRight:"ctrl+right",deleteBackward:"shift?+backspace",backspace:"backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",shiftEnter:"shift+enter",enter:"enter",space:"space",undo:"mod+z",select:"mod+a",shiftTab:"shift+tab",tab:"tab",cmd:"mod",cmdEnter:"mod+enter",kekCeburek:"mod+enter"},gn={moveLineBackward:"opt+up",moveLineForward:"opt+down",ctrlLeft:"opt+left",ctrlRight:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},vn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},yn=e=>{const t=hn[e],n=gn[e],r=vn[e],o=t&&Lt(t),i=n&&Lt(n),a=r&&Lt(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},mn={isBold:yn("bold"),isCompose:yn("compose"),isArrowLeft:yn("arrowLeft"),isArrowRight:yn("arrowRight"),isArrowUp:yn("arrowUp"),isArrowDown:yn("arrowDown"),isDeleteBackward:yn("deleteBackward"),isDeleteForward:yn("deleteForward"),isDeleteLineBackward:yn("deleteLineBackward"),isDeleteLineForward:yn("deleteLineForward"),isDeleteWordBackward:yn("deleteWordBackward"),isDeleteWordForward:yn("deleteWordForward"),isExtendBackward:yn("extendBackward"),isExtendForward:yn("extendForward"),isExtendLineBackward:yn("extendLineBackward"),isExtendLineForward:yn("extendLineForward"),isItalic:yn("italic"),isMoveLineBackward:yn("moveLineBackward"),isMoveLineForward:yn("moveLineForward"),isCtrlLeft:yn("ctrlLeft"),isCtrlRight:yn("ctrlRight"),isRedo:yn("redo"),isShiftEnter:yn("shiftEnter"),isEnter:yn("enter"),isTransposeCharacter:yn("transposeCharacter"),isUndo:yn("undo"),isSpace:yn("space"),isSelect:yn("select"),isTab:yn("tab"),isShiftTab:yn("shiftTab"),isBackspace:yn("backspace"),isCmdEnter:yn("cmdEnter"),isCmd:yn("cmd"),isEscape:yn("escape"),isKekceburek:yn("kekCeburek")},bn=(e,t)=>!!((e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(m.nodes(e,{at:m.unhangRange(e,n),match:e=>!m.isEditor(e)&&_.isElement(e)&&e.type===t}));return r})(e,t),wn=(e,t,n="lowest")=>{var r;const o=Array.from(m.nodes(e,{match:t=>m.isEditor(e)&&_.isElement(t),at:t||(null===(r=e.selection)||void 0===r?void 0:r.anchor.path),mode:n}))[0];return o?o[0]:e.children[0]};function _n(e,t){var n,r;if(O.isText(e))return function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>_n(e,t))).join(""),i=t[e.type];return"function"==typeof(null===(r=null===(n=i.exports)||void 0===n?void 0:n.html)||void 0===r?void 0:r.serialize)?i.exports.html.serialize(e,o):o}function xn(e,t){return e.map((e=>_n(e,t))).join("")}const On={hotkeys:mn,defaultNode:ct(Ze())},jn=({editor:n,placeholder:o,marks:a,readOnly:l,children:u,plugins:p,PLUGINS_MAP:h})=>{i((()=>{const e=window.location.hash.length>0?window.location.hash.replace("#",""):null;if(e){const t=document.getElementById(e)||document.querySelector(`[data-element-id="${e}"]`);t&&window.scrollTo({top:t.offsetTop,behavior:"smooth"})}}),[]);const v=c(null),[{disableWhileDrag:y},{changeHoveredNode:x}]=ht(),O=y||l,E=s((()=>e=>{const r=h[e.element.type],o=function(e){return"function"==typeof e.renderer?e.renderer:e.renderer.editor}(r)(n,r);return t(pn,Object.assign({element:e.element,attributes:e.attributes,nodeType:e.element.nodeType,render:o},{children:e.children}))}),[p,n]),k=s((()=>e=>{const t=[],[r,o]=e;return p.forEach((o=>{const i=o.decorator;"function"==typeof i&&_.isElement(r)&&r.type===o.type&&t.push(...i(n)(e))})),n.selection&&!m.isEditor(r)&&""===m.string(n,[o[0]])&&j.includes(n.selection,o)&&j.isCollapsed(n.selection)&&t.push(Object.assign(Object.assign({},n.selection),{withPlaceholder:!0})),t}),[p,n]),N=s((()=>e=>{var r;const i=Object.assign({},e);let s;p.forEach((e=>{if(e.leaf){const t=e.leaf(n)(i);t&&(i.children=t)}})),null==a||a.forEach((e=>{i.leaf[e.type]&&(i.children=e.render(i))}));const l=null===(r=i.children.props)||void 0===r?void 0:r.parent;if(!function(e){var t,n;return 1!==(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)||0!==(null===(n=null==e?void 0:e.children[0])||void 0===n?void 0:n.text.length)}(l)){const e=h[null==l?void 0:l.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||o}return t(Xt,Object.assign({},i,{placeholder:s}))}),[p,n]),S=s((()=>{const e=p.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){p.forEach((r=>{var o;if(null===(o=r.events)||void 0===o?void 0:o[e]){r.events[e](n,On)(t)}}))}})),t}),[p,n]),D=d((e=>{m.withoutNormalizing(n,(()=>{var t;if(!n.selection)return;const r=ct(Ze());null==a||a.forEach((t=>{t.hotkey&&Lt(t.hotkey)(e)&&(e.preventDefault(),dt(n,t.type,!1))})),null===(t=S.onKeyDown)||void 0===t||t.call(S,e);const o=m.above(n,{match:e=>!m.isEditor(e),mode:"lowest"});if(mn.isEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=Object.keys(m.marks(n)||{});t.length>0&&t.forEach((e=>m.removeMark(n,e)));const i=b.parent(n.selection.anchor.path),a=m.string(n,i),s=o&&o[0].type!==r.type;if(s&&0===a.length)return void w.setNodes(n,r,{at:i});if(m.isStart(n,n.selection.anchor,n.selection.anchor.path)&&s){const[e]=o;return w.setNodes(n,r,{at:i}),w.delete(n,{unit:"block"}),w.insertNodes(n,ze(e),{at:b.next(i)}),void w.select(n,{path:[b.next(n.selection.anchor.path)[0]+1,0],offset:0})}return w.splitNodes(n,{always:!0}),w.setNodes(n,r),void x(r)}if(mn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),n.insertText("\n")}if(mn.isSelect(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=m.above(n,{at:n.selection.anchor.path,match:e=>!m.isEditor(e)&&_.isElement(e)});if(!t)return;const r=m.string(n,t[1]);return j.isExpanded(n.selection)||0===r.length?void w.select(n,[]):void w.select(n,t[1])}}))}),[]),P=s((()=>r.Children.count(u)>0?r.Children.map(u,(e=>r.isValidElement(e)?r.cloneElement(e,Object.assign(Object.assign({},e.props),{plugins:p,marks:null==a?void 0:a.map((e=>e.type)),editorRef:v,PLUGINS_MAP:h})):null)):null),[p,a,v.current]);return e("div",Object.assign({id:"yoopta-editor",ref:v,onMouseDown:e=>{l||(e.preventDefault(),e.currentTarget===e.target&&n.selection&&m.withoutNormalizing(n,(()=>{const e=[n.children.length-1,0],t=wn(n,e,"highest"),r=m.string(n,e);console.log("lastNode",t),console.log("lastNodeText",r);const o={anchor:{path:e,offset:0},focus:{path:e,offset:0}};if("paragraph"===t.type&&0===r.length)return w.select(n,{path:o.anchor.path,offset:0}),x(t),f.focus(n);const i=ct(Ze());x(i),w.insertNodes(n,i,{at:[n.children.length],select:!0}),f.focus(n)})))}},{children:[P,t(g,Object.assign({id:"yoopta-contenteditable",renderLeaf:N,renderElement:E,readOnly:O,decorate:k,onCopy:e=>{if(e.preventDefault(),!n.selection)return;if(j.isCollapsed(n.selection))return;const t=xn(m.fragment(n,n.selection),n.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},autoFocus:!0,spellCheck:!0},S,{onKeyDown:D,onMouseDown:e=>{var t;null===(t=S.onMouseDown)||void 0===t||t.call(S,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)}}))]}))};function En(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=new WeakMap,Nn=new WeakMap;class Sn{}class Dn extends Sn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}class Pn extends Sn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}var Cn=e=>Nn.get(e);function An(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?An(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):An(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Bn=new WeakSet,Ln=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};Bn.add(o),e=o}if(O.isText(e)){var i=e;O.isText(r)&&Bn.has(r)&&Bn.has(i)&&O.equals(r,i,{loose:!0})?r.text+=i.text:t.push(i)}else if(_.isElement(e))t.push(e);else{if(!(e instanceof Sn))throw new Error("Unexpected hyperscript child object: ".concat(e));var a=t[t.length-1];O.isText(a)||(n(""),a=t[t.length-1]),e instanceof Dn?((e,t)=>{var n=e.text.length;kn.set(e,[n,t])})(a,e):e instanceof Pn&&((e,t)=>{var n=e.text.length;Nn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function Fn(e,t,n){return Tn(Tn({},t),{},{children:Ln(n)})}function Mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function In(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Mn(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Rn,zn={anchor:function(e,t,n){return new Dn(t)},cursor:function(e,t,n){return[new Dn(t),new Pn(t)]},editor:(Rn=k,(e,t,n)=>{var r,o=[];for(var i of n)j.isRange(i)?r=i:o.push(i);var a,s=Ln(o),l={},c=Rn();for(var[d,u]of(Object.assign(c,t),c.children=s,E.texts(c))){var f=(a=d,kn.get(a)),p=Cn(d);if(null!=f){var[h]=f;l.anchor={path:u,offset:h}}if(null!=p){var[g]=p;l.focus={path:u,offset:g}}}if(l.anchor&&!l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");if(!l.anchor&&l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");return null!=r?c.selection=r:j.isRange(l)&&(c.selection=l),c}),element:Fn,focus:function(e,t,n){return new Pn(t)},fragment:function(e,t,n){return Ln(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof Dn)),o=n.find((e=>e instanceof Pn));if(!r||null==r.offset||null==r.path)throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");if(!o||null==o.offset||null==o.path)throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");return Tn({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Ln(n);if(r.length>1)throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");var[o]=r;if(null==o&&(o={text:""}),!O.isText(o))throw new Error("\n The <text> hyperscript tag can only contain text content as children.");return Bn.delete(o),Object.assign(o,t),o}},Hn=e=>function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var a=e[t];if(!a)throw new Error("No hyperscript creator found for tag: <".concat(t,">"));return null==n&&(n={}),It(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},Wn=e=>{var t={},n=function(n){var r=e[n];if("object"!=typeof r)throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(n,"> tag you passed: ").concat(r));t[n]=(e,t,n)=>Fn(0,In(In({},r),t),n)};for(var r in e)n(r);return t},Un=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=Wn(t),r=In(In(In({},zn),n),e.creators);return Hn(r)}();const Vn={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},Zn=(e,t)=>{var n,r,o,i;if(3===e.nodeType)return e.textContent;if(1!==e.nodeType)return null;if("BR"===e.nodeName)return"\n";const{nodeName:a}=e;let s=e,l=Array.from(s.childNodes).map((e=>Zn(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return Un("fragment",{},l);if(t[a]){const s=t[a];if(s){let t=s.defineElement();if("function"==typeof(null===(r=null===(n=s.exports)||void 0===n?void 0:n.html.deserialize)||void 0===r?void 0:r.parse)){const n=null===(i=null===(o=s.exports)||void 0===o?void 0:o.html.deserialize)||void 0===i?void 0:i.parse(e);t=Object.assign(Object.assign({},t),{data:n})}return Un("element",t,l)}}if(O.isTextList(l))return Un("element",t.P.defineElement(),l);if(Vn[a]){const t=Vn[a](e);return l.map((e=>O.isText(e)?Un("text",t,e):e))}return l};function $n(e,t){const n=function(e){const t={};return Object.keys(e).forEach((n=>{var r,o,i,a,s,l,c,d;const u=e[n];if(null===(o=null===(r=u.exports)||void 0===r?void 0:r.html.deserialize)||void 0===o?void 0:o.nodeName){if(Array.isArray(null===(a=null===(i=u.exports)||void 0===i?void 0:i.html.deserialize)||void 0===a?void 0:a.nodeName))return void(null===(l=null===(s=u.exports)||void 0===s?void 0:s.html.deserialize)||void 0===l||l.nodeName.forEach((e=>{t[e]=u})));t[null===(d=null===(c=u.exports)||void 0===c?void 0:c.html.deserialize)||void 0===d?void 0:d.nodeName]=u}})),t}(t),r=(new DOMParser).parseFromString(e,"text/html");return Zn(r.body,n)}const qn=r.createContext({marks:{},plugins:{}}),Kn=({children:e,plugins:n,marks:r})=>{const o=p(),i=s((()=>{const e=me(n),t={};return e.forEach((e=>{const{createElement:n,defineElement:r,type:o,options:i}=e;t[e.type]={createElement:n,defineElement:r,type:o,options:i}})),t}),[n]),a=e=>{const t=m.marks(o);return!!(null==t?void 0:t[e])},l=s((()=>{const e={};return null==r||r.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(m.marks(o)||{}).forEach((e=>{m.removeMark(o,e)})),a(e)?m.removeMark(o,e):m.addMark(o,e,!0)})(t.type,null==e?void 0:e.only),isActive:a(t.type)}})),e}),[r,o.selection]),c=s((()=>({plugins:i,marks:l})),[o.selection,l,i]);return t(qn.Provider,Object.assign({value:c},{children:e}))},Gn=({key:e,value:n,plugins:r,marks:a,readOnly:l,children:c,onChange:u,placeholder:p,autoFocus:h=!0,shouldStoreInLocalStorage:g})=>{const N=function(e){return"object"==typeof e&&e.name?e.name:Kt}(g),[S,D]=o((()=>function(e,t,n){const r=[{id:Ze(),type:"paragraph",children:[{text:""}]}],o=qt(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return qt(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(N,g,n))),P=d((e=>{if(u(e),D(e),!g)return;if(B.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(N,t)}catch(e){}}),[g]),C=s((()=>{const e=me(r),t=function(e){const t={};return e.forEach((e=>t[e.type]=e)),t}(e);return{yooptaPlugins:e,PLUGINS_MAP:t}}),[r]),{yooptaPlugins:A,PLUGINS_MAP:T}=C,B=s((()=>{let e=(e=>{const{insertData:t}=e;return e.insertData=n=>{if(e.selection&&j.isExpanded(e.selection))return;const r=n.getData("text/html");if(r){const t=$n(r,e.plugins);w.insertFragment(e,t)}else t(n)},e})((e=>{const{deleteFragment:t}=e;return e.deleteFragment=()=>{const{selection:n}=e;if(!n)return;const[,r]=m.first(e,[0]),[,o]=m.last(e,[e.children.length-1]),i=m.range(e,r,o),a=j.equals(n,i);if(console.log({isAllNodesSelected:a,fullRange:i}),a)return w.removeNodes(e,{mode:"highest",hanging:!0}),void w.select(e,[0]);t()},e})((e=>{const{normalizeNode:t}=e;return e.normalizeNode=n=>{const[r]=n;if(m.isEditor(r)&&0===e.children.length){const t=ct(Ze());w.insertNodes(e,t,{at:[0]})}else t(n)},e})((e=>{const{insertBreak:t,deleteBackward:n}=e;return e.insertBreak=()=>{if(!e.selection||!j.isCollapsed(e.selection))return t();const n=b.parent(e.selection.anchor.path),r=E.get(e,n);_.isElement(r)&&m.isVoid(e,r)?m.insertNode(e,{id:Ze(),type:"paragraph",children:[{text:""}],nodeType:"block"}):t()},e.deleteBackward=t=>{if(!e.selection||!j.isCollapsed(e.selection)||0!==e.selection.anchor.offset)return n(t);const r=b.parent(e.selection.anchor.path),o=E.get(e,r);if(0===E.string(o).length&&b.hasPrevious(r)){const t=b.previous(r),n=E.get(e,t);if(_.isElement(n)&&m.isVoid(e,n))return w.removeNodes(e),w.select(e,t)}n(t)},e})((e=>{var t=e,{apply:n}=t;return t.history={undos:[],redos:[]},t.redo=()=>{var{history:e}=t,{redos:n}=e;if(n.length>0){var r=n[n.length-1];Wt.withoutSaving(t,(()=>{m.withoutNormalizing(t,(()=>{for(var e of r)t.apply(e)}))})),e.redos.pop(),e.undos.push(r)}},t.undo=()=>{var{history:e}=t,{undos:n}=e;if(n.length>0){var r=n[n.length-1];Wt.withoutSaving(t,(()=>{m.withoutNormalizing(t,(()=>{var e=r.map(x.inverse).reverse();for(var n of e)t.apply(n)}))})),e.redos.push(r),e.undos.pop()}},t.apply=e=>{var{operations:r,history:o}=t,{undos:i}=o,a=i[i.length-1],s=a&&a[a.length-1],l=Zt(e,s),c=Wt.isSaving(t),d=Wt.isMerging(t);if(null==c&&(c=Vt(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||Ut(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();$t(e)&&(o.redos=[])}n(e)},t})((e=>{const{insertText:t}=e;return e.insertText=n=>{var r,o;const{selection:i}=e;if(" "===n&&i&&j.isCollapsed(i)){const{anchor:a}=i,s=m.above(e,{match:t=>_.isElement(t)&&m.isBlock(e,t),mode:"lowest"});if(!s)return;const[,l]=s,c=m.parent(e,l),[d]=c;if(_.isElement(d)&&!O.isText(d.children[0]))return t(n);const u=s?l:[],f={anchor:a,focus:m.start(e,u)},p=m.string(e,f),h=null===(r=e.shortcuts)||void 0===r?void 0:r[p];if(h)return w.select(e,f),w.delete(e),void(null===(o=h.createElement)||void 0===o||o.call(h,e))}t(n)},e})(v(k())))))));e.plugins=T;const t={};return A.forEach((n=>{var r;n.shortcut&&(Array.isArray(n.shortcut)?n.shortcut.forEach((e=>t[e]=n)):t[n.shortcut]=n),e=(null===(r=n.extendEditor)||void 0===r?void 0:r.call(n,e))||e})),e.shortcuts=t,e}),[A]);return i((()=>{if(h)try{const[,e]=m.first(B,[0]);w.select(B,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),f.focus(B)}catch(e){}}),[h,B]),t(y,Object.assign({editor:B,value:S,onChange:P},{children:t(Kn,Object.assign({plugins:r,marks:a},{children:t(pt,{children:t(jn,{editor:B,readOnly:l,placeholder:p,plugins:A,children:c,marks:a,PLUGINS_MAP:T})})}))}),e)},Jn=e=>t(Ft,{children:t(Gn,Object.assign({},e,{value:e.value,onChange:e.onChange}))});function Xn({type:e,hotkey:n,className:r}){return{type:e,hotkey:n,render:e=>t("span",Object.assign({},e.attributes,{className:r},{children:e.children}))}}const Qn={ElementOptions:_t,Overlay:Se};export{mn as HOTKEYS,Qn as UI_HELPERS,ve as YooptaPlugin,Xn as createYooptaMark,ye as createYooptaPlugin,_e as cx,ze as deepClone,Jn as default,Ze as generateId,wn as getElementByPath,Bt as isCodeHotkey,bn as isElementActive,Tt as isHotkey,Lt as isKeyHotkey,qt as isValidYooptaNodes,me as mergePlugins,ht as useElementSettings};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { BaseEditor, BaseElement } from 'slate';
|
|
2
2
|
import { ReactEditor, RenderElementProps as ElementProps } from 'slate-react';
|
|
3
3
|
import { HistoryEditor } from 'slate-history';
|
|
4
|
-
import {
|
|
4
|
+
import { YooptaPluginType } from './utils/plugins';
|
|
5
5
|
export type EmptyText = {
|
|
6
6
|
text: string;
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
8
|
+
export type YooptaElementConfig = {
|
|
9
9
|
nodeType: 'block' | 'inline' | 'void';
|
|
10
10
|
};
|
|
11
11
|
export type Modify<T, R> = Omit<T, keyof R> & R;
|
|
12
|
-
export type
|
|
12
|
+
export type YooptaBaseElement<T> = {
|
|
13
13
|
id: string;
|
|
14
14
|
type: T;
|
|
15
15
|
children: BaseElement['children'];
|
|
16
16
|
data?: any;
|
|
17
|
-
} &
|
|
17
|
+
} & YooptaElementConfig;
|
|
18
18
|
export type RenderElementProps<T extends BaseElement = BaseElement> = ElementProps & {
|
|
19
19
|
element: T;
|
|
20
20
|
};
|
|
21
21
|
export interface YoEditor extends BaseEditor, ReactEditor, HistoryEditor {
|
|
22
|
-
shortcuts: Record<string,
|
|
23
|
-
plugins: Record<
|
|
22
|
+
shortcuts: Record<string, YooptaPluginType<string>>;
|
|
23
|
+
plugins: Record<YooptaBaseElement<string>['type'], YooptaPluginType<any, YooptaBaseElement<string>>>;
|
|
24
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare function mergePluginTypesToMapHMTLNodeName(plugins: Record<
|
|
4
|
-
export declare function deserializeHtml(htmlString: string, plugins: Record<
|
|
1
|
+
import { YooptaBaseElement } from '../types';
|
|
2
|
+
import { YooptaPluginType } from './plugins';
|
|
3
|
+
export declare function mergePluginTypesToMapHMTLNodeName(plugins: Record<YooptaBaseElement<string>['type'], YooptaPluginType<any, YooptaBaseElement<string>>>): Record<YooptaBaseElement<string>['type'], YooptaPluginType<any, YooptaBaseElement<string>>>;
|
|
4
|
+
export declare function deserializeHtml(htmlString: string, plugins: Record<YooptaBaseElement<string>['type'], YooptaPluginType<any, YooptaBaseElement<string>>>): any;
|
package/dist/utils/marks.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { RenderLeafProps } from 'slate-react';
|
|
3
|
-
export type
|
|
3
|
+
export type YooptaMark = {
|
|
4
4
|
type: string;
|
|
5
5
|
hotkey?: string;
|
|
6
6
|
render: (props: RenderLeafProps) => JSX.Element;
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
8
|
+
export type YooptaMarksConfig = {
|
|
9
9
|
type: string;
|
|
10
10
|
className: string;
|
|
11
11
|
hotkey?: string;
|
|
12
12
|
};
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function createYooptaMark({ type, hotkey, className }: YooptaMarksConfig): YooptaMark;
|
package/dist/utils/plugins.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { Element, NodeEntry, Range } from 'slate';
|
|
3
3
|
import { RenderLeafProps } from 'slate-react';
|
|
4
|
-
import { YoEditor, RenderElementProps,
|
|
4
|
+
import { YoEditor, RenderElementProps, YooptaBaseElement } from '../types';
|
|
5
5
|
import { EditorEventHandlers } from '../types/eventHandlers';
|
|
6
6
|
import { HOTKEYS_TYPE } from './hotkeys';
|
|
7
7
|
export type HandlersOptions = {
|
|
@@ -9,17 +9,17 @@ export type HandlersOptions = {
|
|
|
9
9
|
defaultNode: Element;
|
|
10
10
|
};
|
|
11
11
|
export type DecoratorFn = (nodeEntry: NodeEntry) => Range[];
|
|
12
|
-
export type
|
|
12
|
+
export type YooptaPluginEventHandlers = {
|
|
13
13
|
[key in keyof EditorEventHandlers]: (editor: YoEditor, options: HandlersOptions) => EditorEventHandlers[key] | void;
|
|
14
14
|
};
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
18
|
-
export type
|
|
19
|
-
editor:
|
|
15
|
+
export type YooptaPluginBaseOptions = Record<string, unknown>;
|
|
16
|
+
export type YooptaRenderElementFunc<P extends YooptaBaseElement<string> = YooptaBaseElement<string>> = (editor: YoEditor, plugin: YooptaPluginType) => (props: RenderElementProps<P>) => ReactElement;
|
|
17
|
+
export type YooptaRender<P extends YooptaBaseElement<string>> = YooptaRenderElementFunc<P>;
|
|
18
|
+
export type ExtendedYooptaRender<P extends YooptaBaseElement<string>> = {
|
|
19
|
+
editor: YooptaRenderElementFunc<P>;
|
|
20
20
|
render: (props: RenderElementProps<P>) => ReactElement;
|
|
21
21
|
};
|
|
22
|
-
export type
|
|
22
|
+
export type YooptaRenderer<P extends YooptaBaseElement<string>> = ExtendedYooptaRender<P> | YooptaRender<P>;
|
|
23
23
|
type DeserializeHTML = {
|
|
24
24
|
nodeName: string | string[];
|
|
25
25
|
parse?: (el: HTMLElement) => any;
|
|
@@ -35,30 +35,30 @@ type Exports<T> = {
|
|
|
35
35
|
parse: (mark: any) => any;
|
|
36
36
|
}>;
|
|
37
37
|
};
|
|
38
|
-
export type
|
|
38
|
+
export type YooptaPluginType<O = YooptaPluginBaseOptions, P extends YooptaBaseElement<string> = YooptaBaseElement<string>> = {
|
|
39
39
|
type: string;
|
|
40
|
-
renderer:
|
|
40
|
+
renderer: YooptaRenderer<P>;
|
|
41
41
|
shortcut?: string | string[];
|
|
42
42
|
decorator?: (editor: YoEditor) => DecoratorFn;
|
|
43
|
-
events?:
|
|
43
|
+
events?: YooptaPluginEventHandlers;
|
|
44
44
|
extendEditor?: (editor: YoEditor) => YoEditor;
|
|
45
45
|
leaf?: (editor: YoEditor) => (props: RenderLeafProps) => any;
|
|
46
46
|
placeholder?: string | null;
|
|
47
47
|
options?: O;
|
|
48
|
-
childPlugin?:
|
|
48
|
+
childPlugin?: YooptaPlugin<any, any>;
|
|
49
49
|
hasParent?: boolean;
|
|
50
50
|
createElement?: (editor: YoEditor) => void;
|
|
51
51
|
defineElement: () => P;
|
|
52
52
|
exports?: Exports<P>;
|
|
53
53
|
};
|
|
54
|
-
export type
|
|
55
|
-
export declare class
|
|
54
|
+
export type ParentYooptaPlugin<O = YooptaPluginBaseOptions> = Omit<YooptaPluginType<O>, 'childPlugin' | 'hasParent'>;
|
|
55
|
+
export declare class YooptaPlugin<O extends YooptaPluginBaseOptions, P extends YooptaBaseElement<string>> {
|
|
56
56
|
#private;
|
|
57
|
-
constructor(inputPlugin:
|
|
58
|
-
extend(overrides: Partial<
|
|
59
|
-
get getPlugin():
|
|
57
|
+
constructor(inputPlugin: YooptaPluginType<O, P>);
|
|
58
|
+
extend(overrides: Partial<YooptaPluginType<O, P>>): YooptaPlugin<O, P>;
|
|
59
|
+
get getPlugin(): YooptaPluginType<O, P>;
|
|
60
60
|
}
|
|
61
|
-
export declare function
|
|
62
|
-
export declare function mergePlugins<O extends
|
|
63
|
-
export declare function mergePluginTypesToMap(plugins:
|
|
61
|
+
export declare function createYooptaPlugin<O extends YooptaPluginBaseOptions, P extends YooptaBaseElement<string>>(input: YooptaPluginType<O, P>): YooptaPlugin<O, P>;
|
|
62
|
+
export declare function mergePlugins<O extends YooptaPluginBaseOptions, P extends YooptaBaseElement<string>>(plugins: YooptaPlugin<O, P>[]): YooptaPluginType<O, P>[];
|
|
63
|
+
export declare function mergePluginTypesToMap(plugins: YooptaPluginType<any, YooptaBaseElement<string>>[]): Record<YooptaBaseElement<string>['type'], YooptaPluginType<any, YooptaBaseElement<string>>>;
|
|
64
64
|
export {};
|
package/dist/utils/validate.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function isValidYooptaNodes(nodes: any): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoopta/editor",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2-rc",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/lodash.uniqwith": "^4.5.7"
|
|
63
63
|
},
|
|
64
|
-
"description": "<h2 align=\"center\">
|
|
64
|
+
"description": "<h2 align=\"center\">Yoopta-Editor v1 🎉</h2> <p align=\"center\">Yoopta-Editor - is an open source notion-like editor 💥</p> <div align=\"center\"> <img width=\"574\" alt=\"Screen Shot 2023-01-25 at 16 04 29\" src=\"https://user-images.githubusercontent.com/29093118/215324525-882bf403-646c-4267-bb5f-c0f37509ac09.png\"> </div>",
|
|
65
65
|
"repository": {
|
|
66
66
|
"type": "git",
|
|
67
|
-
"url": "git+https://github.com/Darginec05/
|
|
67
|
+
"url": "git+https://github.com/Darginec05/Yoopta-Editor.git"
|
|
68
68
|
},
|
|
69
69
|
"author": "https://github.com/Darginec05",
|
|
70
70
|
"bugs": {
|
|
71
|
-
"url": "https://github.com/Darginec05/
|
|
71
|
+
"url": "https://github.com/Darginec05/Yoopta-Editor/issues"
|
|
72
72
|
},
|
|
73
|
-
"homepage": "https://github.com/Darginec05/
|
|
73
|
+
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme"
|
|
74
74
|
}
|
package/dist/YoptaEditor.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { YoptaBaseElement } from '../../types';
|
|
3
|
-
import { YoptaPlugin, YoptaPluginType } from '../../utils/plugins';
|
|
4
|
-
import { YoptaMark } from '../../utils/marks';
|
|
5
|
-
export type HoveredElement = YoptaBaseElement<string> | null;
|
|
6
|
-
export type YoptaContextValues = {
|
|
7
|
-
marks: MarksMap;
|
|
8
|
-
plugins: PluginsMap;
|
|
9
|
-
};
|
|
10
|
-
export type YoptaContextHandlers = {};
|
|
11
|
-
export type YoptaContextType = YoptaContextValues;
|
|
12
|
-
type NodeSettingsProps = {
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
plugins: YoptaPlugin<any, any>[];
|
|
15
|
-
marks?: YoptaMark[];
|
|
16
|
-
};
|
|
17
|
-
type PluginsMap = Record<string, Pick<YoptaPluginType, 'type' | 'createElement' | 'defineElement'>>;
|
|
18
|
-
type MarksMap = {
|
|
19
|
-
[x: string]: {
|
|
20
|
-
toggle: (options?: {
|
|
21
|
-
only: boolean;
|
|
22
|
-
}) => void;
|
|
23
|
-
isActive: boolean;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
declare const YoptaContextProvider: ({ children, plugins: pluginList, marks: markList }: NodeSettingsProps) => JSX.Element;
|
|
27
|
-
declare const useYopta: () => YoptaContextValues;
|
|
28
|
-
export { YoptaContextProvider, useYopta };
|