@use-kona/editor 0.1.0-rc.0
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 +23 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/core/createEditable.d.ts +7 -0
- package/dist/core/createEditable.js +110 -0
- package/dist/core/createEditor.d.ts +2 -0
- package/dist/core/createEditor.js +167 -0
- package/dist/core/deserialize.d.ts +3 -0
- package/dist/core/deserialize.js +33 -0
- package/dist/core/queries.d.ts +2 -0
- package/dist/core/queries.js +10 -0
- package/dist/core/serialize.d.ts +3 -0
- package/dist/core/serialize.js +13 -0
- package/dist/core/styles.module.js +6 -0
- package/dist/core/styles_module.css +29 -0
- package/dist/defaultValue.d.ts +4 -0
- package/dist/defaultValue.js +13 -0
- package/dist/editor.d.ts +10 -0
- package/dist/editor.js +43 -0
- package/dist/elements/BaseElement.d.ts +2 -0
- package/dist/elements/BaseElement.js +6 -0
- package/dist/examples/Backdrop.d.ts +5 -0
- package/dist/examples/Backdrop.js +13 -0
- package/dist/examples/Backdrop.module.js +5 -0
- package/dist/examples/Backdrop_module.css +6 -0
- package/dist/examples/DragBlock.d.ts +11 -0
- package/dist/examples/DragBlock.js +38 -0
- package/dist/examples/DragBlock.module.js +9 -0
- package/dist/examples/DragBlock_module.css +43 -0
- package/dist/examples/DragHandler.d.ts +2 -0
- package/dist/examples/DragHandler.js +44 -0
- package/dist/examples/DragHandler.module.js +8 -0
- package/dist/examples/DragHandler_module.css +18 -0
- package/dist/examples/Editor.d.ts +2 -0
- package/dist/examples/Editor.js +23 -0
- package/dist/examples/Editor.module.js +12 -0
- package/dist/examples/Editor_module.css +128 -0
- package/dist/examples/FloatingMenu.d.ts +17 -0
- package/dist/examples/FloatingMenu.js +244 -0
- package/dist/examples/FloatingMenu.module.js +9 -0
- package/dist/examples/FloatingMenu_module.css +75 -0
- package/dist/examples/LanguageSelector.d.ts +10 -0
- package/dist/examples/LanguageSelector.js +154 -0
- package/dist/examples/LanguageSelector.module.js +7 -0
- package/dist/examples/LanguageSelector_module.css +52 -0
- package/dist/examples/LinksHint.d.ts +7 -0
- package/dist/examples/LinksHint.js +50 -0
- package/dist/examples/LinksHint.module.js +6 -0
- package/dist/examples/LinksHint_module.css +28 -0
- package/dist/examples/Menu.d.ts +6 -0
- package/dist/examples/Menu.js +79 -0
- package/dist/examples/Menu.module.js +8 -0
- package/dist/examples/Menu_module.css +38 -0
- package/dist/examples/colors.d.ts +10 -0
- package/dist/examples/colors.js +12 -0
- package/dist/examples/getCommands.d.ts +2 -0
- package/dist/examples/getCommands.js +87 -0
- package/dist/examples/getPlugins.d.ts +2 -0
- package/dist/examples/getPlugins.js +127 -0
- package/dist/examples/getShortcuts.d.ts +2 -0
- package/dist/examples/getShortcuts.js +90 -0
- package/dist/examples/icons/bold.d.ts +2 -0
- package/dist/examples/icons/bold.js +27 -0
- package/dist/examples/icons/check.d.ts +2 -0
- package/dist/examples/icons/check.js +24 -0
- package/dist/examples/icons/chevronRight.d.ts +2 -0
- package/dist/examples/icons/chevronRight.js +24 -0
- package/dist/examples/icons/color.d.ts +2 -0
- package/dist/examples/icons/color.js +30 -0
- package/dist/examples/icons/copy.d.ts +2 -0
- package/dist/examples/icons/copy.js +27 -0
- package/dist/examples/icons/cross.d.ts +2 -0
- package/dist/examples/icons/cross.js +27 -0
- package/dist/examples/icons/drag.d.ts +2 -0
- package/dist/examples/icons/drag.js +39 -0
- package/dist/examples/icons/edit.d.ts +2 -0
- package/dist/examples/icons/edit.js +30 -0
- package/dist/examples/icons/external.d.ts +2 -0
- package/dist/examples/icons/external.js +30 -0
- package/dist/examples/icons/heading1.d.ts +2 -0
- package/dist/examples/icons/heading1.js +45 -0
- package/dist/examples/icons/heading2.d.ts +2 -0
- package/dist/examples/icons/heading2.js +45 -0
- package/dist/examples/icons/heading3.d.ts +2 -0
- package/dist/examples/icons/heading3.js +48 -0
- package/dist/examples/icons/italic.d.ts +2 -0
- package/dist/examples/icons/italic.js +30 -0
- package/dist/examples/icons/link.d.ts +2 -0
- package/dist/examples/icons/link.js +30 -0
- package/dist/examples/icons/ol.d.ts +2 -0
- package/dist/examples/icons/ol.js +36 -0
- package/dist/examples/icons/strikethrough.d.ts +2 -0
- package/dist/examples/icons/strikethrough.js +27 -0
- package/dist/examples/icons/text.d.ts +2 -0
- package/dist/examples/icons/text.js +22 -0
- package/dist/examples/icons/types.d.ts +3 -0
- package/dist/examples/icons/types.js +0 -0
- package/dist/examples/icons/ul.d.ts +2 -0
- package/dist/examples/icons/ul.js +39 -0
- package/dist/examples/icons/underline.d.ts +2 -0
- package/dist/examples/icons/underline.js +27 -0
- package/dist/examples/store.d.ts +8 -0
- package/dist/examples/store.js +6 -0
- package/dist/examples/styles.module.js +11 -0
- package/dist/examples/styles_module.css +78 -0
- package/dist/examples/text.d.ts +3 -0
- package/dist/examples/text.js +60 -0
- package/dist/examples/ui/Button/Button.d.ts +8 -0
- package/dist/examples/ui/Button/Button.js +15 -0
- package/dist/examples/ui/Button/ButtonWrapper.d.ts +4 -0
- package/dist/examples/ui/Button/ButtonWrapper.js +14 -0
- package/dist/examples/ui/Button/index.d.ts +2 -0
- package/dist/examples/ui/Button/index.js +3 -0
- package/dist/examples/ui/Button/styles.module.js +10 -0
- package/dist/examples/ui/Button/styles_module.css +72 -0
- package/dist/examples/ui/Button/types.d.ts +1 -0
- package/dist/examples/ui/Button/types.js +0 -0
- package/dist/examples/ui/Dropdown/Dropdown.d.ts +16 -0
- package/dist/examples/ui/Dropdown/Dropdown.js +75 -0
- package/dist/examples/ui/Dropdown/index.d.ts +1 -0
- package/dist/examples/ui/Dropdown/index.js +2 -0
- package/dist/examples/ui/Menu/Menu.d.ts +41 -0
- package/dist/examples/ui/Menu/Menu.js +404 -0
- package/dist/examples/ui/Menu/MenuDelimiter.d.ts +1 -0
- package/dist/examples/ui/Menu/MenuDelimiter.js +6 -0
- package/dist/examples/ui/Menu/MenuHotkey.d.ts +6 -0
- package/dist/examples/ui/Menu/MenuHotkey.js +12 -0
- package/dist/examples/ui/Menu/MenuIcon.d.ts +6 -0
- package/dist/examples/ui/Menu/MenuIcon.js +12 -0
- package/dist/examples/ui/Menu/MenuItem.d.ts +6 -0
- package/dist/examples/ui/Menu/MenuItem.js +17 -0
- package/dist/examples/ui/Menu/MenuTitle.d.ts +6 -0
- package/dist/examples/ui/Menu/MenuTitle.js +12 -0
- package/dist/examples/ui/Menu/SafeSpace.d.ts +6 -0
- package/dist/examples/ui/Menu/SafeSpace.js +65 -0
- package/dist/examples/ui/Menu/index.d.ts +2 -0
- package/dist/examples/ui/Menu/index.js +2 -0
- package/dist/examples/ui/Menu/styles.module.js +21 -0
- package/dist/examples/ui/Menu/styles_module.css +140 -0
- package/dist/examples/ui/Menu/types.d.ts +16 -0
- package/dist/examples/ui/Menu/types.js +0 -0
- package/dist/examples/ui/useMenuPosition.d.ts +18 -0
- package/dist/examples/ui/useMenuPosition.js +51 -0
- package/dist/examples/ui/useMergeRefs.d.ts +23 -0
- package/dist/examples/ui/useMergeRefs.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/plugins/AttachmentsPlugin/AttachmentsPlugin.d.ts +17 -0
- package/dist/plugins/AttachmentsPlugin/AttachmentsPlugin.js +37 -0
- package/dist/plugins/AttachmentsPlugin/index.d.ts +1 -0
- package/dist/plugins/AttachmentsPlugin/index.js +2 -0
- package/dist/plugins/AttachmentsPlugin/types.d.ts +11 -0
- package/dist/plugins/AttachmentsPlugin/types.js +0 -0
- package/dist/plugins/BasicFormattingPlugin/BasicFormattingPlugin.d.ts +20 -0
- package/dist/plugins/BasicFormattingPlugin/BasicFormattingPlugin.js +76 -0
- package/dist/plugins/BasicFormattingPlugin/index.d.ts +1 -0
- package/dist/plugins/BasicFormattingPlugin/index.js +2 -0
- package/dist/plugins/BreaksPlugin/BreaksPlugin.d.ts +15 -0
- package/dist/plugins/BreaksPlugin/BreaksPlugin.js +50 -0
- package/dist/plugins/BreaksPlugin/index.d.ts +1 -0
- package/dist/plugins/BreaksPlugin/index.js +2 -0
- package/dist/plugins/CodeBlockPlugin/CodeBlock.d.ts +9 -0
- package/dist/plugins/CodeBlockPlugin/CodeBlock.js +18 -0
- package/dist/plugins/CodeBlockPlugin/CodeBlockLine.d.ts +2 -0
- package/dist/plugins/CodeBlockPlugin/CodeBlockLine.js +9 -0
- package/dist/plugins/CodeBlockPlugin/CodeBlockPlugin.d.ts +55 -0
- package/dist/plugins/CodeBlockPlugin/CodeBlockPlugin.js +224 -0
- package/dist/plugins/CodeBlockPlugin/index.d.ts +1 -0
- package/dist/plugins/CodeBlockPlugin/index.js +2 -0
- package/dist/plugins/CodeBlockPlugin/styles.module.js +6 -0
- package/dist/plugins/CodeBlockPlugin/styles_module.css +12 -0
- package/dist/plugins/CodeBlockPlugin/types.d.ts +8 -0
- package/dist/plugins/CodeBlockPlugin/types.js +0 -0
- package/dist/plugins/CodeBlockPlugin/utils.d.ts +13 -0
- package/dist/plugins/CodeBlockPlugin/utils.js +87 -0
- package/dist/plugins/CommandsPlugin/CommandsPlugin.d.ts +11 -0
- package/dist/plugins/CommandsPlugin/CommandsPlugin.js +65 -0
- package/dist/plugins/CommandsPlugin/Menu.d.ts +11 -0
- package/dist/plugins/CommandsPlugin/Menu.js +153 -0
- package/dist/plugins/CommandsPlugin/actions.d.ts +7 -0
- package/dist/plugins/CommandsPlugin/actions.js +29 -0
- package/dist/plugins/CommandsPlugin/index.d.ts +2 -0
- package/dist/plugins/CommandsPlugin/index.js +2 -0
- package/dist/plugins/CommandsPlugin/styles.module.js +9 -0
- package/dist/plugins/CommandsPlugin/styles_module.css +66 -0
- package/dist/plugins/CommandsPlugin/types.d.ts +27 -0
- package/dist/plugins/CommandsPlugin/types.js +0 -0
- package/dist/plugins/DnDPlugin/DnDPlugin.d.ts +33 -0
- package/dist/plugins/DnDPlugin/DnDPlugin.js +110 -0
- package/dist/plugins/DnDPlugin/index.d.ts +1 -0
- package/dist/plugins/DnDPlugin/index.js +2 -0
- package/dist/plugins/DnDPlugin/styles.module.js +9 -0
- package/dist/plugins/DnDPlugin/styles_module.css +43 -0
- package/dist/plugins/FloatingMenuPlugin/FloatingMenu.d.ts +9 -0
- package/dist/plugins/FloatingMenuPlugin/FloatingMenu.js +89 -0
- package/dist/plugins/FloatingMenuPlugin/FloatingMenuPlugin.d.ts +15 -0
- package/dist/plugins/FloatingMenuPlugin/FloatingMenuPlugin.js +36 -0
- package/dist/plugins/FloatingMenuPlugin/index.d.ts +2 -0
- package/dist/plugins/FloatingMenuPlugin/index.js +2 -0
- package/dist/plugins/FloatingMenuPlugin/styles.module.js +7 -0
- package/dist/plugins/FloatingMenuPlugin/styles_module.css +23 -0
- package/dist/plugins/FloatingMenuPlugin/types.d.ts +16 -0
- package/dist/plugins/FloatingMenuPlugin/types.js +0 -0
- package/dist/plugins/HeadingsPlugin/HeadingsPlugin.d.ts +19 -0
- package/dist/plugins/HeadingsPlugin/HeadingsPlugin.js +64 -0
- package/dist/plugins/HeadingsPlugin/index.d.ts +1 -0
- package/dist/plugins/HeadingsPlugin/index.js +2 -0
- package/dist/plugins/HighlightsPlugin/HighlightsPlugin.d.ts +16 -0
- package/dist/plugins/HighlightsPlugin/HighlightsPlugin.js +36 -0
- package/dist/plugins/HighlightsPlugin/index.d.ts +1 -0
- package/dist/plugins/HighlightsPlugin/index.js +2 -0
- package/dist/plugins/LinksPlugin/Link.d.ts +11 -0
- package/dist/plugins/LinksPlugin/Link.js +89 -0
- package/dist/plugins/LinksPlugin/LinksPlugin.d.ts +17 -0
- package/dist/plugins/LinksPlugin/LinksPlugin.js +102 -0
- package/dist/plugins/LinksPlugin/constants.d.ts +1 -0
- package/dist/plugins/LinksPlugin/constants.js +2 -0
- package/dist/plugins/LinksPlugin/index.d.ts +2 -0
- package/dist/plugins/LinksPlugin/index.js +2 -0
- package/dist/plugins/LinksPlugin/styles.module.js +11 -0
- package/dist/plugins/LinksPlugin/styles_module.css +71 -0
- package/dist/plugins/LinksPlugin/types.d.ts +18 -0
- package/dist/plugins/LinksPlugin/types.js +0 -0
- package/dist/plugins/ListsPlugin/ListsPlugin.d.ts +32 -0
- package/dist/plugins/ListsPlugin/ListsPlugin.js +218 -0
- package/dist/plugins/ListsPlugin/index.d.ts +1 -0
- package/dist/plugins/ListsPlugin/index.js +2 -0
- package/dist/plugins/ListsPlugin/styles.module.js +6 -0
- package/dist/plugins/ListsPlugin/styles_module.css +8 -0
- package/dist/plugins/MenuPlugin/Menu.d.ts +2 -0
- package/dist/plugins/MenuPlugin/Menu.js +14 -0
- package/dist/plugins/MenuPlugin/MenuPlugin.d.ts +7 -0
- package/dist/plugins/MenuPlugin/MenuPlugin.js +19 -0
- package/dist/plugins/MenuPlugin/index.d.ts +1 -0
- package/dist/plugins/MenuPlugin/index.js +2 -0
- package/dist/plugins/MenuPlugin/styles.module.js +6 -0
- package/dist/plugins/MenuPlugin/styles_module.css +33 -0
- package/dist/plugins/MenuPlugin/types.d.ts +4 -0
- package/dist/plugins/MenuPlugin/types.js +0 -0
- package/dist/plugins/NodeIdPlugin/NodeIdPlugin.d.ts +15 -0
- package/dist/plugins/NodeIdPlugin/NodeIdPlugin.js +36 -0
- package/dist/plugins/NodeIdPlugin/index.d.ts +1 -0
- package/dist/plugins/NodeIdPlugin/index.js +2 -0
- package/dist/plugins/PlaceholderPlugin/PlaceholderPlugin.d.ts +16 -0
- package/dist/plugins/PlaceholderPlugin/PlaceholderPlugin.js +44 -0
- package/dist/plugins/PlaceholderPlugin/index.d.ts +1 -0
- package/dist/plugins/PlaceholderPlugin/index.js +2 -0
- package/dist/plugins/PlaceholderPlugin/styles.module.js +5 -0
- package/dist/plugins/PlaceholderPlugin/styles_module.css +14 -0
- package/dist/plugins/ShortcutsPlugin/ShortcutsPlugin.d.ts +24 -0
- package/dist/plugins/ShortcutsPlugin/ShortcutsPlugin.js +55 -0
- package/dist/plugins/ShortcutsPlugin/index.d.ts +2 -0
- package/dist/plugins/ShortcutsPlugin/index.js +2 -0
- package/dist/plugins/TableOfContentsPlugin/TableOfContentsPlugin.d.ts +18 -0
- package/dist/plugins/TableOfContentsPlugin/TableOfContentsPlugin.js +76 -0
- package/dist/plugins/TableOfContentsPlugin/index.d.ts +1 -0
- package/dist/plugins/TableOfContentsPlugin/index.js +2 -0
- package/dist/plugins/TableOfContentsPlugin/styles.module.js +10 -0
- package/dist/plugins/TableOfContentsPlugin/styles_module.css +114 -0
- package/dist/plugins/index.d.ts +16 -0
- package/dist/plugins/index.js +17 -0
- package/dist/queries/getMatchedGroups.d.ts +0 -0
- package/dist/queries/getMatchedGroups.js +0 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.js +0 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +8 -0
- package/package.json +71 -0
- package/src/constants.ts +1 -0
- package/src/core/createEditable.tsx +159 -0
- package/src/core/createEditor.ts +244 -0
- package/src/core/deserialize.ts +57 -0
- package/src/core/queries.ts +10 -0
- package/src/core/serialize.ts +38 -0
- package/src/core/styles.module.css +28 -0
- package/src/defaultValue.ts +10 -0
- package/src/editor.tsx +55 -0
- package/src/elements/BaseElement.tsx +5 -0
- package/src/examples/Backdrop.module.css +8 -0
- package/src/examples/Backdrop.tsx +16 -0
- package/src/examples/DragBlock.module.css +42 -0
- package/src/examples/DragBlock.tsx +57 -0
- package/src/examples/DragHandler.module.css +17 -0
- package/src/examples/DragHandler.tsx +39 -0
- package/src/examples/Editor.module.css +130 -0
- package/src/examples/Editor.tsx +26 -0
- package/src/examples/FloatingMenu.module.css +74 -0
- package/src/examples/FloatingMenu.tsx +274 -0
- package/src/examples/LanguageSelector.module.css +51 -0
- package/src/examples/LanguageSelector.tsx +99 -0
- package/src/examples/LinksHint.module.css +27 -0
- package/src/examples/LinksHint.tsx +58 -0
- package/src/examples/Menu.module.css +37 -0
- package/src/examples/Menu.tsx +80 -0
- package/src/examples/colors.ts +11 -0
- package/src/examples/getCommands.tsx +76 -0
- package/src/examples/getPlugins.tsx +143 -0
- package/src/examples/getShortcuts.ts +107 -0
- package/src/examples/icons/bold.tsx +20 -0
- package/src/examples/icons/check.tsx +19 -0
- package/src/examples/icons/chevronRight.tsx +19 -0
- package/src/examples/icons/color.tsx +23 -0
- package/src/examples/icons/copy.tsx +20 -0
- package/src/examples/icons/cross.tsx +20 -0
- package/src/examples/icons/drag.tsx +24 -0
- package/src/examples/icons/edit.tsx +21 -0
- package/src/examples/icons/external.tsx +21 -0
- package/src/examples/icons/heading1.tsx +26 -0
- package/src/examples/icons/heading2.tsx +26 -0
- package/src/examples/icons/heading3.tsx +27 -0
- package/src/examples/icons/italic.tsx +21 -0
- package/src/examples/icons/link.tsx +21 -0
- package/src/examples/icons/ol.tsx +23 -0
- package/src/examples/icons/strikethrough.tsx +20 -0
- package/src/examples/icons/text.tsx +18 -0
- package/src/examples/icons/types.ts +3 -0
- package/src/examples/icons/ul.tsx +24 -0
- package/src/examples/icons/underline.tsx +20 -0
- package/src/examples/store.ts +14 -0
- package/src/examples/styles.module.css +77 -0
- package/src/examples/text.tsx +133 -0
- package/src/examples/ui/Button/Button.tsx +34 -0
- package/src/examples/ui/Button/ButtonWrapper.tsx +22 -0
- package/src/examples/ui/Button/index.ts +2 -0
- package/src/examples/ui/Button/styles.module.css +75 -0
- package/src/examples/ui/Button/types.ts +1 -0
- package/src/examples/ui/Dropdown/Dropdown.tsx +101 -0
- package/src/examples/ui/Dropdown/index.ts +1 -0
- package/src/examples/ui/Menu/Menu.tsx +576 -0
- package/src/examples/ui/Menu/MenuDelimiter.tsx +3 -0
- package/src/examples/ui/Menu/MenuHotkey.tsx +17 -0
- package/src/examples/ui/Menu/MenuIcon.tsx +17 -0
- package/src/examples/ui/Menu/MenuItem.tsx +45 -0
- package/src/examples/ui/Menu/MenuTitle.tsx +17 -0
- package/src/examples/ui/Menu/SafeSpace.tsx +84 -0
- package/src/examples/ui/Menu/index.ts +2 -0
- package/src/examples/ui/Menu/styles.module.css +143 -0
- package/src/examples/ui/Menu/types.ts +18 -0
- package/src/examples/ui/useMenuPosition.ts +72 -0
- package/src/examples/ui/useMergeRefs.ts +39 -0
- package/src/index.ts +2 -0
- package/src/plugins/AttachmentsPlugin/AttachmentsPlugin.tsx +41 -0
- package/src/plugins/AttachmentsPlugin/index.ts +1 -0
- package/src/plugins/AttachmentsPlugin/types.ts +12 -0
- package/src/plugins/BasicFormattingPlugin/BasicFormattingPlugin.tsx +100 -0
- package/src/plugins/BasicFormattingPlugin/index.ts +1 -0
- package/src/plugins/BreaksPlugin/BreaksPlugin.tsx +70 -0
- package/src/plugins/BreaksPlugin/index.ts +1 -0
- package/src/plugins/CodeBlockPlugin/CodeBlock.tsx +20 -0
- package/src/plugins/CodeBlockPlugin/CodeBlockLine.tsx +7 -0
- package/src/plugins/CodeBlockPlugin/CodeBlockPlugin.tsx +304 -0
- package/src/plugins/CodeBlockPlugin/index.ts +1 -0
- package/src/plugins/CodeBlockPlugin/styles.module.css +11 -0
- package/src/plugins/CodeBlockPlugin/types.ts +10 -0
- package/src/plugins/CodeBlockPlugin/utils.ts +117 -0
- package/src/plugins/CommandsPlugin/CommandsPlugin.tsx +99 -0
- package/src/plugins/CommandsPlugin/Menu.tsx +205 -0
- package/src/plugins/CommandsPlugin/actions.ts +41 -0
- package/src/plugins/CommandsPlugin/index.ts +2 -0
- package/src/plugins/CommandsPlugin/styles.module.css +69 -0
- package/src/plugins/CommandsPlugin/types.ts +32 -0
- package/src/plugins/DnDPlugin/DnDPlugin.tsx +200 -0
- package/src/plugins/DnDPlugin/index.ts +1 -0
- package/src/plugins/DnDPlugin/styles.module.css +42 -0
- package/src/plugins/FloatingMenuPlugin/FloatingMenu.tsx +144 -0
- package/src/plugins/FloatingMenuPlugin/FloatingMenuPlugin.tsx +44 -0
- package/src/plugins/FloatingMenuPlugin/index.ts +2 -0
- package/src/plugins/FloatingMenuPlugin/styles.module.css +22 -0
- package/src/plugins/FloatingMenuPlugin/types.ts +18 -0
- package/src/plugins/HeadingsPlugin/HeadingsPlugin.tsx +75 -0
- package/src/plugins/HeadingsPlugin/index.ts +1 -0
- package/src/plugins/HighlightsPlugin/HighlightsPlugin.tsx +56 -0
- package/src/plugins/HighlightsPlugin/index.ts +1 -0
- package/src/plugins/LinksPlugin/Link.tsx +90 -0
- package/src/plugins/LinksPlugin/LinksPlugin.tsx +128 -0
- package/src/plugins/LinksPlugin/constants.ts +1 -0
- package/src/plugins/LinksPlugin/index.ts +2 -0
- package/src/plugins/LinksPlugin/styles.module.css +73 -0
- package/src/plugins/LinksPlugin/types.ts +19 -0
- package/src/plugins/ListsPlugin/ListsPlugin.tsx +355 -0
- package/src/plugins/ListsPlugin/index.ts +1 -0
- package/src/plugins/ListsPlugin/styles.module.css +7 -0
- package/src/plugins/MenuPlugin/Menu.tsx +9 -0
- package/src/plugins/MenuPlugin/MenuPlugin.tsx +20 -0
- package/src/plugins/MenuPlugin/index.ts +1 -0
- package/src/plugins/MenuPlugin/styles.module.css +33 -0
- package/src/plugins/MenuPlugin/types.ts +5 -0
- package/src/plugins/NodeIdPlugin/NodeIdPlugin.ts +62 -0
- package/src/plugins/NodeIdPlugin/index.ts +1 -0
- package/src/plugins/PlaceholderPlugin/PlaceholderPlugin.tsx +66 -0
- package/src/plugins/PlaceholderPlugin/index.ts +1 -0
- package/src/plugins/PlaceholderPlugin/styles.module.css +17 -0
- package/src/plugins/ShortcutsPlugin/ShortcutsPlugin.tsx +133 -0
- package/src/plugins/ShortcutsPlugin/index.ts +2 -0
- package/src/plugins/TableOfContentsPlugin/TableOfContentsPlugin.tsx +102 -0
- package/src/plugins/TableOfContentsPlugin/index.ts +1 -0
- package/src/plugins/TableOfContentsPlugin/styles.module.css +113 -0
- package/src/plugins/index.ts +20 -0
- package/src/queries/getMatchedGroups.ts +0 -0
- package/src/types.ts +87 -0
- package/src/utils.ts +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Rslib project
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Install the dependencies:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Get started
|
|
12
|
+
|
|
13
|
+
Build the library:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Build the library in watch mode:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm dev
|
|
23
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ELEMENT_PARAGRAPH = "paragraph";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Editor } from 'slate';
|
|
2
|
+
import type { IPlugin } from '../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
readOnly?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const createEditable: (editor: Editor, plugins: IPlugin[]) => ({ readOnly }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import is_hotkey from "is-hotkey";
|
|
3
|
+
import react, { isValidElement, useCallback } from "react";
|
|
4
|
+
import { Editable, useReadOnly } from "slate-react";
|
|
5
|
+
import { BaseElement } from "../elements/BaseElement.js";
|
|
6
|
+
import styles_module from "./styles.module.js";
|
|
7
|
+
const SUPPORTED_HANDLERS = [
|
|
8
|
+
'onDrop',
|
|
9
|
+
'onKeyDown',
|
|
10
|
+
'onPaste'
|
|
11
|
+
];
|
|
12
|
+
const createEditable = (editor, plugins)=>({ readOnly })=>{
|
|
13
|
+
const renderElement = (props)=>{
|
|
14
|
+
let result = null;
|
|
15
|
+
for (const plugin of plugins)for (const element of plugin.blocks || []){
|
|
16
|
+
if (element.type !== props.element.type) continue;
|
|
17
|
+
const newElement = element.render(props, editor);
|
|
18
|
+
result = newElement || result;
|
|
19
|
+
}
|
|
20
|
+
for (const plugin of plugins)if (plugin.renderBlock) result = plugin.renderBlock({
|
|
21
|
+
...props,
|
|
22
|
+
children: result || props.children
|
|
23
|
+
});
|
|
24
|
+
return result || /*#__PURE__*/ jsx(BaseElement, {
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const renderLeaf = (props)=>{
|
|
29
|
+
let result;
|
|
30
|
+
for (const plugin of plugins)plugin.leafs?.map((element)=>{
|
|
31
|
+
const newElement = element.render({
|
|
32
|
+
...props,
|
|
33
|
+
children: result || props.children
|
|
34
|
+
}, editor);
|
|
35
|
+
if (newElement && /*#__PURE__*/ isValidElement(newElement)) result = newElement;
|
|
36
|
+
});
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
const handleHotkey = (event)=>{
|
|
40
|
+
for (const plugin of plugins)if (plugin.hotkeys) {
|
|
41
|
+
for (const hotkey of plugin.hotkeys)if (is_hotkey(hotkey[0], event) && hotkey[1]) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
hotkey[1](event, editor);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const decorate = (entry)=>{
|
|
48
|
+
const decorators = plugins.filter((plugin)=>!!plugin.decorate);
|
|
49
|
+
return decorators.reduce((decorations, plugin)=>{
|
|
50
|
+
const pluginDecorators = plugin.decorate?.(entry) || [];
|
|
51
|
+
return decorations.concat(pluginDecorators);
|
|
52
|
+
}, []);
|
|
53
|
+
};
|
|
54
|
+
const handlers = plugins.reduce((handlers, plugin)=>{
|
|
55
|
+
SUPPORTED_HANDLERS.forEach((handlerName)=>{
|
|
56
|
+
if (plugin.handlers?.[handlerName]) {
|
|
57
|
+
const lastHandler = handlers[handlerName];
|
|
58
|
+
if (lastHandler) handlers[handlerName] = (event)=>{
|
|
59
|
+
lastHandler(event, editor);
|
|
60
|
+
plugin.handlers?.[handlerName](event, editor);
|
|
61
|
+
};
|
|
62
|
+
else handlers[handlerName] = (event)=>{
|
|
63
|
+
plugin.handlers?.[handlerName](event, editor);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return handlers;
|
|
68
|
+
}, {
|
|
69
|
+
onKeyDown: handleHotkey
|
|
70
|
+
});
|
|
71
|
+
const Ui = useCallback(({ children })=>{
|
|
72
|
+
const ui = plugins.filter((p)=>Boolean(p.ui));
|
|
73
|
+
const readOnly = useReadOnly();
|
|
74
|
+
if (!ui.length) return /*#__PURE__*/ jsx("div", {
|
|
75
|
+
className: styles_module.editor,
|
|
76
|
+
children: children
|
|
77
|
+
});
|
|
78
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
79
|
+
children: [
|
|
80
|
+
ui.map((p, index)=>/*#__PURE__*/ jsx(react.Fragment, {
|
|
81
|
+
children: p.ui({
|
|
82
|
+
readOnly,
|
|
83
|
+
children,
|
|
84
|
+
editor
|
|
85
|
+
})
|
|
86
|
+
}, index)),
|
|
87
|
+
/*#__PURE__*/ jsx("div", {
|
|
88
|
+
className: styles_module.editor,
|
|
89
|
+
children: children
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
}, [
|
|
94
|
+
editor,
|
|
95
|
+
plugins.filter
|
|
96
|
+
]);
|
|
97
|
+
return /*#__PURE__*/ jsx("div", {
|
|
98
|
+
className: styles_module.root,
|
|
99
|
+
children: /*#__PURE__*/ jsx(Ui, {
|
|
100
|
+
children: /*#__PURE__*/ jsx(Editable, {
|
|
101
|
+
decorate: decorate,
|
|
102
|
+
renderElement: renderElement,
|
|
103
|
+
renderLeaf: renderLeaf,
|
|
104
|
+
readOnly: readOnly,
|
|
105
|
+
...handlers
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
export { createEditable };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Editor, Path, Range, Transforms, createEditor } from "slate";
|
|
2
|
+
import { withHistory } from "slate-history";
|
|
3
|
+
import { withReact } from "slate-react";
|
|
4
|
+
const createEditor_createEditor = (plugins)=>()=>{
|
|
5
|
+
const baseEditor = withHistory(withReact(createEditor()));
|
|
6
|
+
const editorWithPlugins = plugins.reduce((editor, plugin)=>{
|
|
7
|
+
if (plugin.init) return plugin.init(editor);
|
|
8
|
+
return editor;
|
|
9
|
+
}, baseEditor);
|
|
10
|
+
const { isInline, isVoid, normalizeNode, deleteFragment, deleteBackward, deleteForward } = editorWithPlugins;
|
|
11
|
+
editorWithPlugins.normalizeNode = (entry)=>{
|
|
12
|
+
const [node, path] = entry;
|
|
13
|
+
const lastElement = editorWithPlugins.children[editorWithPlugins.children.length - 1];
|
|
14
|
+
if (!lastElement || 'paragraph' !== lastElement.type) {
|
|
15
|
+
const paragraph = {
|
|
16
|
+
type: 'paragraph',
|
|
17
|
+
children: [
|
|
18
|
+
{
|
|
19
|
+
text: ''
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
Transforms.insertNodes(editorWithPlugins, paragraph, {
|
|
24
|
+
at: [
|
|
25
|
+
editorWithPlugins.children.length
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return normalizeNode([
|
|
30
|
+
node,
|
|
31
|
+
path
|
|
32
|
+
]);
|
|
33
|
+
};
|
|
34
|
+
editorWithPlugins.isVoid = (element)=>{
|
|
35
|
+
const result = plugins.reduce((result, plugin)=>{
|
|
36
|
+
const match = plugin.blocks?.find((el)=>element?.type === el.type);
|
|
37
|
+
if (match && 'isVoid' in match) return match.isVoid;
|
|
38
|
+
return result;
|
|
39
|
+
}, void 0);
|
|
40
|
+
return result ?? isVoid(element);
|
|
41
|
+
};
|
|
42
|
+
editorWithPlugins.isInline = (element)=>{
|
|
43
|
+
const result = plugins.reduce((result, plugin)=>{
|
|
44
|
+
const match = plugin.blocks?.find((el)=>element?.type === el.type);
|
|
45
|
+
if (match && 'isInline' in match) return match.isInline;
|
|
46
|
+
return result;
|
|
47
|
+
}, void 0);
|
|
48
|
+
return result ?? isInline(element);
|
|
49
|
+
};
|
|
50
|
+
editorWithPlugins.deleteForward = async (unit)=>{
|
|
51
|
+
const { selection } = editorWithPlugins;
|
|
52
|
+
if (!selection) return;
|
|
53
|
+
if (Range.isCollapsed(selection)) {
|
|
54
|
+
const firstEntry = Editor.above(editorWithPlugins, {
|
|
55
|
+
at: selection.anchor,
|
|
56
|
+
match: (n)=>Editor.isBlock(editorWithPlugins, n),
|
|
57
|
+
mode: 'lowest'
|
|
58
|
+
});
|
|
59
|
+
if (!firstEntry) return;
|
|
60
|
+
const [, currentPath] = firstEntry;
|
|
61
|
+
const secondEntry = Editor.above(editorWithPlugins, {
|
|
62
|
+
at: Editor.after(editorWithPlugins, selection.anchor),
|
|
63
|
+
match: (n)=>Editor.isBlock(editorWithPlugins, n),
|
|
64
|
+
mode: 'lowest'
|
|
65
|
+
});
|
|
66
|
+
if (!secondEntry) return;
|
|
67
|
+
const [node, path] = secondEntry;
|
|
68
|
+
if (node && Editor.isStart(editorWithPlugins, selection.anchor, currentPath)) {
|
|
69
|
+
const matchedBlock = plugins.reduce((block, plugin)=>{
|
|
70
|
+
const match = plugin.blocks?.find((b)=>b.type === node.type);
|
|
71
|
+
return block || match || null;
|
|
72
|
+
}, null);
|
|
73
|
+
if (matchedBlock) {
|
|
74
|
+
const result = matchedBlock.onBeforeDelete ? await matchedBlock?.onBeforeDelete?.([
|
|
75
|
+
node
|
|
76
|
+
]) : true;
|
|
77
|
+
if (result) {
|
|
78
|
+
Transforms.removeNodes(editorWithPlugins, {
|
|
79
|
+
at: path
|
|
80
|
+
});
|
|
81
|
+
matchedBlock.onDelete?.([
|
|
82
|
+
node
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
deleteForward(unit);
|
|
90
|
+
};
|
|
91
|
+
editorWithPlugins.deleteBackward = async (unit)=>{
|
|
92
|
+
const { selection } = editorWithPlugins;
|
|
93
|
+
if (!selection) return;
|
|
94
|
+
if (Range.isCollapsed(selection)) {
|
|
95
|
+
const firstEntry = Editor.above(editorWithPlugins, {
|
|
96
|
+
at: selection.anchor,
|
|
97
|
+
match: (n)=>Editor.isBlock(editorWithPlugins, n),
|
|
98
|
+
mode: 'lowest'
|
|
99
|
+
});
|
|
100
|
+
const secondEntry = Editor.above(editorWithPlugins, {
|
|
101
|
+
at: Editor.before(editorWithPlugins, selection.anchor),
|
|
102
|
+
match: (n)=>Editor.isBlock(editorWithPlugins, n),
|
|
103
|
+
mode: 'lowest'
|
|
104
|
+
});
|
|
105
|
+
if (!firstEntry || !secondEntry) return;
|
|
106
|
+
const [_, currentPath] = firstEntry;
|
|
107
|
+
const [node, path] = secondEntry;
|
|
108
|
+
if (node && Editor.isStart(editorWithPlugins, selection.anchor, currentPath)) {
|
|
109
|
+
const matchedBlock = plugins.reduce((block, plugin)=>{
|
|
110
|
+
const match = plugin.blocks?.find((b)=>b.type === node.type);
|
|
111
|
+
return block || match || null;
|
|
112
|
+
}, null);
|
|
113
|
+
if (matchedBlock) {
|
|
114
|
+
const result = matchedBlock.onBeforeDelete ? await matchedBlock.onBeforeDelete([
|
|
115
|
+
node
|
|
116
|
+
]) : true;
|
|
117
|
+
if (result) {
|
|
118
|
+
Transforms.removeNodes(editorWithPlugins, {
|
|
119
|
+
at: path
|
|
120
|
+
});
|
|
121
|
+
matchedBlock.onDelete?.([
|
|
122
|
+
node
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
deleteBackward(unit);
|
|
130
|
+
};
|
|
131
|
+
editorWithPlugins.deleteFragment = async (options)=>{
|
|
132
|
+
const { selection } = editorWithPlugins;
|
|
133
|
+
if (!selection) return;
|
|
134
|
+
const [start, end] = Range.edges(selection);
|
|
135
|
+
const isSingleText = Path.equals(start.path, end.path);
|
|
136
|
+
if (isSingleText) return void deleteFragment(options);
|
|
137
|
+
const nodes = Array.from(Editor.nodes(editorWithPlugins, {
|
|
138
|
+
at: selection,
|
|
139
|
+
match: (n)=>!Editor.isEditor(n) && Editor.isBlock(editorWithPlugins, n)
|
|
140
|
+
})).reverse();
|
|
141
|
+
for (const entry of nodes){
|
|
142
|
+
const [node, path] = entry;
|
|
143
|
+
const plugin = plugins.find((plugin)=>plugin.blocks?.find((b)=>b.type === node.type));
|
|
144
|
+
if (plugin) {
|
|
145
|
+
const match = plugin.blocks?.find((b)=>b.type === node.type);
|
|
146
|
+
const result = match?.onBeforeDelete ? await match.onBeforeDelete([
|
|
147
|
+
node
|
|
148
|
+
]) : true;
|
|
149
|
+
if (!result) return;
|
|
150
|
+
Transforms.removeNodes(editorWithPlugins, {
|
|
151
|
+
at: path,
|
|
152
|
+
match: (n)=>n.type === node.type
|
|
153
|
+
});
|
|
154
|
+
match?.onDelete?.([
|
|
155
|
+
node
|
|
156
|
+
]);
|
|
157
|
+
} else Transforms.removeNodes(editorWithPlugins, {
|
|
158
|
+
at: path,
|
|
159
|
+
match: (n)=>n.type === node.type
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (nodes.length > 0) return;
|
|
163
|
+
deleteFragment(options);
|
|
164
|
+
};
|
|
165
|
+
return editorWithPlugins;
|
|
166
|
+
};
|
|
167
|
+
export { createEditor_createEditor as createEditor };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Element } from "slate";
|
|
2
|
+
import { jsx } from "slate-hyperscript";
|
|
3
|
+
const deserialize = (plugins)=>(element)=>{
|
|
4
|
+
if (3 === element.nodeType) return element.textContent;
|
|
5
|
+
if (1 !== element.nodeType) return null;
|
|
6
|
+
if ('BR' === element.nodeName) return '\n';
|
|
7
|
+
let children = Array.from(element.childNodes).flatMap((node)=>deserialize(plugins)(node));
|
|
8
|
+
if (0 === children.length) children = [
|
|
9
|
+
{
|
|
10
|
+
text: ''
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
if ('BODY' === element.nodeName) if (children.some((c)=>Element.isElement(c))) return jsx('fragment', {}, children);
|
|
14
|
+
else return jsx('element', {
|
|
15
|
+
type: 'paragraph'
|
|
16
|
+
}, children);
|
|
17
|
+
if ('P' === element.nodeName) return jsx('element', {
|
|
18
|
+
type: 'paragraph'
|
|
19
|
+
}, children);
|
|
20
|
+
let result = null;
|
|
21
|
+
for (const plugin of plugins){
|
|
22
|
+
if (plugin.blocks?.some((b)=>b.deserialize)) plugin.blocks.forEach((e)=>{
|
|
23
|
+
if (e.deserialize) {
|
|
24
|
+
const childrenAsDescendants = children;
|
|
25
|
+
const newResult = e.deserialize(element, childrenAsDescendants);
|
|
26
|
+
if (newResult) result = newResult;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (result) return result;
|
|
30
|
+
}
|
|
31
|
+
return children.filter((child)=>null !== child);
|
|
32
|
+
};
|
|
33
|
+
export { deserialize };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import escape_html from "escape-html";
|
|
2
|
+
import { Text } from "slate";
|
|
3
|
+
const serialize = (plugins)=>(node)=>{
|
|
4
|
+
const serializers = plugins.flatMap((plugin)=>plugin.blocks?.map((element)=>element.serialize)).filter(Boolean);
|
|
5
|
+
if (Array.isArray(node)) return node.map(serialize(plugins)).join('');
|
|
6
|
+
if (Text.isText(node)) return serializers.reduce((prev, current)=>current?.(node) || prev, escape_html(node.text));
|
|
7
|
+
{
|
|
8
|
+
const children = node.children?.map((n)=>serialize(plugins)(n)).join('');
|
|
9
|
+
if ('paragraph' === node.type) return `<p>${children}</p>`;
|
|
10
|
+
return serializers.reduce((prev, current)=>current?.(node, children) || prev, '') || children;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export { serialize };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.root-e1gdll {
|
|
2
|
+
height: 100%;
|
|
3
|
+
color: var(--kona-editor-text-color, #444);
|
|
4
|
+
background-color: var(--kona-editor-background-color, #fff);
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
display: flex;
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.editor-K2itFp {
|
|
11
|
+
outline: none;
|
|
12
|
+
overflow: auto;
|
|
13
|
+
|
|
14
|
+
&::-webkit-scrollbar {
|
|
15
|
+
background: #00000006;
|
|
16
|
+
border-radius: 8px;
|
|
17
|
+
width: 4px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&::-webkit-scrollbar-thumb {
|
|
21
|
+
background: #00000013;
|
|
22
|
+
border-radius: 8px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
& > [role="textbox"] {
|
|
26
|
+
outline: none;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Descendant } from 'slate';
|
|
2
|
+
import type { EditorRef, IPlugin } from './types';
|
|
3
|
+
type KonaEditorProps = {
|
|
4
|
+
readOnly?: boolean;
|
|
5
|
+
plugins?: IPlugin[];
|
|
6
|
+
initialValue: Descendant[];
|
|
7
|
+
onChange: (value: Descendant[]) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const KonaEditor: import("react").ForwardRefExoticComponent<KonaEditorProps & import("react").RefAttributes<EditorRef>>;
|
|
10
|
+
export {};
|
package/dist/editor.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useImperativeHandle, useState } from "react";
|
|
3
|
+
import { Transforms } from "slate";
|
|
4
|
+
import { ReactEditor, Slate } from "slate-react";
|
|
5
|
+
import { createEditable } from "./core/createEditable.js";
|
|
6
|
+
import { createEditor } from "./core/createEditor.js";
|
|
7
|
+
import { deserialize } from "./core/deserialize.js";
|
|
8
|
+
import { serialize } from "./core/serialize.js";
|
|
9
|
+
import { isEmpty } from "./utils.js";
|
|
10
|
+
const KonaEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
11
|
+
const { initialValue, plugins = [], readOnly = false, onChange } = props;
|
|
12
|
+
const [editor] = useState(createEditor(plugins));
|
|
13
|
+
const SlateEditable = useCallback(createEditable(editor, plugins), []);
|
|
14
|
+
useImperativeHandle(ref, ()=>{
|
|
15
|
+
const deleteNode = (match)=>{
|
|
16
|
+
Transforms.removeNodes(editor, {
|
|
17
|
+
at: [],
|
|
18
|
+
match
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
serialize: serialize(plugins),
|
|
23
|
+
deserialize: deserialize(plugins),
|
|
24
|
+
deleteNode,
|
|
25
|
+
isEmpty: ()=>isEmpty(editor.children),
|
|
26
|
+
focus: ()=>{
|
|
27
|
+
ReactEditor.focus(editor);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}, [
|
|
31
|
+
editor,
|
|
32
|
+
plugins
|
|
33
|
+
]);
|
|
34
|
+
return /*#__PURE__*/ jsx(Slate, {
|
|
35
|
+
editor: editor,
|
|
36
|
+
initialValue: initialValue,
|
|
37
|
+
onValueChange: onChange,
|
|
38
|
+
children: /*#__PURE__*/ jsx(SlateEditable, {
|
|
39
|
+
readOnly: readOnly
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
export { KonaEditor };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useStore } from "@nanostores/react";
|
|
3
|
+
import Backdrop_module from "./Backdrop.module.js";
|
|
4
|
+
import { $store } from "./store.js";
|
|
5
|
+
const Backdrop = (props)=>{
|
|
6
|
+
const { isFloatingMenuOpen } = useStore($store);
|
|
7
|
+
const { onClose } = props;
|
|
8
|
+
return isFloatingMenuOpen ? /*#__PURE__*/ jsx("div", {
|
|
9
|
+
className: Backdrop_module.root,
|
|
10
|
+
onClick: onClose
|
|
11
|
+
}) : null;
|
|
12
|
+
};
|
|
13
|
+
export { Backdrop };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConnectDragPreview, ConnectDragSource, ConnectDropTarget } from 'react-dnd';
|
|
2
|
+
import type { RenderElementProps } from 'slate-react';
|
|
3
|
+
type Props = {
|
|
4
|
+
props: RenderElementProps;
|
|
5
|
+
dragRef: ConnectDragSource;
|
|
6
|
+
dropRef: ConnectDropTarget;
|
|
7
|
+
previewRef: ConnectDragPreview;
|
|
8
|
+
position: 'top' | 'bottom' | null;
|
|
9
|
+
};
|
|
10
|
+
export declare const DragBlock: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import DragBlock_module from "./DragBlock.module.js";
|
|
4
|
+
import { DragHandler } from "./DragHandler.js";
|
|
5
|
+
const DragBlock = (props)=>{
|
|
6
|
+
const { props: { attributes, element, children }, dragRef: drag, dropRef: drop, previewRef: preview, position } = props;
|
|
7
|
+
return /*#__PURE__*/ jsx("div", {
|
|
8
|
+
className: clsx(DragBlock_module.root, {
|
|
9
|
+
[DragBlock_module.top]: 'top' === position,
|
|
10
|
+
[DragBlock_module.bottom]: 'bottom' === position
|
|
11
|
+
}),
|
|
12
|
+
...attributes,
|
|
13
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
14
|
+
className: DragBlock_module.block,
|
|
15
|
+
ref: (e)=>{
|
|
16
|
+
drop(preview(e));
|
|
17
|
+
},
|
|
18
|
+
children: [
|
|
19
|
+
/*#__PURE__*/ jsx("div", {
|
|
20
|
+
className: DragBlock_module.drag,
|
|
21
|
+
ref: (element)=>{
|
|
22
|
+
drag(element);
|
|
23
|
+
},
|
|
24
|
+
contentEditable: false,
|
|
25
|
+
children: /*#__PURE__*/ jsx(DragHandler, {
|
|
26
|
+
attributes: attributes,
|
|
27
|
+
element: element,
|
|
28
|
+
children: children
|
|
29
|
+
})
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ jsx("div", {
|
|
32
|
+
children: children
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export { DragBlock };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.root-QYAUnT {
|
|
2
|
+
border-top: 2px solid #0000;
|
|
3
|
+
border-bottom: 2px solid #0000;
|
|
4
|
+
position: relative;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.top-qIwygJ {
|
|
8
|
+
border-top: 2px solid #3498db;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.bottom-K22AI8 {
|
|
12
|
+
border-bottom: 2px solid #3498db;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.drag-v0MSZ1 {
|
|
16
|
+
vertical-align: baseline;
|
|
17
|
+
cursor: move;
|
|
18
|
+
opacity: 0;
|
|
19
|
+
width: 16px;
|
|
20
|
+
line-height: 1.2;
|
|
21
|
+
transition: opacity .25s;
|
|
22
|
+
display: inline-block;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.block-y_k_tl {
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
grid-template-columns: 16px 1fr;
|
|
28
|
+
align-items: start;
|
|
29
|
+
column-gap: 8px;
|
|
30
|
+
padding: 4px 8px;
|
|
31
|
+
transition: background-color .25s;
|
|
32
|
+
display: grid;
|
|
33
|
+
position: relative;
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
background-color: #00000004;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:hover .drag-v0MSZ1 {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|