@byline/richtext-lexical 0.9.3
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/LICENSE +373 -0
- package/README.md +18 -0
- package/dist/field/apply-value-plugin.d.ts +10 -0
- package/dist/field/apply-value-plugin.d.ts.map +1 -0
- package/dist/field/apply-value-plugin.js +60 -0
- package/dist/field/config/default.d.ts +6 -0
- package/dist/field/config/default.d.ts.map +1 -0
- package/dist/field/config/default.js +53 -0
- package/dist/field/config/editor-config-context.d.ts +14 -0
- package/dist/field/config/editor-config-context.d.ts.map +1 -0
- package/dist/field/config/editor-config-context.js +51 -0
- package/dist/field/config/types.d.ts +28 -0
- package/dist/field/config/types.d.ts.map +1 -0
- package/dist/field/config/types.js +1 -0
- package/dist/field/constants.d.ts +2 -0
- package/dist/field/constants.d.ts.map +1 -0
- package/dist/field/constants.js +2 -0
- package/dist/field/content-editable-inline.d.ts +13 -0
- package/dist/field/content-editable-inline.d.ts.map +1 -0
- package/dist/field/content-editable-inline.js +11 -0
- package/dist/field/content-editable.css +23 -0
- package/dist/field/content-editable.d.ts +13 -0
- package/dist/field/content-editable.d.ts.map +1 -0
- package/dist/field/content-editable.js +14 -0
- package/dist/field/context/shared-autocomplete-context.js +44 -0
- package/dist/field/context/shared-history-context.d.ts +19 -0
- package/dist/field/context/shared-history-context.d.ts.map +1 -0
- package/dist/field/context/shared-history-context.js +16 -0
- package/dist/field/context/shared-on-change-context.d.ts +13 -0
- package/dist/field/context/shared-on-change-context.d.ts.map +1 -0
- package/dist/field/context/shared-on-change-context.js +21 -0
- package/dist/field/debug.d.ts +10 -0
- package/dist/field/debug.d.ts.map +1 -0
- package/dist/field/debug.js +30 -0
- package/dist/field/editor-component.css +33 -0
- package/dist/field/editor-component.d.ts +13 -0
- package/dist/field/editor-component.d.ts.map +1 -0
- package/dist/field/editor-component.js +115 -0
- package/dist/field/editor-context.d.ts +23 -0
- package/dist/field/editor-context.d.ts.map +1 -0
- package/dist/field/editor-context.js +57 -0
- package/dist/field/editor-field.d.ts +34 -0
- package/dist/field/editor-field.d.ts.map +1 -0
- package/dist/field/editor-field.js +18 -0
- package/dist/field/editor.css +1449 -0
- package/dist/field/editor.d.ts +14 -0
- package/dist/field/editor.d.ts.map +1 -0
- package/dist/field/editor.js +190 -0
- package/dist/field/hooks/use-modal.d.ts +13 -0
- package/dist/field/hooks/use-modal.d.ts.map +1 -0
- package/dist/field/hooks/use-modal.js +37 -0
- package/dist/field/hooks/use-report.js +39 -0
- package/dist/field/lexical-populate-shared.d.ts +97 -0
- package/dist/field/lexical-populate-shared.d.ts.map +1 -0
- package/dist/field/lexical-populate-shared.js +60 -0
- package/dist/field/nodes/admonition-node/admonition-node-component.css +119 -0
- package/dist/field/nodes/admonition-node/admonition-node-component.d.ts +18 -0
- package/dist/field/nodes/admonition-node/admonition-node-component.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/admonition-node-component.js +190 -0
- package/dist/field/nodes/admonition-node/admonition-node.d.ts +35 -0
- package/dist/field/nodes/admonition-node/admonition-node.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/admonition-node.js +129 -0
- package/dist/field/nodes/admonition-node/icons/danger-icon.css +12 -0
- package/dist/field/nodes/admonition-node/icons/danger-icon.d.ts +8 -0
- package/dist/field/nodes/admonition-node/icons/danger-icon.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/icons/danger-icon.js +18 -0
- package/dist/field/nodes/admonition-node/icons/index.d.ts +5 -0
- package/dist/field/nodes/admonition-node/icons/index.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/icons/index.js +4 -0
- package/dist/field/nodes/admonition-node/icons/note-icon.css +12 -0
- package/dist/field/nodes/admonition-node/icons/note-icon.d.ts +8 -0
- package/dist/field/nodes/admonition-node/icons/note-icon.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/icons/note-icon.js +18 -0
- package/dist/field/nodes/admonition-node/icons/tip-icon.css +12 -0
- package/dist/field/nodes/admonition-node/icons/tip-icon.d.ts +8 -0
- package/dist/field/nodes/admonition-node/icons/tip-icon.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/icons/tip-icon.js +18 -0
- package/dist/field/nodes/admonition-node/icons/warning-icon.css +12 -0
- package/dist/field/nodes/admonition-node/icons/warning-icon.d.ts +8 -0
- package/dist/field/nodes/admonition-node/icons/warning-icon.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/icons/warning-icon.js +18 -0
- package/dist/field/nodes/admonition-node/index.d.ts +10 -0
- package/dist/field/nodes/admonition-node/index.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/index.js +2 -0
- package/dist/field/nodes/admonition-node/types.d.ts +21 -0
- package/dist/field/nodes/admonition-node/types.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/types.js +1 -0
- package/dist/field/nodes/document-relation.d.ts +33 -0
- package/dist/field/nodes/document-relation.d.ts.map +1 -0
- package/dist/field/nodes/document-relation.js +1 -0
- package/dist/field/nodes/index.d.ts +10 -0
- package/dist/field/nodes/index.d.ts.map +1 -0
- package/dist/field/nodes/index.js +37 -0
- package/dist/field/nodes/inline-image-node/index.d.ts +10 -0
- package/dist/field/nodes/inline-image-node/index.d.ts.map +1 -0
- package/dist/field/nodes/inline-image-node/index.js +2 -0
- package/dist/field/nodes/inline-image-node/inline-image-node-component.css +204 -0
- package/dist/field/nodes/inline-image-node/inline-image-node-component.d.ts +24 -0
- package/dist/field/nodes/inline-image-node/inline-image-node-component.d.ts.map +1 -0
- package/dist/field/nodes/inline-image-node/inline-image-node-component.js +221 -0
- package/dist/field/nodes/inline-image-node/inline-image-node.d.ts +45 -0
- package/dist/field/nodes/inline-image-node/inline-image-node.d.ts.map +1 -0
- package/dist/field/nodes/inline-image-node/inline-image-node.js +187 -0
- package/dist/field/nodes/inline-image-node/types.d.ts +30 -0
- package/dist/field/nodes/inline-image-node/types.d.ts.map +1 -0
- package/dist/field/nodes/inline-image-node/types.js +1 -0
- package/dist/field/nodes/layout-container-node/layout-container-node.d.ts +29 -0
- package/dist/field/nodes/layout-container-node/layout-container-node.d.ts.map +1 -0
- package/dist/field/nodes/layout-container-node/layout-container-node.js +54 -0
- package/dist/field/nodes/layout-container-node/layout-item-node.d.ts +23 -0
- package/dist/field/nodes/layout-container-node/layout-item-node.d.ts.map +1 -0
- package/dist/field/nodes/layout-container-node/layout-item-node.js +41 -0
- package/dist/field/nodes/link-nodes/auto-link-node.d.ts +17 -0
- package/dist/field/nodes/link-nodes/auto-link-node.d.ts.map +1 -0
- package/dist/field/nodes/link-nodes/auto-link-node.js +52 -0
- package/dist/field/nodes/link-nodes/index.d.ts +4 -0
- package/dist/field/nodes/link-nodes/index.d.ts.map +1 -0
- package/dist/field/nodes/link-nodes/index.js +3 -0
- package/dist/field/nodes/link-nodes/link-node.d.ts +49 -0
- package/dist/field/nodes/link-nodes/link-node.d.ts.map +1 -0
- package/dist/field/nodes/link-nodes/link-node.js +253 -0
- package/dist/field/nodes/link-nodes/types.d.ts +26 -0
- package/dist/field/nodes/link-nodes/types.d.ts.map +1 -0
- package/dist/field/nodes/link-nodes/types.js +1 -0
- package/dist/field/nodes/vimeo-node/index.d.ts +30 -0
- package/dist/field/nodes/vimeo-node/index.d.ts.map +1 -0
- package/dist/field/nodes/vimeo-node/index.js +109 -0
- package/dist/field/nodes/youtube-node/index.d.ts +30 -0
- package/dist/field/nodes/youtube-node/index.d.ts.map +1 -0
- package/dist/field/nodes/youtube-node/index.js +110 -0
- package/dist/field/plugins/admonition-plugin/admonition-modal.css +26 -0
- package/dist/field/plugins/admonition-plugin/admonition-modal.d.ts +12 -0
- package/dist/field/plugins/admonition-plugin/admonition-modal.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/admonition-modal.js +165 -0
- package/dist/field/plugins/admonition-plugin/fields.d.ts +21 -0
- package/dist/field/plugins/admonition-plugin/fields.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/fields.js +55 -0
- package/dist/field/plugins/admonition-plugin/index.d.ts +15 -0
- package/dist/field/plugins/admonition-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/index.js +54 -0
- package/dist/field/plugins/admonition-plugin/types.d.ts +34 -0
- package/dist/field/plugins/admonition-plugin/types.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/types.js +1 -0
- package/dist/field/plugins/auto-embed-plugin/auto-embed-modal.css +16 -0
- package/dist/field/plugins/auto-embed-plugin/auto-embed-modal.d.ts +8 -0
- package/dist/field/plugins/auto-embed-plugin/auto-embed-modal.d.ts.map +1 -0
- package/dist/field/plugins/auto-embed-plugin/auto-embed-modal.js +105 -0
- package/dist/field/plugins/auto-embed-plugin/index.d.ts +21 -0
- package/dist/field/plugins/auto-embed-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/auto-embed-plugin/index.js +152 -0
- package/dist/field/plugins/code-highlight-plugin/index.d.ts +10 -0
- package/dist/field/plugins/code-highlight-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/code-highlight-plugin/index.js +11 -0
- package/dist/field/plugins/drag-drop-paste-plugin/index.js +1 -0
- package/dist/field/plugins/floating-text-format-toolbar-plugin/index.css +148 -0
- package/dist/field/plugins/floating-text-format-toolbar-plugin/index.d.ts +13 -0
- package/dist/field/plugins/floating-text-format-toolbar-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/floating-text-format-toolbar-plugin/index.js +279 -0
- package/dist/field/plugins/inline-image-plugin/fields.d.ts +12 -0
- package/dist/field/plugins/inline-image-plugin/fields.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/fields.js +22 -0
- package/dist/field/plugins/inline-image-plugin/index.d.ts +34 -0
- package/dist/field/plugins/inline-image-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/index.js +107 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-modal.css +25 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-modal.d.ts +11 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-modal.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-modal.js +271 -0
- package/dist/field/plugins/inline-image-plugin/populate.d.ts +10 -0
- package/dist/field/plugins/inline-image-plugin/populate.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/populate.js +28 -0
- package/dist/field/plugins/inline-image-plugin/types.d.ts +37 -0
- package/dist/field/plugins/inline-image-plugin/types.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/types.js +1 -0
- package/dist/field/plugins/inline-image-plugin/utils.d.ts +42 -0
- package/dist/field/plugins/inline-image-plugin/utils.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/utils.js +46 -0
- package/dist/field/plugins/layout-plugin/insert-layout-modal.css +20 -0
- package/dist/field/plugins/layout-plugin/insert-layout-modal.d.ts +22 -0
- package/dist/field/plugins/layout-plugin/insert-layout-modal.d.ts.map +1 -0
- package/dist/field/plugins/layout-plugin/insert-layout-modal.js +97 -0
- package/dist/field/plugins/layout-plugin/layout-plugin.d.ts +10 -0
- package/dist/field/plugins/layout-plugin/layout-plugin.d.ts.map +1 -0
- package/dist/field/plugins/layout-plugin/layout-plugin.js +81 -0
- package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.d.ts +22 -0
- package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.js +185 -0
- package/dist/field/plugins/link-plugin/auto-link/index.d.ts +10 -0
- package/dist/field/plugins/link-plugin/auto-link/index.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/auto-link/index.js +15 -0
- package/dist/field/plugins/link-plugin/link/floating-link-editor.css +124 -0
- package/dist/field/plugins/link-plugin/link/floating-link-editor.d.ts +15 -0
- package/dist/field/plugins/link-plugin/link/floating-link-editor.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/link/floating-link-editor.js +234 -0
- package/dist/field/plugins/link-plugin/link/index.d.ts +2 -0
- package/dist/field/plugins/link-plugin/link/index.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/link/index.js +43 -0
- package/dist/field/plugins/link-plugin/link/link-modal.d.ts +11 -0
- package/dist/field/plugins/link-plugin/link/link-modal.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/link/link-modal.js +311 -0
- package/dist/field/plugins/link-plugin/link/types.d.ts +19 -0
- package/dist/field/plugins/link-plugin/link/types.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/link/types.js +1 -0
- package/dist/field/plugins/link-plugin/populate.d.ts +22 -0
- package/dist/field/plugins/link-plugin/populate.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/populate.js +28 -0
- package/dist/field/plugins/table-action-menu-plugin/index.d.ts +6 -0
- package/dist/field/plugins/table-action-menu-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/table-action-menu-plugin/index.js +598 -0
- package/dist/field/plugins/table-plugin/index.d.ts +4 -0
- package/dist/field/plugins/table-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/table-plugin/index.js +26 -0
- package/dist/field/plugins/table-plugin/table-modal.css +20 -0
- package/dist/field/plugins/table-plugin/table-modal.d.ts +21 -0
- package/dist/field/plugins/table-plugin/table-modal.d.ts.map +1 -0
- package/dist/field/plugins/table-plugin/table-modal.js +111 -0
- package/dist/field/plugins/toolbar-plugin/index.d.ts +17 -0
- package/dist/field/plugins/toolbar-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/toolbar-plugin/index.js +837 -0
- package/dist/field/plugins/treeview-plugin/index.d.ts +10 -0
- package/dist/field/plugins/treeview-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/treeview-plugin/index.js +17 -0
- package/dist/field/plugins/vimeo-plugin/index.d.ts +4 -0
- package/dist/field/plugins/vimeo-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/vimeo-plugin/index.js +24 -0
- package/dist/field/plugins/youtube-plugin/index.d.ts +4 -0
- package/dist/field/plugins/youtube-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/youtube-plugin/index.js +24 -0
- package/dist/field/shared/canUseDOM.d.ts +9 -0
- package/dist/field/shared/canUseDOM.d.ts.map +1 -0
- package/dist/field/shared/canUseDOM.js +2 -0
- package/dist/field/shared/environment.d.ts +23 -0
- package/dist/field/shared/environment.d.ts.map +1 -0
- package/dist/field/shared/environment.js +10 -0
- package/dist/field/shared/invariant.d.ts +9 -0
- package/dist/field/shared/invariant.d.ts.map +1 -0
- package/dist/field/shared/invariant.js +6 -0
- package/dist/field/shared/simpleDiffWithCursor.js +15 -0
- package/dist/field/shared/useLayoutEffect.js +5 -0
- package/dist/field/shared/useModalFormState.d.ts +23 -0
- package/dist/field/shared/useModalFormState.d.ts.map +1 -0
- package/dist/field/shared/useModalFormState.js +23 -0
- package/dist/field/shared/warnOnlyOnce.js +9 -0
- package/dist/field/themes/lexical-editor-theme.css +537 -0
- package/dist/field/themes/lexical-editor-theme.d.ts +10 -0
- package/dist/field/themes/lexical-editor-theme.d.ts.map +1 -0
- package/dist/field/themes/lexical-editor-theme.js +105 -0
- package/dist/field/toolbar-extensions.d.ts +32 -0
- package/dist/field/toolbar-extensions.d.ts.map +1 -0
- package/dist/field/toolbar-extensions.js +56 -0
- package/dist/field/types.js +1 -0
- package/dist/field/ui/button.css +31 -0
- package/dist/field/ui/button.js +19 -0
- package/dist/field/ui/checkbox.css +46 -0
- package/dist/field/ui/color-picker.css +75 -0
- package/dist/field/ui/color-picker.d.ts +21 -0
- package/dist/field/ui/color-picker.d.ts.map +1 -0
- package/dist/field/ui/color-picker.js +360 -0
- package/dist/field/ui/dialog.css +18 -0
- package/dist/field/ui/dialog.js +17 -0
- package/dist/field/ui/dropdown.d.ts +25 -0
- package/dist/field/ui/dropdown.d.ts.map +1 -0
- package/dist/field/ui/dropdown.js +150 -0
- package/dist/field/ui/file-input.js +27 -0
- package/dist/field/ui/input.css +23 -0
- package/dist/field/ui/modal.css +73 -0
- package/dist/field/ui/modal.d.ts +17 -0
- package/dist/field/ui/modal.d.ts.map +1 -0
- package/dist/field/ui/modal.js +69 -0
- package/dist/field/ui/placeholder-inline.d.ts +14 -0
- package/dist/field/ui/placeholder-inline.d.ts.map +1 -0
- package/dist/field/ui/placeholder-inline.js +12 -0
- package/dist/field/ui/placeholder.css +26 -0
- package/dist/field/ui/placeholder.d.ts +14 -0
- package/dist/field/ui/placeholder.d.ts.map +1 -0
- package/dist/field/ui/placeholder.js +14 -0
- package/dist/field/ui/select.css +32 -0
- package/dist/field/ui/select.js +28 -0
- package/dist/field/ui/switch.js +25 -0
- package/dist/field/ui/text-area.css +31 -0
- package/dist/field/ui/text-area.js +28 -0
- package/dist/field/ui/text-input.d.ts +20 -0
- package/dist/field/ui/text-input.d.ts.map +1 -0
- package/dist/field/ui/text-input.js +29 -0
- package/dist/field/utils/cloneDeep.js +26 -0
- package/dist/field/utils/deepEqual.js +19 -0
- package/dist/field/utils/emoji-list.js +21389 -0
- package/dist/field/utils/getDOMRangeRect.d.ts +9 -0
- package/dist/field/utils/getDOMRangeRect.d.ts.map +1 -0
- package/dist/field/utils/getDOMRangeRect.js +11 -0
- package/dist/field/utils/getSelectedNode.d.ts +3 -0
- package/dist/field/utils/getSelectedNode.d.ts.map +1 -0
- package/dist/field/utils/getSelectedNode.js +12 -0
- package/dist/field/utils/guard.js +4 -0
- package/dist/field/utils/hashSerializedState.d.ts +3 -0
- package/dist/field/utils/hashSerializedState.d.ts.map +1 -0
- package/dist/field/utils/hashSerializedState.js +22 -0
- package/dist/field/utils/isMobileWidth.js +1 -0
- package/dist/field/utils/joinClasses.js +4 -0
- package/dist/field/utils/point.js +34 -0
- package/dist/field/utils/rect.js +95 -0
- package/dist/field/utils/setFloatingElemPosition.d.ts +2 -0
- package/dist/field/utils/setFloatingElemPosition.d.ts.map +1 -0
- package/dist/field/utils/setFloatingElemPosition.js +22 -0
- package/dist/field/utils/setFloatingElemPositionForLinkEditor.d.ts +2 -0
- package/dist/field/utils/setFloatingElemPositionForLinkEditor.d.ts.map +1 -0
- package/dist/field/utils/setFloatingElemPositionForLinkEditor.js +22 -0
- package/dist/field/utils/swipe.js +77 -0
- package/dist/field/utils/url.d.ts +11 -0
- package/dist/field/utils/url.d.ts.map +1 -0
- package/dist/field/utils/url.js +30 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/lexical-editor.d.ts +41 -0
- package/dist/lexical-editor.d.ts.map +1 -0
- package/dist/lexical-editor.js +13 -0
- package/dist/richtext-field.d.ts +25 -0
- package/dist/richtext-field.d.ts.map +1 -0
- package/dist/richtext-field.js +62 -0
- package/dist/richtext-field.module.js +8 -0
- package/dist/richtext-field_module.css +18 -0
- package/dist/server.d.ts +64 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +20 -0
- package/dist/static/svg/3-columns.svg +3 -0
- package/dist/static/svg/admonition.svg +1 -0
- package/dist/static/svg/ai.svg +5 -0
- package/dist/static/svg/arrow-clockwise.svg +1 -0
- package/dist/static/svg/arrow-counterclockwise.svg +1 -0
- package/dist/static/svg/bg-color.svg +1 -0
- package/dist/static/svg/camera.svg +1 -0
- package/dist/static/svg/caret-right-fill.svg +1 -0
- package/dist/static/svg/chat-square-quote.svg +1 -0
- package/dist/static/svg/chevron-down.svg +1 -0
- package/dist/static/svg/clipboard.svg +1 -0
- package/dist/static/svg/close.svg +1 -0
- package/dist/static/svg/code.svg +1 -0
- package/dist/static/svg/copy.svg +1 -0
- package/dist/static/svg/diagram-2.svg +1 -0
- package/dist/static/svg/download.svg +1 -0
- package/dist/static/svg/dropdown-more.svg +1 -0
- package/dist/static/svg/file-image.svg +1 -0
- package/dist/static/svg/filetype-gif.svg +1 -0
- package/dist/static/svg/font-color.svg +1 -0
- package/dist/static/svg/font-family.svg +1 -0
- package/dist/static/svg/gear.svg +1 -0
- package/dist/static/svg/horizontal-rule.svg +1 -0
- package/dist/static/svg/indent.svg +1 -0
- package/dist/static/svg/journal-code.svg +1 -0
- package/dist/static/svg/justify.svg +1 -0
- package/dist/static/svg/link.svg +1 -0
- package/dist/static/svg/list-ol.svg +1 -0
- package/dist/static/svg/list-ul.svg +1 -0
- package/dist/static/svg/lock-fill.svg +1 -0
- package/dist/static/svg/lock.svg +1 -0
- package/dist/static/svg/markdown.svg +1 -0
- package/dist/static/svg/mic.svg +1 -0
- package/dist/static/svg/outdent.svg +1 -0
- package/dist/static/svg/paint-bucket.svg +1 -0
- package/dist/static/svg/palette.svg +1 -0
- package/dist/static/svg/pencil-fill.svg +1 -0
- package/dist/static/svg/plug-fill.svg +1 -0
- package/dist/static/svg/plug.svg +1 -0
- package/dist/static/svg/plus.svg +1 -0
- package/dist/static/svg/prettier-error.svg +1 -0
- package/dist/static/svg/prettier.svg +1 -0
- package/dist/static/svg/square-check.svg +1 -0
- package/dist/static/svg/success.svg +1 -0
- package/dist/static/svg/table.svg +1 -0
- package/dist/static/svg/text-center.svg +1 -0
- package/dist/static/svg/text-left.svg +1 -0
- package/dist/static/svg/text-paragraph.svg +1 -0
- package/dist/static/svg/text-right.svg +1 -0
- package/dist/static/svg/trash.svg +1 -0
- package/dist/static/svg/type-bold.svg +1 -0
- package/dist/static/svg/type-h1.svg +1 -0
- package/dist/static/svg/type-h2.svg +1 -0
- package/dist/static/svg/type-h3.svg +1 -0
- package/dist/static/svg/type-h4.svg +1 -0
- package/dist/static/svg/type-h5.svg +1 -0
- package/dist/static/svg/type-h6.svg +1 -0
- package/dist/static/svg/type-italic.svg +1 -0
- package/dist/static/svg/type-strikethrough.svg +1 -0
- package/dist/static/svg/type-subscript.svg +1 -0
- package/dist/static/svg/type-superscript.svg +1 -0
- package/dist/static/svg/type-underline.svg +1 -0
- package/dist/static/svg/upload.svg +1 -0
- package/dist/static/svg/user.svg +1 -0
- package/dist/static/svg/vimeo.svg +1 -0
- package/dist/static/svg/youtube.svg +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/validate/createEmptyEditorState.d.ts +25 -0
- package/dist/validate/createEmptyEditorState.d.ts.map +1 -0
- package/dist/validate/createEmptyEditorState.js +26 -0
- package/dist/validate/hasText.d.ts +3 -0
- package/dist/validate/hasText.d.ts.map +1 -0
- package/dist/validate/hasText.js +20 -0
- package/dist/validate/validate.d.ts +5 -0
- package/dist/validate/validate.d.ts.map +1 -0
- package/dist/validate/validate.js +7 -0
- package/package.json +120 -0
- package/src/declarations.d.ts +4 -0
- package/src/field/apply-value-plugin.tsx +104 -0
- package/src/field/config/default.ts +58 -0
- package/src/field/config/editor-config-context.tsx +60 -0
- package/src/field/config/types.ts +67 -0
- package/src/field/constants.ts +1 -0
- package/src/field/content-editable-inline.tsx +27 -0
- package/src/field/content-editable.css +29 -0
- package/src/field/content-editable.tsx +27 -0
- package/src/field/context/shared-autocomplete-context.tsx +61 -0
- package/src/field/context/shared-history-context.tsx +30 -0
- package/src/field/context/shared-on-change-context.tsx +32 -0
- package/src/field/debug.tsx +39 -0
- package/src/field/editor-component.css +46 -0
- package/src/field/editor-component.md +87 -0
- package/src/field/editor-component.test.tsx +170 -0
- package/src/field/editor-component.tsx +207 -0
- package/src/field/editor-context.tsx +102 -0
- package/src/field/editor-field.tsx +51 -0
- package/src/field/editor.css +1481 -0
- package/src/field/editor.tsx +245 -0
- package/src/field/hooks/use-media-queryts +21 -0
- package/src/field/hooks/use-modal.tsx +59 -0
- package/src/field/hooks/use-report.ts +62 -0
- package/src/field/images/LICENSE.md +5 -0
- package/src/field/images/assets.d.ts +27 -0
- package/src/field/images/cat-typing.gif +0 -0
- package/src/field/images/emoji/1F600.png +0 -0
- package/src/field/images/emoji/1F641.png +0 -0
- package/src/field/images/emoji/1F642.png +0 -0
- package/src/field/images/emoji/2764.png +0 -0
- package/src/field/images/emoji/LICENSE.md +5 -0
- package/src/field/images/icons/3-columns.svg +3 -0
- package/src/field/images/icons/LICENSE.md +5 -0
- package/src/field/images/icons/admonition.svg +1 -0
- package/src/field/images/icons/ai.svg +5 -0
- package/src/field/images/icons/arrow-clockwise.svg +1 -0
- package/src/field/images/icons/arrow-counterclockwise.svg +1 -0
- package/src/field/images/icons/bg-color.svg +1 -0
- package/src/field/images/icons/camera.svg +1 -0
- package/src/field/images/icons/card-checklist.svg +1 -0
- package/src/field/images/icons/caret-right-fill.svg +1 -0
- package/src/field/images/icons/chat-left-text.svg +1 -0
- package/src/field/images/icons/chat-right-dots.svg +1 -0
- package/src/field/images/icons/chat-right-text.svg +1 -0
- package/src/field/images/icons/chat-right.svg +1 -0
- package/src/field/images/icons/chat-square-quote.svg +1 -0
- package/src/field/images/icons/chevron-down.svg +1 -0
- package/src/field/images/icons/clipboard.svg +1 -0
- package/src/field/images/icons/close.svg +1 -0
- package/src/field/images/icons/code.svg +1 -0
- package/src/field/images/icons/comments.svg +1 -0
- package/src/field/images/icons/copy.svg +1 -0
- package/src/field/images/icons/diagram-2.svg +1 -0
- package/src/field/images/icons/download.svg +1 -0
- package/src/field/images/icons/draggable-block-menu.svg +1 -0
- package/src/field/images/icons/dropdown-more.svg +1 -0
- package/src/field/images/icons/figma.svg +1 -0
- package/src/field/images/icons/file-earmark-text.svg +4 -0
- package/src/field/images/icons/file-image.svg +1 -0
- package/src/field/images/icons/filetype-gif.svg +1 -0
- package/src/field/images/icons/font-color.svg +1 -0
- package/src/field/images/icons/font-family.svg +1 -0
- package/src/field/images/icons/gear.svg +1 -0
- package/src/field/images/icons/horizontal-rule.svg +1 -0
- package/src/field/images/icons/indent.svg +1 -0
- package/src/field/images/icons/journal-code.svg +1 -0
- package/src/field/images/icons/journal-text.svg +1 -0
- package/src/field/images/icons/justify.svg +1 -0
- package/src/field/images/icons/link.svg +1 -0
- package/src/field/images/icons/list-ol.svg +1 -0
- package/src/field/images/icons/list-ul.svg +1 -0
- package/src/field/images/icons/lock-fill.svg +1 -0
- package/src/field/images/icons/lock.svg +1 -0
- package/src/field/images/icons/markdown.svg +1 -0
- package/src/field/images/icons/mic.svg +1 -0
- package/src/field/images/icons/outdent.svg +1 -0
- package/src/field/images/icons/paint-bucket.svg +1 -0
- package/src/field/images/icons/palette.svg +1 -0
- package/src/field/images/icons/pencil-fill.svg +1 -0
- package/src/field/images/icons/plug-fill.svg +1 -0
- package/src/field/images/icons/plug.svg +1 -0
- package/src/field/images/icons/plus-slash-minus.svg +1 -0
- package/src/field/images/icons/plus.svg +1 -0
- package/src/field/images/icons/prettier-error.svg +1 -0
- package/src/field/images/icons/prettier.svg +1 -0
- package/src/field/images/icons/send.svg +1 -0
- package/src/field/images/icons/square-check.svg +1 -0
- package/src/field/images/icons/sticky.svg +1 -0
- package/src/field/images/icons/success-alt.svg +1 -0
- package/src/field/images/icons/success.svg +1 -0
- package/src/field/images/icons/table.svg +1 -0
- package/src/field/images/icons/text-center.svg +1 -0
- package/src/field/images/icons/text-left.svg +1 -0
- package/src/field/images/icons/text-paragraph.svg +1 -0
- package/src/field/images/icons/text-right.svg +1 -0
- package/src/field/images/icons/trash.svg +1 -0
- package/src/field/images/icons/trash3.svg +1 -0
- package/src/field/images/icons/tweet.svg +1 -0
- package/src/field/images/icons/type-bold.svg +1 -0
- package/src/field/images/icons/type-h1.svg +1 -0
- package/src/field/images/icons/type-h2.svg +1 -0
- package/src/field/images/icons/type-h3.svg +1 -0
- package/src/field/images/icons/type-h4.svg +1 -0
- package/src/field/images/icons/type-h5.svg +1 -0
- package/src/field/images/icons/type-h6.svg +1 -0
- package/src/field/images/icons/type-italic.svg +1 -0
- package/src/field/images/icons/type-strikethrough.svg +1 -0
- package/src/field/images/icons/type-subscript.svg +1 -0
- package/src/field/images/icons/type-superscript.svg +1 -0
- package/src/field/images/icons/type-underline.svg +1 -0
- package/src/field/images/icons/upload.svg +1 -0
- package/src/field/images/icons/user.svg +1 -0
- package/src/field/images/icons/vimeo.svg +1 -0
- package/src/field/images/icons/youtube.svg +1 -0
- package/src/field/images/landscape.jpg +0 -0
- package/src/field/images/logo.svg +1 -0
- package/src/field/images/yellow-flower-small.jpg +0 -0
- package/src/field/images/yellow-flower.jpg +0 -0
- package/src/field/lexical-populate-shared.ts +188 -0
- package/src/field/nodes/admonition-node/admonition-node-component.css +115 -0
- package/src/field/nodes/admonition-node/admonition-node-component.tsx +256 -0
- package/src/field/nodes/admonition-node/admonition-node.tsx +189 -0
- package/src/field/nodes/admonition-node/icons/danger-icon.css +11 -0
- package/src/field/nodes/admonition-node/icons/danger-icon.js +17 -0
- package/src/field/nodes/admonition-node/icons/danger-icon.tsx +19 -0
- package/src/field/nodes/admonition-node/icons/index.js +4 -0
- package/src/field/nodes/admonition-node/icons/index.ts +4 -0
- package/src/field/nodes/admonition-node/icons/note-icon.css +11 -0
- package/src/field/nodes/admonition-node/icons/note-icon.js +17 -0
- package/src/field/nodes/admonition-node/icons/note-icon.tsx +19 -0
- package/src/field/nodes/admonition-node/icons/tip-icon.css +11 -0
- package/src/field/nodes/admonition-node/icons/tip-icon.js +17 -0
- package/src/field/nodes/admonition-node/icons/tip-icon.tsx +19 -0
- package/src/field/nodes/admonition-node/icons/warning-icon.css +11 -0
- package/src/field/nodes/admonition-node/icons/warning-icon.js +17 -0
- package/src/field/nodes/admonition-node/icons/warning-icon.tsx +19 -0
- package/src/field/nodes/admonition-node/index.ts +14 -0
- package/src/field/nodes/admonition-node/types.ts +33 -0
- package/src/field/nodes/document-relation.ts +33 -0
- package/src/field/nodes/index.ts +47 -0
- package/src/field/nodes/inline-image-node/index.ts +10 -0
- package/src/field/nodes/inline-image-node/inline-image-node-component.css +205 -0
- package/src/field/nodes/inline-image-node/inline-image-node-component.tsx +342 -0
- package/src/field/nodes/inline-image-node/inline-image-node.tsx +328 -0
- package/src/field/nodes/inline-image-node/types.ts +43 -0
- package/src/field/nodes/layout-container-node/layout-container-node.ts +97 -0
- package/src/field/nodes/layout-container-node/layout-item-node.ts +63 -0
- package/src/field/nodes/link-nodes/auto-link-node.ts +64 -0
- package/src/field/nodes/link-nodes/index.ts +3 -0
- package/src/field/nodes/link-nodes/link-node.ts +426 -0
- package/src/field/nodes/link-nodes/types.ts +33 -0
- package/src/field/nodes/vimeo-node/index.tsx +172 -0
- package/src/field/nodes/youtube-node/index.tsx +178 -0
- package/src/field/plugins/admonition-plugin/admonition-modal.css +25 -0
- package/src/field/plugins/admonition-plugin/admonition-modal.tsx +187 -0
- package/src/field/plugins/admonition-plugin/fields.ts +103 -0
- package/src/field/plugins/admonition-plugin/index.tsx +105 -0
- package/src/field/plugins/admonition-plugin/types.ts +37 -0
- package/src/field/plugins/auto-embed-plugin/auto-embed-modal.css +15 -0
- package/src/field/plugins/auto-embed-plugin/auto-embed-modal.tsx +110 -0
- package/src/field/plugins/auto-embed-plugin/index.tsx +323 -0
- package/src/field/plugins/code-highlight-plugin/index.ts +23 -0
- package/src/field/plugins/drag-drop-paste-plugin/index.ts +47 -0
- package/src/field/plugins/floating-text-format-toolbar-plugin/index.css +148 -0
- package/src/field/plugins/floating-text-format-toolbar-plugin/index.tsx +398 -0
- package/src/field/plugins/inline-image-plugin/fields.ts +21 -0
- package/src/field/plugins/inline-image-plugin/index.tsx +202 -0
- package/src/field/plugins/inline-image-plugin/inline-image-modal.css +29 -0
- package/src/field/plugins/inline-image-plugin/inline-image-modal.tsx +314 -0
- package/src/field/plugins/inline-image-plugin/populate.ts +48 -0
- package/src/field/plugins/inline-image-plugin/types.ts +39 -0
- package/src/field/plugins/inline-image-plugin/utils.ts +113 -0
- package/src/field/plugins/layout-plugin/insert-layout-modal.css +19 -0
- package/src/field/plugins/layout-plugin/insert-layout-modal.tsx +100 -0
- package/src/field/plugins/layout-plugin/layout-plugin.tsx +162 -0
- package/src/field/plugins/link-plugin/auto-link/auto-link-plugin.tsx +327 -0
- package/src/field/plugins/link-plugin/auto-link/index.tsx +35 -0
- package/src/field/plugins/link-plugin/link/floating-link-editor.css +128 -0
- package/src/field/plugins/link-plugin/link/floating-link-editor.tsx +348 -0
- package/src/field/plugins/link-plugin/link/index.tsx +99 -0
- package/src/field/plugins/link-plugin/link/link-modal.tsx +376 -0
- package/src/field/plugins/link-plugin/link/types.ts +20 -0
- package/src/field/plugins/link-plugin/populate.ts +48 -0
- package/src/field/plugins/table-action-menu-plugin/index.tsx +804 -0
- package/src/field/plugins/table-plugin/index.tsx +33 -0
- package/src/field/plugins/table-plugin/table-modal.css +19 -0
- package/src/field/plugins/table-plugin/table-modal.tsx +127 -0
- package/src/field/plugins/toolbar-plugin/index.tsx +937 -0
- package/src/field/plugins/treeview-plugin/index.tsx +29 -0
- package/src/field/plugins/vimeo-plugin/index.ts +42 -0
- package/src/field/plugins/youtube-plugin/index.ts +43 -0
- package/src/field/shared/canUseDOM.ts +10 -0
- package/src/field/shared/caretFromPoint.bak +40 -0
- package/src/field/shared/environment.ts +44 -0
- package/src/field/shared/invariant.ts +25 -0
- package/src/field/shared/simpleDiffWithCursor.ts +40 -0
- package/src/field/shared/useLayoutEffect.ts +15 -0
- package/src/field/shared/useModalFormState.ts +48 -0
- package/src/field/shared/warnOnlyOnce.ts +21 -0
- package/src/field/themes/lexical-editor-theme.css +565 -0
- package/src/field/themes/lexical-editor-theme.js +104 -0
- package/src/field/themes/lexical-editor-theme.tsx +115 -0
- package/src/field/toolbar-extensions.tsx +93 -0
- package/src/field/types.ts +19 -0
- package/src/field/ui/button.css +45 -0
- package/src/field/ui/button.tsx +51 -0
- package/src/field/ui/checkbox.css +52 -0
- package/src/field/ui/color-picker.css +88 -0
- package/src/field/ui/color-picker.tsx +395 -0
- package/src/field/ui/dialog.css +17 -0
- package/src/field/ui/dialog.tsx +29 -0
- package/src/field/ui/dropdown.tsx +217 -0
- package/src/field/ui/file-input.tsx +44 -0
- package/src/field/ui/input.css +32 -0
- package/src/field/ui/modal.css +84 -0
- package/src/field/ui/modal.tsx +106 -0
- package/src/field/ui/placeholder-inline.tsx +28 -0
- package/src/field/ui/placeholder.css +33 -0
- package/src/field/ui/placeholder.tsx +32 -0
- package/src/field/ui/select.css +34 -0
- package/src/field/ui/select.tsx +38 -0
- package/src/field/ui/switch.tsx +33 -0
- package/src/field/ui/text-area.css +45 -0
- package/src/field/ui/text-area.tsx +50 -0
- package/src/field/ui/text-input.tsx +51 -0
- package/src/field/utils/cloneDeep.ts +57 -0
- package/src/field/utils/deepEqual.ts +54 -0
- package/src/field/utils/emoji-list.ts +16615 -0
- package/src/field/utils/getDOMRangeRect.ts +24 -0
- package/src/field/utils/getSelectedNode.ts +25 -0
- package/src/field/utils/guard.ts +10 -0
- package/src/field/utils/hashSerializedState.ts +34 -0
- package/src/field/utils/isMobileWidth.ts +7 -0
- package/src/field/utils/joinClasses.ts +11 -0
- package/src/field/utils/point.ts +52 -0
- package/src/field/utils/rect.ts +142 -0
- package/src/field/utils/setFloatingElemPosition.ts +48 -0
- package/src/field/utils/setFloatingElemPositionForLinkEditor.ts +46 -0
- package/src/field/utils/swipe.ts +129 -0
- package/src/field/utils/url.ts +49 -0
- package/src/index.ts +26 -0
- package/src/lexical-editor.tsx +56 -0
- package/src/richtext-field.module.css +29 -0
- package/src/richtext-field.tsx +113 -0
- package/src/server.ts +85 -0
- package/src/types.ts +43 -0
- package/src/validate/createEmptyEditorState.ts +52 -0
- package/src/validate/hasText.test.ts +89 -0
- package/src/validate/hasText.ts +34 -0
- package/src/validate/validate.ts +18 -0
|
@@ -0,0 +1,837 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment as external_react_Fragment, useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { $createCodeNode, $isCodeNode, CODE_LANGUAGE_FRIENDLY_NAME_MAP, CODE_LANGUAGE_MAP, getLanguageFriendlyName } from "@lexical/code";
|
|
5
|
+
import { $isListNode, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode, REMOVE_LIST_COMMAND } from "@lexical/list";
|
|
6
|
+
import { INSERT_EMBED_COMMAND } from "@lexical/react/LexicalAutoEmbedPlugin";
|
|
7
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
8
|
+
import { $isDecoratorBlockNode } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
9
|
+
import { INSERT_HORIZONTAL_RULE_COMMAND } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
10
|
+
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode } from "@lexical/rich-text";
|
|
11
|
+
import { $setBlocksType } from "@lexical/selection";
|
|
12
|
+
import { $isTableNode } from "@lexical/table";
|
|
13
|
+
import { $findMatchingParent, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, mergeRegister } from "@lexical/utils";
|
|
14
|
+
import { $createParagraphNode, $getNodeByKey, $getSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_NORMAL, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, INDENT_CONTENT_COMMAND, KEY_MODIFIER_COMMAND, OUTDENT_CONTENT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from "lexical";
|
|
15
|
+
import { useEditorConfig } from "../../config/editor-config-context.js";
|
|
16
|
+
import { $isLinkNode, OPEN_LINK_MODAL_COMMAND, TOGGLE_LINK_COMMAND } from "../../nodes/link-nodes/index.js";
|
|
17
|
+
import { IS_APPLE } from "../../shared/environment.js";
|
|
18
|
+
import { useToolbarExtensions } from "../../toolbar-extensions.js";
|
|
19
|
+
import { DropDown, DropDownItem } from "../../ui/dropdown.js";
|
|
20
|
+
import { getSelectedNode } from "../../utils/getSelectedNode.js";
|
|
21
|
+
import { sanitizeUrl } from "../../utils/url.js";
|
|
22
|
+
import { OPEN_ADMONITION_MODAL_COMMAND } from "../admonition-plugin/index.js";
|
|
23
|
+
import { EmbedConfigs } from "../auto-embed-plugin/index.js";
|
|
24
|
+
import { OPEN_INLINE_IMAGE_MODAL_COMMAND } from "../inline-image-plugin/index.js";
|
|
25
|
+
import { OPEN_INSERT_LAYOUT_MODAL_COMMAND } from "../layout-plugin/layout-plugin.js";
|
|
26
|
+
import { OPEN_TABLE_MODAL_COMMAND } from "../table-plugin/index.js";
|
|
27
|
+
const blockTypeToBlockName = {
|
|
28
|
+
bullet: 'Bulleted List',
|
|
29
|
+
check: 'Check List',
|
|
30
|
+
code: 'Code Block',
|
|
31
|
+
h1: 'Heading 1',
|
|
32
|
+
h2: 'Heading 2',
|
|
33
|
+
h3: 'Heading 3',
|
|
34
|
+
h4: 'Heading 4',
|
|
35
|
+
h5: 'Heading 5',
|
|
36
|
+
h6: 'Heading 6',
|
|
37
|
+
number: 'Numbered List',
|
|
38
|
+
paragraph: 'Normal',
|
|
39
|
+
quote: 'Quote'
|
|
40
|
+
};
|
|
41
|
+
function getCodeLanguageOptions() {
|
|
42
|
+
const options = [];
|
|
43
|
+
for (const [lang, friendlyName] of Object.entries(CODE_LANGUAGE_FRIENDLY_NAME_MAP))options.push([
|
|
44
|
+
lang,
|
|
45
|
+
friendlyName
|
|
46
|
+
]);
|
|
47
|
+
return options;
|
|
48
|
+
}
|
|
49
|
+
const CODE_LANGUAGE_OPTIONS = getCodeLanguageOptions();
|
|
50
|
+
function dropDownActiveClass(active) {
|
|
51
|
+
if (active) return 'active dropdown-item-active';
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
function BlockFormatDropDown({ editor, blockType, rootType, disabled = false }) {
|
|
55
|
+
const { config: { options: { checkListPlugin, listPlugin, codeHighlightPlugin } } } = useEditorConfig();
|
|
56
|
+
const formatParagraph = ()=>{
|
|
57
|
+
editor.update(()=>{
|
|
58
|
+
const selection = $getSelection();
|
|
59
|
+
if ($isRangeSelection(selection)) $setBlocksType(selection, ()=>$createParagraphNode());
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const formatHeading = (headingSize)=>{
|
|
63
|
+
if (blockType !== headingSize) editor.update(()=>{
|
|
64
|
+
const selection = $getSelection();
|
|
65
|
+
if ($isRangeSelection(selection)) $setBlocksType(selection, ()=>$createHeadingNode(headingSize));
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const formatBulletList = ()=>{
|
|
69
|
+
if ('bullet' !== blockType) editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, void 0);
|
|
70
|
+
else editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
|
|
71
|
+
};
|
|
72
|
+
const formatCheckList = ()=>{
|
|
73
|
+
if ('check' !== blockType) editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, void 0);
|
|
74
|
+
else editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
|
|
75
|
+
};
|
|
76
|
+
const formatNumberedList = ()=>{
|
|
77
|
+
if ('number' !== blockType) editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, void 0);
|
|
78
|
+
else editor.dispatchCommand(REMOVE_LIST_COMMAND, void 0);
|
|
79
|
+
};
|
|
80
|
+
const formatQuote = ()=>{
|
|
81
|
+
if ('quote' !== blockType) editor.update(()=>{
|
|
82
|
+
const selection = $getSelection();
|
|
83
|
+
if ($isRangeSelection(selection)) $setBlocksType(selection, ()=>$createQuoteNode());
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const formatCode = ()=>{
|
|
87
|
+
if ('code' !== blockType) editor.update(()=>{
|
|
88
|
+
let selection = $getSelection();
|
|
89
|
+
if ($isRangeSelection(selection)) if (selection.isCollapsed()) $setBlocksType(selection, ()=>$createCodeNode());
|
|
90
|
+
else {
|
|
91
|
+
const textContent = selection.getTextContent();
|
|
92
|
+
const codeNode = $createCodeNode();
|
|
93
|
+
selection.insertNodes([
|
|
94
|
+
codeNode
|
|
95
|
+
]);
|
|
96
|
+
selection = $getSelection();
|
|
97
|
+
if ($isRangeSelection(selection)) selection.insertRawText(textContent);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
return /*#__PURE__*/ jsxs(DropDown, {
|
|
102
|
+
disabled: disabled,
|
|
103
|
+
buttonClassName: "toolbar-item block-controls",
|
|
104
|
+
buttonIconClassName: `icon block-type ${blockType}`,
|
|
105
|
+
buttonLabel: blockTypeToBlockName[blockType],
|
|
106
|
+
buttonAriaLabel: "Formatting options for text style",
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
109
|
+
className: `item ${dropDownActiveClass('paragraph' === blockType)}`,
|
|
110
|
+
onClick: formatParagraph,
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ jsx("i", {
|
|
113
|
+
className: "icon paragraph"
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsx("span", {
|
|
116
|
+
className: "text",
|
|
117
|
+
children: "Normal"
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
122
|
+
className: `item ${dropDownActiveClass('h1' === blockType)}`,
|
|
123
|
+
onClick: ()=>{
|
|
124
|
+
formatHeading('h1');
|
|
125
|
+
},
|
|
126
|
+
children: [
|
|
127
|
+
/*#__PURE__*/ jsx("i", {
|
|
128
|
+
className: "icon h1"
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ jsx("span", {
|
|
131
|
+
className: "text",
|
|
132
|
+
children: "Heading 1"
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
137
|
+
className: `item ${dropDownActiveClass('h2' === blockType)}`,
|
|
138
|
+
onClick: ()=>{
|
|
139
|
+
formatHeading('h2');
|
|
140
|
+
},
|
|
141
|
+
children: [
|
|
142
|
+
/*#__PURE__*/ jsx("i", {
|
|
143
|
+
className: "icon h2"
|
|
144
|
+
}),
|
|
145
|
+
/*#__PURE__*/ jsx("span", {
|
|
146
|
+
className: "text",
|
|
147
|
+
children: "Heading 2"
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
152
|
+
className: `item ${dropDownActiveClass('h3' === blockType)}`,
|
|
153
|
+
onClick: ()=>{
|
|
154
|
+
formatHeading('h3');
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
/*#__PURE__*/ jsx("i", {
|
|
158
|
+
className: "icon h3"
|
|
159
|
+
}),
|
|
160
|
+
/*#__PURE__*/ jsx("span", {
|
|
161
|
+
className: "text",
|
|
162
|
+
children: "Heading 3"
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
}),
|
|
166
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
167
|
+
className: `item ${dropDownActiveClass('h4' === blockType)}`,
|
|
168
|
+
onClick: ()=>{
|
|
169
|
+
formatHeading('h4');
|
|
170
|
+
},
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ jsx("i", {
|
|
173
|
+
className: "icon h4"
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ jsx("span", {
|
|
176
|
+
className: "text",
|
|
177
|
+
children: "Heading 4"
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
}),
|
|
181
|
+
listPlugin && /*#__PURE__*/ jsxs(Fragment, {
|
|
182
|
+
children: [
|
|
183
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
184
|
+
className: `item ${dropDownActiveClass('bullet' === blockType)}`,
|
|
185
|
+
onClick: formatBulletList,
|
|
186
|
+
children: [
|
|
187
|
+
/*#__PURE__*/ jsx("i", {
|
|
188
|
+
className: "icon bullet-list"
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ jsx("span", {
|
|
191
|
+
className: "text",
|
|
192
|
+
children: "Bullet List"
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
197
|
+
className: `item ${dropDownActiveClass('number' === blockType)}`,
|
|
198
|
+
onClick: formatNumberedList,
|
|
199
|
+
children: [
|
|
200
|
+
/*#__PURE__*/ jsx("i", {
|
|
201
|
+
className: "icon numbered-list"
|
|
202
|
+
}),
|
|
203
|
+
/*#__PURE__*/ jsx("span", {
|
|
204
|
+
className: "text",
|
|
205
|
+
children: "Numbered List"
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
}),
|
|
211
|
+
checkListPlugin && /*#__PURE__*/ jsxs(DropDownItem, {
|
|
212
|
+
className: `item ${dropDownActiveClass('check' === blockType)}`,
|
|
213
|
+
onClick: formatCheckList,
|
|
214
|
+
children: [
|
|
215
|
+
/*#__PURE__*/ jsx("i", {
|
|
216
|
+
className: "icon check-list"
|
|
217
|
+
}),
|
|
218
|
+
/*#__PURE__*/ jsx("span", {
|
|
219
|
+
className: "text",
|
|
220
|
+
children: "Check List"
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
}),
|
|
224
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
225
|
+
className: `item ${dropDownActiveClass('quote' === blockType)}`,
|
|
226
|
+
onClick: formatQuote,
|
|
227
|
+
children: [
|
|
228
|
+
/*#__PURE__*/ jsx("i", {
|
|
229
|
+
className: "icon quote"
|
|
230
|
+
}),
|
|
231
|
+
/*#__PURE__*/ jsx("span", {
|
|
232
|
+
className: "text",
|
|
233
|
+
children: "Quote"
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
}),
|
|
237
|
+
codeHighlightPlugin && /*#__PURE__*/ jsxs(DropDownItem, {
|
|
238
|
+
className: `item ${dropDownActiveClass('code' === blockType)}`,
|
|
239
|
+
onClick: formatCode,
|
|
240
|
+
children: [
|
|
241
|
+
/*#__PURE__*/ jsx("i", {
|
|
242
|
+
className: "icon code"
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ jsx("span", {
|
|
245
|
+
className: "text",
|
|
246
|
+
children: "Code Block"
|
|
247
|
+
})
|
|
248
|
+
]
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function Divider() {
|
|
254
|
+
return /*#__PURE__*/ jsx("div", {
|
|
255
|
+
className: "divider"
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function ToolbarPlugin() {
|
|
259
|
+
const [editor] = useLexicalComposerContext();
|
|
260
|
+
const [activeEditor, setActiveEditor] = useState(editor);
|
|
261
|
+
const [blockType, setBlockType] = useState('paragraph');
|
|
262
|
+
const [rootType, setRootType] = useState('root');
|
|
263
|
+
const [selectedElementKey, setSelectedElementKey] = useState(null);
|
|
264
|
+
const [_toggleAiDrawerCommand, _setToggleAiDrawerCommand] = useState(null);
|
|
265
|
+
const [isLink, setIsLink] = useState(false);
|
|
266
|
+
const [isBold, setIsBold] = useState(false);
|
|
267
|
+
const [isItalic, setIsItalic] = useState(false);
|
|
268
|
+
const [isUnderline, setIsUnderline] = useState(false);
|
|
269
|
+
const [isStrikethrough, setIsStrikethrough] = useState(false);
|
|
270
|
+
const [isSubscript, setIsSubscript] = useState(false);
|
|
271
|
+
const [isSuperscript, setIsSuperscript] = useState(false);
|
|
272
|
+
const [isCode, setIsCode] = useState(false);
|
|
273
|
+
const [canUndo, setCanUndo] = useState(false);
|
|
274
|
+
const [canRedo, setCanRedo] = useState(false);
|
|
275
|
+
const [isRTL, _setIsRTL] = useState(false);
|
|
276
|
+
const [codeLanguage, setCodeLanguage] = useState('');
|
|
277
|
+
const [isEditable, setIsEditable] = useState(()=>editor.isEditable());
|
|
278
|
+
const { items: toolbarExtensionItems } = useToolbarExtensions();
|
|
279
|
+
const { uuid, config: { options: { textAlignment, tablePlugin, inlineImagePlugin, admonitionPlugin, horizontalRulePlugin, layoutPlugin, autoEmbedPlugin, undoRedo, textStyle, inlineCode, links } } } = useEditorConfig();
|
|
280
|
+
const $updateToolbar = useCallback(()=>{
|
|
281
|
+
const selection = $getSelection();
|
|
282
|
+
if ($isRangeSelection(selection)) {
|
|
283
|
+
const anchorNode = selection.anchor.getNode();
|
|
284
|
+
let element = 'root' === anchorNode.getKey() ? anchorNode : $findMatchingParent(anchorNode, (e)=>{
|
|
285
|
+
const parent = e.getParent();
|
|
286
|
+
return null !== parent && $isRootOrShadowRoot(parent);
|
|
287
|
+
});
|
|
288
|
+
if (null === element) element = anchorNode.getTopLevelElementOrThrow();
|
|
289
|
+
const elementKey = element.getKey();
|
|
290
|
+
const elementDOM = activeEditor.getElementByKey(elementKey);
|
|
291
|
+
setIsBold(selection.hasFormat('bold'));
|
|
292
|
+
setIsItalic(selection.hasFormat('italic'));
|
|
293
|
+
setIsUnderline(selection.hasFormat('underline'));
|
|
294
|
+
setIsStrikethrough(selection.hasFormat('strikethrough'));
|
|
295
|
+
setIsSubscript(selection.hasFormat("subscript"));
|
|
296
|
+
setIsSuperscript(selection.hasFormat("superscript"));
|
|
297
|
+
setIsCode(selection.hasFormat('code'));
|
|
298
|
+
const node = getSelectedNode(selection);
|
|
299
|
+
const parent = node.getParent();
|
|
300
|
+
$isLinkNode(parent) || $isLinkNode(node) ? setIsLink(true) : setIsLink(false);
|
|
301
|
+
const tableNode = $findMatchingParent(node, $isTableNode);
|
|
302
|
+
$isTableNode(tableNode) ? setRootType('table') : setRootType('root');
|
|
303
|
+
if (null !== elementDOM) {
|
|
304
|
+
setSelectedElementKey(elementKey);
|
|
305
|
+
if ($isListNode(element)) {
|
|
306
|
+
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
307
|
+
const type = null != parentList ? parentList.getListType() : element.getListType();
|
|
308
|
+
setBlockType(type);
|
|
309
|
+
} else {
|
|
310
|
+
const type = $isHeadingNode(element) ? element.getTag() : element.getType();
|
|
311
|
+
if (type in blockTypeToBlockName) setBlockType(type);
|
|
312
|
+
if ($isCodeNode(element)) {
|
|
313
|
+
const language = element.getLanguage();
|
|
314
|
+
setCodeLanguage(null != language ? CODE_LANGUAGE_MAP[language] ?? language : '');
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}, [
|
|
320
|
+
activeEditor
|
|
321
|
+
]);
|
|
322
|
+
useEffect(()=>editor.registerCommand(SELECTION_CHANGE_COMMAND, (_payload, newEditor)=>{
|
|
323
|
+
$updateToolbar();
|
|
324
|
+
setActiveEditor(newEditor);
|
|
325
|
+
return false;
|
|
326
|
+
}, COMMAND_PRIORITY_CRITICAL), [
|
|
327
|
+
editor,
|
|
328
|
+
$updateToolbar
|
|
329
|
+
]);
|
|
330
|
+
useEffect(()=>mergeRegister(editor.registerEditableListener((editable)=>{
|
|
331
|
+
setIsEditable(editable);
|
|
332
|
+
}), activeEditor.registerUpdateListener(({ editorState })=>{
|
|
333
|
+
editorState.read(()=>{
|
|
334
|
+
$updateToolbar();
|
|
335
|
+
});
|
|
336
|
+
}), activeEditor.registerCommand(CAN_UNDO_COMMAND, (payload)=>{
|
|
337
|
+
setCanUndo(payload);
|
|
338
|
+
return false;
|
|
339
|
+
}, COMMAND_PRIORITY_CRITICAL), activeEditor.registerCommand(CAN_REDO_COMMAND, (payload)=>{
|
|
340
|
+
setCanRedo(payload);
|
|
341
|
+
return false;
|
|
342
|
+
}, COMMAND_PRIORITY_CRITICAL)), [
|
|
343
|
+
$updateToolbar,
|
|
344
|
+
activeEditor,
|
|
345
|
+
editor
|
|
346
|
+
]);
|
|
347
|
+
useEffect(()=>activeEditor.registerCommand(KEY_MODIFIER_COMMAND, (payload)=>{
|
|
348
|
+
const event = payload;
|
|
349
|
+
const { code, ctrlKey, metaKey } = event;
|
|
350
|
+
if ('KeyK' === code && (ctrlKey || metaKey)) {
|
|
351
|
+
event.preventDefault();
|
|
352
|
+
return activeEditor.dispatchCommand(TOGGLE_LINK_COMMAND, sanitizeUrl('https://'));
|
|
353
|
+
}
|
|
354
|
+
return false;
|
|
355
|
+
}, COMMAND_PRIORITY_NORMAL), [
|
|
356
|
+
activeEditor
|
|
357
|
+
]);
|
|
358
|
+
const clearFormatting = useCallback(()=>{
|
|
359
|
+
activeEditor.update(()=>{
|
|
360
|
+
const selection = $getSelection();
|
|
361
|
+
if ($isRangeSelection(selection)) {
|
|
362
|
+
const anchor = selection.anchor;
|
|
363
|
+
const focus = selection.focus;
|
|
364
|
+
const nodes = selection.getNodes();
|
|
365
|
+
if (anchor.key === focus.key && anchor.offset === focus.offset) return;
|
|
366
|
+
nodes.forEach((node, idx)=>{
|
|
367
|
+
if ($isTextNode(node)) {
|
|
368
|
+
let textNode = node;
|
|
369
|
+
if (0 === idx && 0 !== anchor.offset) textNode = textNode.splitText(anchor.offset)[1] ?? textNode;
|
|
370
|
+
if (idx === nodes.length - 1) textNode = textNode.splitText(focus.offset)[0] ?? textNode;
|
|
371
|
+
if ('' !== textNode.__style) textNode.setStyle('');
|
|
372
|
+
if (0 !== textNode.__format) {
|
|
373
|
+
textNode.setFormat(0);
|
|
374
|
+
$getNearestBlockElementAncestorOrThrow(textNode).setFormat('');
|
|
375
|
+
}
|
|
376
|
+
} else if ($isHeadingNode(node) || $isQuoteNode(node)) node.replace($createParagraphNode(), true);
|
|
377
|
+
else if ($isDecoratorBlockNode(node)) node.setFormat('');
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}, [
|
|
382
|
+
activeEditor
|
|
383
|
+
]);
|
|
384
|
+
const insertLink = useCallback(()=>{
|
|
385
|
+
if (isLink) editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
386
|
+
else {
|
|
387
|
+
const editorState = activeEditor.getEditorState();
|
|
388
|
+
editorState.read(()=>{
|
|
389
|
+
const selection = $getSelection();
|
|
390
|
+
if ($isRangeSelection(selection)) {
|
|
391
|
+
if (selection.focus.offset !== selection.anchor.offset) {
|
|
392
|
+
const linkAttributes = {
|
|
393
|
+
linkType: 'custom',
|
|
394
|
+
url: 'https://'
|
|
395
|
+
};
|
|
396
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, linkAttributes);
|
|
397
|
+
editor.dispatchCommand(OPEN_LINK_MODAL_COMMAND, void 0);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}, [
|
|
403
|
+
editor,
|
|
404
|
+
isLink,
|
|
405
|
+
activeEditor
|
|
406
|
+
]);
|
|
407
|
+
const onCodeLanguageSelect = useCallback((value)=>{
|
|
408
|
+
activeEditor.update(()=>{
|
|
409
|
+
if (null !== selectedElementKey) {
|
|
410
|
+
const node = $getNodeByKey(selectedElementKey);
|
|
411
|
+
if ($isCodeNode(node)) node.setLanguage(value);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}, [
|
|
415
|
+
activeEditor,
|
|
416
|
+
selectedElementKey
|
|
417
|
+
]);
|
|
418
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
419
|
+
className: "toolbar",
|
|
420
|
+
children: [
|
|
421
|
+
undoRedo && /*#__PURE__*/ jsxs(Fragment, {
|
|
422
|
+
children: [
|
|
423
|
+
/*#__PURE__*/ jsx("button", {
|
|
424
|
+
disabled: !canUndo || !isEditable,
|
|
425
|
+
onClick: ()=>{
|
|
426
|
+
activeEditor.dispatchCommand(UNDO_COMMAND, void 0);
|
|
427
|
+
},
|
|
428
|
+
title: IS_APPLE ? 'Undo (⌘Z)' : 'Undo (Ctrl+Z)',
|
|
429
|
+
type: "button",
|
|
430
|
+
className: "toolbar-item spaced",
|
|
431
|
+
"aria-label": "Undo",
|
|
432
|
+
children: /*#__PURE__*/ jsx("i", {
|
|
433
|
+
className: "format undo"
|
|
434
|
+
})
|
|
435
|
+
}),
|
|
436
|
+
/*#__PURE__*/ jsx("button", {
|
|
437
|
+
disabled: !canRedo || !isEditable,
|
|
438
|
+
onClick: ()=>{
|
|
439
|
+
activeEditor.dispatchCommand(REDO_COMMAND, void 0);
|
|
440
|
+
},
|
|
441
|
+
title: IS_APPLE ? 'Redo (⌘Y)' : 'Redo (Ctrl+Y)',
|
|
442
|
+
type: "button",
|
|
443
|
+
className: "toolbar-item",
|
|
444
|
+
"aria-label": "Redo",
|
|
445
|
+
children: /*#__PURE__*/ jsx("i", {
|
|
446
|
+
className: "format redo"
|
|
447
|
+
})
|
|
448
|
+
}),
|
|
449
|
+
/*#__PURE__*/ jsx(Divider, {})
|
|
450
|
+
]
|
|
451
|
+
}),
|
|
452
|
+
blockType in blockTypeToBlockName && activeEditor === editor && /*#__PURE__*/ jsxs(Fragment, {
|
|
453
|
+
children: [
|
|
454
|
+
textStyle && /*#__PURE__*/ jsxs(Fragment, {
|
|
455
|
+
children: [
|
|
456
|
+
/*#__PURE__*/ jsx(BlockFormatDropDown, {
|
|
457
|
+
disabled: !isEditable,
|
|
458
|
+
blockType: blockType,
|
|
459
|
+
rootType: rootType,
|
|
460
|
+
editor: editor
|
|
461
|
+
}),
|
|
462
|
+
/*#__PURE__*/ jsx(Divider, {})
|
|
463
|
+
]
|
|
464
|
+
}),
|
|
465
|
+
textAlignment && /*#__PURE__*/ jsxs(Fragment, {
|
|
466
|
+
children: [
|
|
467
|
+
/*#__PURE__*/ jsxs(DropDown, {
|
|
468
|
+
disabled: !isEditable,
|
|
469
|
+
buttonLabel: "Align",
|
|
470
|
+
buttonIconClassName: "icon left-align",
|
|
471
|
+
buttonClassName: "toolbar-item spaced alignment",
|
|
472
|
+
buttonAriaLabel: "Formatting options for text alignment",
|
|
473
|
+
children: [
|
|
474
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
475
|
+
onClick: ()=>{
|
|
476
|
+
activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left');
|
|
477
|
+
},
|
|
478
|
+
className: "item",
|
|
479
|
+
children: [
|
|
480
|
+
/*#__PURE__*/ jsx("i", {
|
|
481
|
+
className: "icon left-align"
|
|
482
|
+
}),
|
|
483
|
+
/*#__PURE__*/ jsx("span", {
|
|
484
|
+
className: "text",
|
|
485
|
+
children: "Left Align"
|
|
486
|
+
})
|
|
487
|
+
]
|
|
488
|
+
}),
|
|
489
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
490
|
+
onClick: ()=>{
|
|
491
|
+
activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center');
|
|
492
|
+
},
|
|
493
|
+
className: "item",
|
|
494
|
+
children: [
|
|
495
|
+
/*#__PURE__*/ jsx("i", {
|
|
496
|
+
className: "icon center-align"
|
|
497
|
+
}),
|
|
498
|
+
/*#__PURE__*/ jsx("span", {
|
|
499
|
+
className: "text",
|
|
500
|
+
children: "Center Align"
|
|
501
|
+
})
|
|
502
|
+
]
|
|
503
|
+
}),
|
|
504
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
505
|
+
onClick: ()=>{
|
|
506
|
+
activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right');
|
|
507
|
+
},
|
|
508
|
+
className: "item",
|
|
509
|
+
children: [
|
|
510
|
+
/*#__PURE__*/ jsx("i", {
|
|
511
|
+
className: "icon right-align"
|
|
512
|
+
}),
|
|
513
|
+
/*#__PURE__*/ jsx("span", {
|
|
514
|
+
className: "text",
|
|
515
|
+
children: "Right Align"
|
|
516
|
+
})
|
|
517
|
+
]
|
|
518
|
+
}),
|
|
519
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
520
|
+
onClick: ()=>{
|
|
521
|
+
activeEditor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify');
|
|
522
|
+
},
|
|
523
|
+
className: "item",
|
|
524
|
+
children: [
|
|
525
|
+
/*#__PURE__*/ jsx("i", {
|
|
526
|
+
className: "icon justify-align"
|
|
527
|
+
}),
|
|
528
|
+
/*#__PURE__*/ jsx("span", {
|
|
529
|
+
className: "text",
|
|
530
|
+
children: "Justify Align"
|
|
531
|
+
})
|
|
532
|
+
]
|
|
533
|
+
}),
|
|
534
|
+
/*#__PURE__*/ jsx(Divider, {}),
|
|
535
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
536
|
+
onClick: ()=>{
|
|
537
|
+
activeEditor.dispatchCommand(OUTDENT_CONTENT_COMMAND, void 0);
|
|
538
|
+
},
|
|
539
|
+
className: "item",
|
|
540
|
+
children: [
|
|
541
|
+
/*#__PURE__*/ jsx("i", {
|
|
542
|
+
className: `icon ${isRTL ? 'indent' : 'outdent'}`
|
|
543
|
+
}),
|
|
544
|
+
/*#__PURE__*/ jsx("span", {
|
|
545
|
+
className: "text",
|
|
546
|
+
children: "Outdent"
|
|
547
|
+
})
|
|
548
|
+
]
|
|
549
|
+
}),
|
|
550
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
551
|
+
onClick: ()=>{
|
|
552
|
+
activeEditor.dispatchCommand(INDENT_CONTENT_COMMAND, void 0);
|
|
553
|
+
},
|
|
554
|
+
className: "item",
|
|
555
|
+
children: [
|
|
556
|
+
/*#__PURE__*/ jsx("i", {
|
|
557
|
+
className: `icon ${isRTL ? 'outdent' : 'indent'}`
|
|
558
|
+
}),
|
|
559
|
+
/*#__PURE__*/ jsx("span", {
|
|
560
|
+
className: "text",
|
|
561
|
+
children: "Indent"
|
|
562
|
+
})
|
|
563
|
+
]
|
|
564
|
+
})
|
|
565
|
+
]
|
|
566
|
+
}),
|
|
567
|
+
/*#__PURE__*/ jsx(Divider, {})
|
|
568
|
+
]
|
|
569
|
+
})
|
|
570
|
+
]
|
|
571
|
+
}),
|
|
572
|
+
'code' === blockType ? /*#__PURE__*/ jsx(DropDown, {
|
|
573
|
+
disabled: !isEditable,
|
|
574
|
+
buttonClassName: "toolbar-item code-language",
|
|
575
|
+
buttonLabel: getLanguageFriendlyName(codeLanguage),
|
|
576
|
+
buttonAriaLabel: "Select language",
|
|
577
|
+
children: CODE_LANGUAGE_OPTIONS.map(([value, name])=>/*#__PURE__*/ jsx(DropDownItem, {
|
|
578
|
+
className: `item ${dropDownActiveClass(value === codeLanguage)}`,
|
|
579
|
+
onClick: ()=>{
|
|
580
|
+
onCodeLanguageSelect(value);
|
|
581
|
+
},
|
|
582
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
583
|
+
className: "text",
|
|
584
|
+
children: name
|
|
585
|
+
})
|
|
586
|
+
}, value))
|
|
587
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
588
|
+
children: [
|
|
589
|
+
/*#__PURE__*/ jsx("button", {
|
|
590
|
+
disabled: !isEditable,
|
|
591
|
+
onClick: ()=>{
|
|
592
|
+
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');
|
|
593
|
+
},
|
|
594
|
+
className: `toolbar-item spaced ${isBold ? 'active' : ''}`,
|
|
595
|
+
title: IS_APPLE ? 'Bold (⌘B)' : 'Bold (Ctrl+B)',
|
|
596
|
+
type: "button",
|
|
597
|
+
"aria-label": `Format text as bold. Shortcut: ${IS_APPLE ? '⌘B' : 'Ctrl+B'}`,
|
|
598
|
+
children: /*#__PURE__*/ jsx("i", {
|
|
599
|
+
className: "format bold"
|
|
600
|
+
})
|
|
601
|
+
}),
|
|
602
|
+
/*#__PURE__*/ jsx("button", {
|
|
603
|
+
disabled: !isEditable,
|
|
604
|
+
onClick: ()=>{
|
|
605
|
+
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');
|
|
606
|
+
},
|
|
607
|
+
className: `toolbar-item spaced ${isItalic ? 'active' : ''}`,
|
|
608
|
+
title: IS_APPLE ? 'Italic (⌘I)' : 'Italic (Ctrl+I)',
|
|
609
|
+
type: "button",
|
|
610
|
+
"aria-label": `Format text as italics. Shortcut: ${IS_APPLE ? '⌘I' : 'Ctrl+I'}`,
|
|
611
|
+
children: /*#__PURE__*/ jsx("i", {
|
|
612
|
+
className: "format italic"
|
|
613
|
+
})
|
|
614
|
+
}),
|
|
615
|
+
/*#__PURE__*/ jsx("button", {
|
|
616
|
+
disabled: !isEditable,
|
|
617
|
+
onClick: ()=>{
|
|
618
|
+
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline');
|
|
619
|
+
},
|
|
620
|
+
className: `toolbar-item spaced ${isUnderline ? 'active' : ''}`,
|
|
621
|
+
title: IS_APPLE ? 'Underline (⌘U)' : 'Underline (Ctrl+U)',
|
|
622
|
+
type: "button",
|
|
623
|
+
"aria-label": `Format text to underlined. Shortcut: ${IS_APPLE ? '⌘U' : 'Ctrl+U'}`,
|
|
624
|
+
children: /*#__PURE__*/ jsx("i", {
|
|
625
|
+
className: "format underline"
|
|
626
|
+
})
|
|
627
|
+
}),
|
|
628
|
+
inlineCode && /*#__PURE__*/ jsx("button", {
|
|
629
|
+
disabled: !isEditable,
|
|
630
|
+
onClick: ()=>{
|
|
631
|
+
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'code');
|
|
632
|
+
},
|
|
633
|
+
className: `toolbar-item spaced ${isCode ? 'active' : ''}`,
|
|
634
|
+
title: "Insert code block",
|
|
635
|
+
type: "button",
|
|
636
|
+
"aria-label": "Insert code block",
|
|
637
|
+
children: /*#__PURE__*/ jsx("i", {
|
|
638
|
+
className: "format code"
|
|
639
|
+
})
|
|
640
|
+
}),
|
|
641
|
+
links && /*#__PURE__*/ jsx("button", {
|
|
642
|
+
type: "button",
|
|
643
|
+
disabled: !isEditable,
|
|
644
|
+
onClick: insertLink,
|
|
645
|
+
className: `toolbar-item spaced ${isLink ? 'active' : ''}`,
|
|
646
|
+
"aria-label": "Insert link",
|
|
647
|
+
title: "Insert link",
|
|
648
|
+
children: /*#__PURE__*/ jsx("i", {
|
|
649
|
+
className: "format link"
|
|
650
|
+
})
|
|
651
|
+
}, "link"),
|
|
652
|
+
/*#__PURE__*/ jsxs(DropDown, {
|
|
653
|
+
disabled: !isEditable,
|
|
654
|
+
buttonClassName: "toolbar-item spaced",
|
|
655
|
+
buttonLabel: "",
|
|
656
|
+
buttonAriaLabel: "Formatting options for additional text styles",
|
|
657
|
+
buttonIconClassName: "icon dropdown-more",
|
|
658
|
+
children: [
|
|
659
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
660
|
+
onClick: ()=>{
|
|
661
|
+
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough');
|
|
662
|
+
},
|
|
663
|
+
className: `item ${dropDownActiveClass(isStrikethrough)}`,
|
|
664
|
+
title: "Strikethrough",
|
|
665
|
+
"aria-label": "Format text with a strikethrough",
|
|
666
|
+
children: [
|
|
667
|
+
/*#__PURE__*/ jsx("i", {
|
|
668
|
+
className: "icon strikethrough"
|
|
669
|
+
}),
|
|
670
|
+
/*#__PURE__*/ jsx("span", {
|
|
671
|
+
className: "text",
|
|
672
|
+
children: "Strikethrough"
|
|
673
|
+
})
|
|
674
|
+
]
|
|
675
|
+
}),
|
|
676
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
677
|
+
onClick: ()=>{
|
|
678
|
+
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "subscript");
|
|
679
|
+
},
|
|
680
|
+
className: `item ${dropDownActiveClass(isSubscript)}`,
|
|
681
|
+
title: "Subscript",
|
|
682
|
+
"aria-label": "Format text with a subscript",
|
|
683
|
+
children: [
|
|
684
|
+
/*#__PURE__*/ jsx("i", {
|
|
685
|
+
className: "icon subscript"
|
|
686
|
+
}),
|
|
687
|
+
/*#__PURE__*/ jsx("span", {
|
|
688
|
+
className: "text",
|
|
689
|
+
children: "Subscript"
|
|
690
|
+
})
|
|
691
|
+
]
|
|
692
|
+
}),
|
|
693
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
694
|
+
onClick: ()=>{
|
|
695
|
+
activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, "superscript");
|
|
696
|
+
},
|
|
697
|
+
className: `item ${dropDownActiveClass(isSuperscript)}`,
|
|
698
|
+
title: "Superscript",
|
|
699
|
+
"aria-label": "Format text with a superscript",
|
|
700
|
+
children: [
|
|
701
|
+
/*#__PURE__*/ jsx("i", {
|
|
702
|
+
className: "icon superscript"
|
|
703
|
+
}),
|
|
704
|
+
/*#__PURE__*/ jsx("span", {
|
|
705
|
+
className: "text",
|
|
706
|
+
children: "Superscript"
|
|
707
|
+
})
|
|
708
|
+
]
|
|
709
|
+
}),
|
|
710
|
+
/*#__PURE__*/ jsxs(DropDownItem, {
|
|
711
|
+
onClick: clearFormatting,
|
|
712
|
+
className: "item",
|
|
713
|
+
title: "Clear text formatting",
|
|
714
|
+
"aria-label": "Clear all text formatting",
|
|
715
|
+
children: [
|
|
716
|
+
/*#__PURE__*/ jsx("i", {
|
|
717
|
+
className: "icon clear"
|
|
718
|
+
}),
|
|
719
|
+
/*#__PURE__*/ jsx("span", {
|
|
720
|
+
className: "text",
|
|
721
|
+
children: "Clear Formatting"
|
|
722
|
+
})
|
|
723
|
+
]
|
|
724
|
+
})
|
|
725
|
+
]
|
|
726
|
+
}),
|
|
727
|
+
activeEditor === editor && (horizontalRulePlugin || inlineImagePlugin || tablePlugin || admonitionPlugin) && /*#__PURE__*/ jsxs(Fragment, {
|
|
728
|
+
children: [
|
|
729
|
+
/*#__PURE__*/ jsx(Divider, {}),
|
|
730
|
+
/*#__PURE__*/ jsxs(DropDown, {
|
|
731
|
+
disabled: !isEditable,
|
|
732
|
+
buttonClassName: "toolbar-item spaced",
|
|
733
|
+
buttonLabel: "Insert",
|
|
734
|
+
buttonAriaLabel: "Insert specialized editor node",
|
|
735
|
+
buttonIconClassName: "icon plus",
|
|
736
|
+
children: [
|
|
737
|
+
horizontalRulePlugin && /*#__PURE__*/ jsxs(DropDownItem, {
|
|
738
|
+
onClick: ()=>{
|
|
739
|
+
activeEditor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, void 0);
|
|
740
|
+
},
|
|
741
|
+
className: "item",
|
|
742
|
+
children: [
|
|
743
|
+
/*#__PURE__*/ jsx("i", {
|
|
744
|
+
className: "icon horizontal-rule"
|
|
745
|
+
}),
|
|
746
|
+
/*#__PURE__*/ jsx("span", {
|
|
747
|
+
className: "text",
|
|
748
|
+
children: "Horizontal Rule"
|
|
749
|
+
})
|
|
750
|
+
]
|
|
751
|
+
}),
|
|
752
|
+
layoutPlugin && /*#__PURE__*/ jsxs(DropDownItem, {
|
|
753
|
+
onClick: ()=>{
|
|
754
|
+
activeEditor.dispatchCommand(OPEN_INSERT_LAYOUT_MODAL_COMMAND, null);
|
|
755
|
+
},
|
|
756
|
+
className: "item",
|
|
757
|
+
children: [
|
|
758
|
+
/*#__PURE__*/ jsx("i", {
|
|
759
|
+
className: "icon columns"
|
|
760
|
+
}),
|
|
761
|
+
/*#__PURE__*/ jsx("span", {
|
|
762
|
+
className: "text",
|
|
763
|
+
children: "Columns Layout"
|
|
764
|
+
})
|
|
765
|
+
]
|
|
766
|
+
}),
|
|
767
|
+
admonitionPlugin && /*#__PURE__*/ jsxs(DropDownItem, {
|
|
768
|
+
onClick: ()=>{
|
|
769
|
+
activeEditor.dispatchCommand(OPEN_ADMONITION_MODAL_COMMAND, null);
|
|
770
|
+
},
|
|
771
|
+
className: "item",
|
|
772
|
+
children: [
|
|
773
|
+
/*#__PURE__*/ jsx("i", {
|
|
774
|
+
className: "icon admonition"
|
|
775
|
+
}),
|
|
776
|
+
/*#__PURE__*/ jsx("span", {
|
|
777
|
+
className: "text",
|
|
778
|
+
children: "Admonition"
|
|
779
|
+
})
|
|
780
|
+
]
|
|
781
|
+
}),
|
|
782
|
+
inlineImagePlugin && /*#__PURE__*/ jsxs(DropDownItem, {
|
|
783
|
+
onClick: ()=>{
|
|
784
|
+
activeEditor.dispatchCommand(OPEN_INLINE_IMAGE_MODAL_COMMAND, null);
|
|
785
|
+
},
|
|
786
|
+
className: "item",
|
|
787
|
+
children: [
|
|
788
|
+
/*#__PURE__*/ jsx("i", {
|
|
789
|
+
className: "icon image"
|
|
790
|
+
}),
|
|
791
|
+
/*#__PURE__*/ jsx("span", {
|
|
792
|
+
className: "text",
|
|
793
|
+
children: "Inline Image"
|
|
794
|
+
})
|
|
795
|
+
]
|
|
796
|
+
}),
|
|
797
|
+
tablePlugin && /*#__PURE__*/ jsxs(DropDownItem, {
|
|
798
|
+
onClick: ()=>{
|
|
799
|
+
activeEditor.dispatchCommand(OPEN_TABLE_MODAL_COMMAND, null);
|
|
800
|
+
},
|
|
801
|
+
className: "item",
|
|
802
|
+
children: [
|
|
803
|
+
/*#__PURE__*/ jsx("i", {
|
|
804
|
+
className: "icon table"
|
|
805
|
+
}),
|
|
806
|
+
/*#__PURE__*/ jsx("span", {
|
|
807
|
+
className: "text",
|
|
808
|
+
children: "Table"
|
|
809
|
+
})
|
|
810
|
+
]
|
|
811
|
+
}),
|
|
812
|
+
autoEmbedPlugin && EmbedConfigs.map((embedConfig)=>/*#__PURE__*/ jsxs(DropDownItem, {
|
|
813
|
+
onClick: ()=>{
|
|
814
|
+
activeEditor.dispatchCommand(INSERT_EMBED_COMMAND, embedConfig.type);
|
|
815
|
+
},
|
|
816
|
+
className: "item",
|
|
817
|
+
children: [
|
|
818
|
+
embedConfig.icon,
|
|
819
|
+
/*#__PURE__*/ jsx("span", {
|
|
820
|
+
className: "text",
|
|
821
|
+
children: embedConfig.contentName
|
|
822
|
+
})
|
|
823
|
+
]
|
|
824
|
+
}, embedConfig.type))
|
|
825
|
+
]
|
|
826
|
+
})
|
|
827
|
+
]
|
|
828
|
+
})
|
|
829
|
+
]
|
|
830
|
+
}),
|
|
831
|
+
toolbarExtensionItems.slice().sort((a, b)=>(a.order ?? 0) - (b.order ?? 0)).map((item)=>/*#__PURE__*/ jsx(external_react_Fragment, {
|
|
832
|
+
children: item.node
|
|
833
|
+
}, item.id))
|
|
834
|
+
]
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
export { ToolbarPlugin };
|