@infonomic/payload-alternative-lexical-editor 1.0.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/LICENSE +21 -0
- package/dist/adapter.d.ts +11 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +124 -0
- package/dist/adapter.js.map +1 -0
- package/dist/cell/rsc-entry.d.ts +20 -0
- package/dist/cell/rsc-entry.d.ts.map +1 -0
- package/dist/cell/rsc-entry.js +68 -0
- package/dist/cell/rsc-entry.js.map +1 -0
- package/dist/field/apply-value-plugin.d.ts +9 -0
- package/dist/field/apply-value-plugin.d.ts.map +1 -0
- package/dist/field/apply-value-plugin.js +66 -0
- package/dist/field/apply-value-plugin.js.map +1 -0
- package/dist/field/build-initial-state.d.ts +29 -0
- package/dist/field/build-initial-state.d.ts.map +1 -0
- package/dist/field/build-initial-state.js +14 -0
- package/dist/field/build-initial-state.js.map +1 -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 +52 -0
- package/dist/field/config/default.js.map +1 -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 +38 -0
- package/dist/field/config/editor-config-context.js.map +1 -0
- package/dist/field/config/types.d.ts +22 -0
- package/dist/field/config/types.d.ts.map +1 -0
- package/dist/field/config/types.js +2 -0
- package/dist/field/config/types.js.map +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/constants.js.map +1 -0
- package/dist/field/context/shared-autocomplete-context.d.ts +18 -0
- package/dist/field/context/shared-autocomplete-context.d.ts.map +1 -0
- package/dist/field/context/shared-autocomplete-context.js +40 -0
- package/dist/field/context/shared-autocomplete-context.js.map +1 -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 +13 -0
- package/dist/field/context/shared-history-context.js.map +1 -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 +18 -0
- package/dist/field/context/shared-on-change-context.js.map +1 -0
- package/dist/field/debug.d.ts +3 -0
- package/dist/field/debug.d.ts.map +1 -0
- package/dist/field/debug.js +17 -0
- package/dist/field/debug.js.map +1 -0
- package/dist/field/editor-context.d.ts +15 -0
- package/dist/field/editor-context.d.ts.map +1 -0
- package/dist/field/editor-context.js +37 -0
- package/dist/field/editor-context.js.map +1 -0
- package/dist/field/editor.css +1477 -0
- package/dist/field/editor.d.ts +4 -0
- package/dist/field/editor.d.ts.map +1 -0
- package/dist/field/editor.js +86 -0
- package/dist/field/editor.js.map +1 -0
- package/dist/field/field-component.css +44 -0
- package/dist/field/field-component.d.ts +16 -0
- package/dist/field/field-component.d.ts.map +1 -0
- package/dist/field/field-component.js +136 -0
- package/dist/field/field-component.js.map +1 -0
- package/dist/field/hooks/useMediaQuery.d.ts +3 -0
- package/dist/field/hooks/useMediaQuery.d.ts.map +1 -0
- package/dist/field/hooks/useMediaQuery.js +20 -0
- package/dist/field/hooks/useMediaQuery.js.map +1 -0
- package/dist/field/hooks/useModal.d.ts +13 -0
- package/dist/field/hooks/useModal.d.ts.map +1 -0
- package/dist/field/hooks/useModal.js +28 -0
- package/dist/field/hooks/useModal.js.map +1 -0
- package/dist/field/hooks/useReport.d.ts +9 -0
- package/dist/field/hooks/useReport.d.ts.map +1 -0
- package/dist/field/hooks/useReport.js +51 -0
- package/dist/field/hooks/useReport.js.map +1 -0
- package/dist/field/images/cat-typing.gif +0 -0
- package/dist/field/images/emoji/1F600.png +0 -0
- package/dist/field/images/emoji/1F641.png +0 -0
- package/dist/field/images/emoji/1F642.png +0 -0
- package/dist/field/images/emoji/2764.png +0 -0
- package/dist/field/images/icons/3-columns.svg +3 -0
- package/dist/field/images/icons/admonition.svg +1 -0
- package/dist/field/images/icons/arrow-clockwise.svg +1 -0
- package/dist/field/images/icons/arrow-counterclockwise.svg +1 -0
- package/dist/field/images/icons/bg-color.svg +1 -0
- package/dist/field/images/icons/camera.svg +1 -0
- package/dist/field/images/icons/card-checklist.svg +1 -0
- package/dist/field/images/icons/caret-right-fill.svg +1 -0
- package/dist/field/images/icons/chat-left-text.svg +1 -0
- package/dist/field/images/icons/chat-right-dots.svg +1 -0
- package/dist/field/images/icons/chat-right-text.svg +1 -0
- package/dist/field/images/icons/chat-right.svg +1 -0
- package/dist/field/images/icons/chat-square-quote.svg +1 -0
- package/dist/field/images/icons/chevron-down.svg +1 -0
- package/dist/field/images/icons/clipboard.svg +1 -0
- package/dist/field/images/icons/close.svg +1 -0
- package/dist/field/images/icons/code.svg +1 -0
- package/dist/field/images/icons/comments.svg +1 -0
- package/dist/field/images/icons/copy.svg +1 -0
- package/dist/field/images/icons/diagram-2.svg +1 -0
- package/dist/field/images/icons/download.svg +1 -0
- package/dist/field/images/icons/draggable-block-menu.svg +1 -0
- package/dist/field/images/icons/dropdown-more.svg +1 -0
- package/dist/field/images/icons/figma.svg +1 -0
- package/dist/field/images/icons/file-earmark-text.svg +4 -0
- package/dist/field/images/icons/file-image.svg +1 -0
- package/dist/field/images/icons/filetype-gif.svg +1 -0
- package/dist/field/images/icons/font-color.svg +1 -0
- package/dist/field/images/icons/font-family.svg +1 -0
- package/dist/field/images/icons/gear.svg +1 -0
- package/dist/field/images/icons/horizontal-rule.svg +1 -0
- package/dist/field/images/icons/indent.svg +1 -0
- package/dist/field/images/icons/journal-code.svg +1 -0
- package/dist/field/images/icons/journal-text.svg +1 -0
- package/dist/field/images/icons/justify.svg +1 -0
- package/dist/field/images/icons/link.svg +1 -0
- package/dist/field/images/icons/list-ol.svg +1 -0
- package/dist/field/images/icons/list-ul.svg +1 -0
- package/dist/field/images/icons/lock-fill.svg +1 -0
- package/dist/field/images/icons/lock.svg +1 -0
- package/dist/field/images/icons/markdown.svg +1 -0
- package/dist/field/images/icons/mic.svg +1 -0
- package/dist/field/images/icons/outdent.svg +1 -0
- package/dist/field/images/icons/paint-bucket.svg +1 -0
- package/dist/field/images/icons/palette.svg +1 -0
- package/dist/field/images/icons/pencil-fill.svg +1 -0
- package/dist/field/images/icons/plug-fill.svg +1 -0
- package/dist/field/images/icons/plug.svg +1 -0
- package/dist/field/images/icons/plus-slash-minus.svg +1 -0
- package/dist/field/images/icons/plus.svg +1 -0
- package/dist/field/images/icons/prettier-error.svg +1 -0
- package/dist/field/images/icons/prettier.svg +1 -0
- package/dist/field/images/icons/send.svg +1 -0
- package/dist/field/images/icons/square-check.svg +1 -0
- package/dist/field/images/icons/sticky.svg +1 -0
- package/dist/field/images/icons/success-alt.svg +1 -0
- package/dist/field/images/icons/success.svg +1 -0
- package/dist/field/images/icons/table.svg +1 -0
- package/dist/field/images/icons/text-center.svg +1 -0
- package/dist/field/images/icons/text-left.svg +1 -0
- package/dist/field/images/icons/text-paragraph.svg +1 -0
- package/dist/field/images/icons/text-right.svg +1 -0
- package/dist/field/images/icons/trash.svg +1 -0
- package/dist/field/images/icons/trash3.svg +1 -0
- package/dist/field/images/icons/tweet.svg +1 -0
- package/dist/field/images/icons/type-bold.svg +1 -0
- package/dist/field/images/icons/type-h1.svg +1 -0
- package/dist/field/images/icons/type-h2.svg +1 -0
- package/dist/field/images/icons/type-h3.svg +1 -0
- package/dist/field/images/icons/type-h4.svg +1 -0
- package/dist/field/images/icons/type-h5.svg +1 -0
- package/dist/field/images/icons/type-h6.svg +1 -0
- package/dist/field/images/icons/type-italic.svg +1 -0
- package/dist/field/images/icons/type-strikethrough.svg +1 -0
- package/dist/field/images/icons/type-subscript.svg +1 -0
- package/dist/field/images/icons/type-superscript.svg +1 -0
- package/dist/field/images/icons/type-underline.svg +1 -0
- package/dist/field/images/icons/upload.svg +1 -0
- package/dist/field/images/icons/user.svg +1 -0
- package/dist/field/images/icons/vimeo.svg +1 -0
- package/dist/field/images/icons/youtube.svg +1 -0
- package/dist/field/images/landscape.jpg +0 -0
- package/dist/field/images/logo.svg +1 -0
- package/dist/field/images/yellow-flower-small.jpg +0 -0
- package/dist/field/images/yellow-flower.jpg +0 -0
- package/dist/field/index.d.ts +12 -0
- package/dist/field/index.d.ts.map +1 -0
- package/dist/field/index.js +9 -0
- package/dist/field/index.js.map +1 -0
- package/dist/field/lexical-after-read-populate-links.d.ts +47 -0
- package/dist/field/lexical-after-read-populate-links.d.ts.map +1 -0
- package/dist/field/lexical-after-read-populate-links.js +118 -0
- package/dist/field/lexical-after-read-populate-links.js.map +1 -0
- package/dist/field/lexical-after-read-populate-media.d.ts +34 -0
- package/dist/field/lexical-after-read-populate-media.d.ts.map +1 -0
- package/dist/field/lexical-after-read-populate-media.js +40 -0
- package/dist/field/lexical-after-read-populate-media.js.map +1 -0
- package/dist/field/lexical-before-change-populate-links.d.ts +52 -0
- package/dist/field/lexical-before-change-populate-links.d.ts.map +1 -0
- package/dist/field/lexical-before-change-populate-links.js +116 -0
- package/dist/field/lexical-before-change-populate-links.js.map +1 -0
- package/dist/field/nodes/admonition-node/admonition-node-component.css +115 -0
- package/dist/field/nodes/admonition-node/admonition-node-component.d.ts +11 -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 +157 -0
- package/dist/field/nodes/admonition-node/admonition-node-component.js.map +1 -0
- package/dist/field/nodes/admonition-node/admonition-node.d.ts +28 -0
- package/dist/field/nodes/admonition-node/admonition-node.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/admonition-node.js +134 -0
- package/dist/field/nodes/admonition-node/admonition-node.js.map +1 -0
- package/dist/field/nodes/admonition-node/icons/danger-icon.css +11 -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 +7 -0
- package/dist/field/nodes/admonition-node/icons/danger-icon.js.map +1 -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 +5 -0
- package/dist/field/nodes/admonition-node/icons/index.js.map +1 -0
- package/dist/field/nodes/admonition-node/icons/note-icon.css +11 -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 +7 -0
- package/dist/field/nodes/admonition-node/icons/note-icon.js.map +1 -0
- package/dist/field/nodes/admonition-node/icons/tip-icon.css +11 -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 +7 -0
- package/dist/field/nodes/admonition-node/icons/tip-icon.js.map +1 -0
- package/dist/field/nodes/admonition-node/icons/warning-icon.css +11 -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 +7 -0
- package/dist/field/nodes/admonition-node/icons/warning-icon.js.map +1 -0
- package/dist/field/nodes/admonition-node/index.d.ts +4 -0
- package/dist/field/nodes/admonition-node/index.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/index.js +4 -0
- package/dist/field/nodes/admonition-node/index.js.map +1 -0
- package/dist/field/nodes/admonition-node/types.d.ts +14 -0
- package/dist/field/nodes/admonition-node/types.d.ts.map +1 -0
- package/dist/field/nodes/admonition-node/types.js +2 -0
- package/dist/field/nodes/admonition-node/types.js.map +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 +44 -0
- package/dist/field/nodes/index.js.map +1 -0
- package/dist/field/nodes/inline-image-node/index.d.ts +4 -0
- package/dist/field/nodes/inline-image-node/index.d.ts.map +1 -0
- package/dist/field/nodes/inline-image-node/index.js +4 -0
- package/dist/field/nodes/inline-image-node/index.js.map +1 -0
- package/dist/field/nodes/inline-image-node/inline-image-node-component.css +205 -0
- package/dist/field/nodes/inline-image-node/inline-image-node-component.d.ts +18 -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 +239 -0
- package/dist/field/nodes/inline-image-node/inline-image-node-component.js.map +1 -0
- package/dist/field/nodes/inline-image-node/inline-image-node.d.ts +39 -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 +204 -0
- package/dist/field/nodes/inline-image-node/inline-image-node.js.map +1 -0
- package/dist/field/nodes/inline-image-node/types.d.ts +33 -0
- package/dist/field/nodes/inline-image-node/types.d.ts.map +1 -0
- package/dist/field/nodes/inline-image-node/types.js +2 -0
- package/dist/field/nodes/inline-image-node/types.js.map +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 +66 -0
- package/dist/field/nodes/layout-container-node/layout-container-node.js.map +1 -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 +50 -0
- package/dist/field/nodes/layout-container-node/layout-item-node.js.map +1 -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 +46 -0
- package/dist/field/nodes/link-nodes/auto-link-node.js.map +1 -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 +4 -0
- package/dist/field/nodes/link-nodes/index.js.map +1 -0
- package/dist/field/nodes/link-nodes/link-node.d.ts +42 -0
- package/dist/field/nodes/link-nodes/link-node.d.ts.map +1 -0
- package/dist/field/nodes/link-nodes/link-node.js +340 -0
- package/dist/field/nodes/link-nodes/link-node.js.map +1 -0
- package/dist/field/nodes/link-nodes/types.d.ts +16 -0
- package/dist/field/nodes/link-nodes/types.d.ts.map +1 -0
- package/dist/field/nodes/link-nodes/types.js +2 -0
- package/dist/field/nodes/link-nodes/types.js.map +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 +92 -0
- package/dist/field/nodes/vimeo-node/index.js.map +1 -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 +92 -0
- package/dist/field/nodes/youtube-node/index.js.map +1 -0
- package/dist/field/plugins/admonition-plugin/admonition-drawer.css +8 -0
- package/dist/field/plugins/admonition-plugin/admonition-drawer.d.ts +5 -0
- package/dist/field/plugins/admonition-plugin/admonition-drawer.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/admonition-drawer.js +44 -0
- package/dist/field/plugins/admonition-plugin/admonition-drawer.js.map +1 -0
- package/dist/field/plugins/admonition-plugin/fields.d.ts +14 -0
- package/dist/field/plugins/admonition-plugin/fields.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/fields.js +72 -0
- package/dist/field/plugins/admonition-plugin/fields.js.map +1 -0
- package/dist/field/plugins/admonition-plugin/index.d.ts +8 -0
- package/dist/field/plugins/admonition-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/index.js +65 -0
- package/dist/field/plugins/admonition-plugin/index.js.map +1 -0
- package/dist/field/plugins/admonition-plugin/types.d.ts +15 -0
- package/dist/field/plugins/admonition-plugin/types.d.ts.map +1 -0
- package/dist/field/plugins/admonition-plugin/types.js +2 -0
- package/dist/field/plugins/admonition-plugin/types.js.map +1 -0
- package/dist/field/plugins/auto-embed-plugin/index.d.ts +26 -0
- package/dist/field/plugins/auto-embed-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/auto-embed-plugin/index.js +191 -0
- package/dist/field/plugins/auto-embed-plugin/index.js.map +1 -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/code-highlight-plugin/index.js.map +1 -0
- package/dist/field/plugins/drag-drop-paste-plugin/index.d.ts +9 -0
- package/dist/field/plugins/drag-drop-paste-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/drag-drop-paste-plugin/index.js +37 -0
- package/dist/field/plugins/drag-drop-paste-plugin/index.js.map +1 -0
- package/dist/field/plugins/floating-text-format-toolbar-plugin/index.css +150 -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 +236 -0
- package/dist/field/plugins/floating-text-format-toolbar-plugin/index.js.map +1 -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 +160 -0
- package/dist/field/plugins/inline-image-plugin/fields.js.map +1 -0
- package/dist/field/plugins/inline-image-plugin/index.d.ts +26 -0
- package/dist/field/plugins/inline-image-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/index.js +222 -0
- package/dist/field/plugins/inline-image-plugin/index.js.map +1 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-drawer.css +29 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-drawer.d.ts +5 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-drawer.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-drawer.js +51 -0
- package/dist/field/plugins/inline-image-plugin/inline-image-drawer.js.map +1 -0
- package/dist/field/plugins/inline-image-plugin/types.d.ts +16 -0
- package/dist/field/plugins/inline-image-plugin/types.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/types.js +2 -0
- package/dist/field/plugins/inline-image-plugin/types.js.map +1 -0
- package/dist/field/plugins/inline-image-plugin/utils.d.ts +9 -0
- package/dist/field/plugins/inline-image-plugin/utils.d.ts.map +1 -0
- package/dist/field/plugins/inline-image-plugin/utils.js +27 -0
- package/dist/field/plugins/inline-image-plugin/utils.js.map +1 -0
- package/dist/field/plugins/layout-plugin/insert-layout-dialog.d.ts +14 -0
- package/dist/field/plugins/layout-plugin/insert-layout-dialog.d.ts.map +1 -0
- package/dist/field/plugins/layout-plugin/insert-layout-dialog.js +26 -0
- package/dist/field/plugins/layout-plugin/insert-layout-dialog.js.map +1 -0
- package/dist/field/plugins/layout-plugin/layout-plugin.d.ts +8 -0
- package/dist/field/plugins/layout-plugin/layout-plugin.d.ts.map +1 -0
- package/dist/field/plugins/layout-plugin/layout-plugin.js +87 -0
- package/dist/field/plugins/layout-plugin/layout-plugin.js.map +1 -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 +218 -0
- package/dist/field/plugins/link-plugin/auto-link/auto-link-plugin.js.map +1 -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 +17 -0
- package/dist/field/plugins/link-plugin/auto-link/index.js.map +1 -0
- package/dist/field/plugins/link-plugin/link/fields.d.ts +11 -0
- package/dist/field/plugins/link-plugin/link/fields.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/link/fields.js +120 -0
- package/dist/field/plugins/link-plugin/link/fields.js.map +1 -0
- package/dist/field/plugins/link-plugin/link/floating-link-editor.css +128 -0
- package/dist/field/plugins/link-plugin/link/floating-link-editor.d.ts +13 -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 +239 -0
- package/dist/field/plugins/link-plugin/link/floating-link-editor.js.map +1 -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 +65 -0
- package/dist/field/plugins/link-plugin/link/index.js.map +1 -0
- package/dist/field/plugins/link-plugin/link/link-drawer.css +21 -0
- package/dist/field/plugins/link-plugin/link/link-drawer.d.ts +5 -0
- package/dist/field/plugins/link-plugin/link/link-drawer.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/link/link-drawer.js +72 -0
- package/dist/field/plugins/link-plugin/link/link-drawer.js.map +1 -0
- package/dist/field/plugins/link-plugin/link/types.d.ts +20 -0
- package/dist/field/plugins/link-plugin/link/types.d.ts.map +1 -0
- package/dist/field/plugins/link-plugin/link/types.js +2 -0
- package/dist/field/plugins/link-plugin/link/types.js.map +1 -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 +476 -0
- package/dist/field/plugins/table-action-menu-plugin/index.js.map +1 -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 +30 -0
- package/dist/field/plugins/table-plugin/index.js.map +1 -0
- package/dist/field/plugins/table-plugin/table-drawer.d.ts +12 -0
- package/dist/field/plugins/table-plugin/table-drawer.d.ts.map +1 -0
- package/dist/field/plugins/table-plugin/table-drawer.js +42 -0
- package/dist/field/plugins/table-plugin/table-drawer.js.map +1 -0
- package/dist/field/plugins/toolbar-plugin/index.d.ts +10 -0
- package/dist/field/plugins/toolbar-plugin/index.d.ts.map +1 -0
- package/dist/field/plugins/toolbar-plugin/index.js +394 -0
- package/dist/field/plugins/toolbar-plugin/index.js.map +1 -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 +9 -0
- package/dist/field/plugins/treeview-plugin/index.js.map +1 -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 +29 -0
- package/dist/field/plugins/vimeo-plugin/index.js.map +1 -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 +29 -0
- package/dist/field/plugins/youtube-plugin/index.js.map +1 -0
- package/dist/field/rsc-entry.d.ts +9 -0
- package/dist/field/rsc-entry.d.ts.map +1 -0
- package/dist/field/rsc-entry.js +57 -0
- package/dist/field/rsc-entry.js.map +1 -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 +9 -0
- package/dist/field/shared/canUseDOM.js.map +1 -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 +22 -0
- package/dist/field/shared/environment.js.map +1 -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 +18 -0
- package/dist/field/shared/invariant.js.map +1 -0
- package/dist/field/shared/simpleDiffWithCursor.d.ts +13 -0
- package/dist/field/shared/simpleDiffWithCursor.d.ts.map +1 -0
- package/dist/field/shared/simpleDiffWithCursor.js +34 -0
- package/dist/field/shared/simpleDiffWithCursor.js.map +1 -0
- package/dist/field/shared/useLayoutEffect.d.ts +11 -0
- package/dist/field/shared/useLayoutEffect.d.ts.map +1 -0
- package/dist/field/shared/useLayoutEffect.js +12 -0
- package/dist/field/shared/useLayoutEffect.js.map +1 -0
- package/dist/field/shared/warnOnlyOnce.d.ts +9 -0
- package/dist/field/shared/warnOnlyOnce.d.ts.map +1 -0
- package/dist/field/shared/warnOnlyOnce.js +21 -0
- package/dist/field/shared/warnOnlyOnce.js.map +1 -0
- package/dist/field/themes/lexical-editor-theme.css +558 -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/themes/lexical-editor-theme.js.map +1 -0
- package/dist/field/types.d.ts +10 -0
- package/dist/field/types.d.ts.map +1 -0
- package/dist/field/types.js +2 -0
- package/dist/field/types.js.map +1 -0
- package/dist/field/ui/button.css +45 -0
- package/dist/field/ui/button.d.ts +19 -0
- package/dist/field/ui/button.d.ts.map +1 -0
- package/dist/field/ui/button.js +8 -0
- package/dist/field/ui/button.js.map +1 -0
- package/dist/field/ui/checkbox.css +52 -0
- package/dist/field/ui/color-picker.css +88 -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 +250 -0
- package/dist/field/ui/color-picker.js.map +1 -0
- package/dist/field/ui/content-editable-inline.d.ts +13 -0
- package/dist/field/ui/content-editable-inline.d.ts.map +1 -0
- package/dist/field/ui/content-editable-inline.js +14 -0
- package/dist/field/ui/content-editable-inline.js.map +1 -0
- package/dist/field/ui/content-editable.css +28 -0
- package/dist/field/ui/content-editable.d.ts +13 -0
- package/dist/field/ui/content-editable.d.ts.map +1 -0
- package/dist/field/ui/content-editable.js +15 -0
- package/dist/field/ui/content-editable.js.map +1 -0
- package/dist/field/ui/dialog.css +17 -0
- package/dist/field/ui/dialog.d.ts +17 -0
- package/dist/field/ui/dialog.d.ts.map +1 -0
- package/dist/field/ui/dialog.js +10 -0
- package/dist/field/ui/dialog.js.map +1 -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 +118 -0
- package/dist/field/ui/dropdown.js.map +1 -0
- package/dist/field/ui/file-input.d.ts +18 -0
- package/dist/field/ui/file-input.d.ts.map +1 -0
- package/dist/field/ui/file-input.js +17 -0
- package/dist/field/ui/file-input.js.map +1 -0
- package/dist/field/ui/input.css +32 -0
- package/dist/field/ui/modal.css +84 -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 +48 -0
- package/dist/field/ui/modal.js.map +1 -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-inline.js.map +1 -0
- package/dist/field/ui/placeholder.css +33 -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/placeholder.js.map +1 -0
- package/dist/field/ui/select.css +34 -0
- package/dist/field/ui/select.d.ts +16 -0
- package/dist/field/ui/select.d.ts.map +1 -0
- package/dist/field/ui/select.js +17 -0
- package/dist/field/ui/select.js.map +1 -0
- package/dist/field/ui/switch.d.ts +15 -0
- package/dist/field/ui/switch.d.ts.map +1 -0
- package/dist/field/ui/switch.js +8 -0
- package/dist/field/ui/switch.js.map +1 -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 +18 -0
- package/dist/field/ui/text-input.js.map +1 -0
- package/dist/field/utils/cloneDeep.d.ts +2 -0
- package/dist/field/utils/cloneDeep.d.ts.map +1 -0
- package/dist/field/utils/cloneDeep.js +50 -0
- package/dist/field/utils/cloneDeep.js.map +1 -0
- package/dist/field/utils/deepEqual.d.ts +2 -0
- package/dist/field/utils/deepEqual.d.ts.map +1 -0
- package/dist/field/utils/deepEqual.js +48 -0
- package/dist/field/utils/deepEqual.js.map +1 -0
- package/dist/field/utils/emoji-list.d.ts +28 -0
- package/dist/field/utils/emoji-list.d.ts.map +1 -0
- package/dist/field/utils/emoji-list.js +16613 -0
- package/dist/field/utils/emoji-list.js.map +1 -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 +23 -0
- package/dist/field/utils/getDOMRangeRect.js.map +1 -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 +25 -0
- package/dist/field/utils/getSelectedNode.js.map +1 -0
- package/dist/field/utils/guard.d.ts +9 -0
- package/dist/field/utils/guard.d.ts.map +1 -0
- package/dist/field/utils/guard.js +11 -0
- package/dist/field/utils/guard.js.map +1 -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 +32 -0
- package/dist/field/utils/hashSerializedState.js.map +1 -0
- package/dist/field/utils/isMobileWidth.d.ts +9 -0
- package/dist/field/utils/isMobileWidth.d.ts.map +1 -0
- package/dist/field/utils/isMobileWidth.js +9 -0
- package/dist/field/utils/isMobileWidth.js.map +1 -0
- package/dist/field/utils/joinClasses.d.ts +9 -0
- package/dist/field/utils/joinClasses.d.ts.map +1 -0
- package/dist/field/utils/joinClasses.js +11 -0
- package/dist/field/utils/joinClasses.js.map +1 -0
- package/dist/field/utils/load-related.d.ts +4 -0
- package/dist/field/utils/load-related.d.ts.map +1 -0
- package/dist/field/utils/load-related.js +45 -0
- package/dist/field/utils/load-related.js.map +1 -0
- package/dist/field/utils/point.d.ts +22 -0
- package/dist/field/utils/point.d.ts.map +1 -0
- package/dist/field/utils/point.js +43 -0
- package/dist/field/utils/point.js.map +1 -0
- package/dist/field/utils/rect.d.ts +46 -0
- package/dist/field/utils/rect.d.ts.map +1 -0
- package/dist/field/utils/rect.js +101 -0
- package/dist/field/utils/rect.js.map +1 -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 +34 -0
- package/dist/field/utils/setFloatingElemPosition.js.map +1 -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 +33 -0
- package/dist/field/utils/setFloatingElemPositionForLinkEditor.js.map +1 -0
- package/dist/field/utils/swipe.d.ts +12 -0
- package/dist/field/utils/swipe.d.ts.map +1 -0
- package/dist/field/utils/swipe.js +100 -0
- package/dist/field/utils/swipe.js.map +1 -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 +45 -0
- package/dist/field/utils/url.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validate/hasText.d.ts +3 -0
- package/dist/validate/hasText.d.ts.map +1 -0
- package/dist/validate/hasText.js +29 -0
- package/dist/validate/hasText.js.map +1 -0
- package/dist/validate/validate-client.d.ts +4 -0
- package/dist/validate/validate-client.d.ts.map +1 -0
- package/dist/validate/validate-client.js +17 -0
- package/dist/validate/validate-client.js.map +1 -0
- package/dist/validate/validate-server.d.ts +4 -0
- package/dist/validate/validate-server.d.ts.map +1 -0
- package/dist/validate/validate-server.js +10 -0
- package/dist/validate/validate-server.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect } from 'react';
|
|
10
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
11
|
+
import { mergeRegister } from '@lexical/utils';
|
|
12
|
+
import { $createTextNode, $isElementNode, $isLineBreakNode, $isTextNode, TextNode } from 'lexical';
|
|
13
|
+
import { $createAutoLinkNode, $isAutoLinkNode, $isLinkNode, AutoLinkNode, } from '../../../nodes/link-nodes';
|
|
14
|
+
import invariant from '../../../shared/invariant';
|
|
15
|
+
export function createLinkMatcherWithRegExp(regExp, urlTransformer = (text) => text) {
|
|
16
|
+
return (text) => {
|
|
17
|
+
const match = regExp.exec(text);
|
|
18
|
+
if (match === null)
|
|
19
|
+
return null;
|
|
20
|
+
return {
|
|
21
|
+
index: match.index,
|
|
22
|
+
length: match[0].length,
|
|
23
|
+
text: match[0],
|
|
24
|
+
url: urlTransformer(text),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function findFirstMatch(text, matchers) {
|
|
29
|
+
for (let i = 0; i < matchers.length; i++) {
|
|
30
|
+
const match = matchers[i](text);
|
|
31
|
+
if (match != null) {
|
|
32
|
+
return match;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const PUNCTUATION_OR_SPACE = /[.,;\s]/;
|
|
38
|
+
function isSeparator(char) {
|
|
39
|
+
return PUNCTUATION_OR_SPACE.test(char);
|
|
40
|
+
}
|
|
41
|
+
function endsWithSeparator(textContent) {
|
|
42
|
+
return isSeparator(textContent[textContent.length - 1]);
|
|
43
|
+
}
|
|
44
|
+
function startsWithSeparator(textContent) {
|
|
45
|
+
return isSeparator(textContent[0]);
|
|
46
|
+
}
|
|
47
|
+
function isPreviousNodeValid(node) {
|
|
48
|
+
let previousNode = node.getPreviousSibling();
|
|
49
|
+
if ($isElementNode(previousNode)) {
|
|
50
|
+
previousNode = previousNode.getLastDescendant();
|
|
51
|
+
}
|
|
52
|
+
return (previousNode === null ||
|
|
53
|
+
$isLineBreakNode(previousNode) ||
|
|
54
|
+
($isTextNode(previousNode) && endsWithSeparator(previousNode.getTextContent())));
|
|
55
|
+
}
|
|
56
|
+
function isNextNodeValid(node) {
|
|
57
|
+
let nextNode = node.getNextSibling();
|
|
58
|
+
if ($isElementNode(nextNode)) {
|
|
59
|
+
nextNode = nextNode.getFirstDescendant();
|
|
60
|
+
}
|
|
61
|
+
return (nextNode === null ||
|
|
62
|
+
$isLineBreakNode(nextNode) ||
|
|
63
|
+
($isTextNode(nextNode) && startsWithSeparator(nextNode.getTextContent())));
|
|
64
|
+
}
|
|
65
|
+
function isContentAroundIsValid(matchStart, matchEnd, text, node) {
|
|
66
|
+
const contentBeforeIsValid = matchStart > 0 ? isSeparator(text[matchStart - 1]) : isPreviousNodeValid(node);
|
|
67
|
+
if (!contentBeforeIsValid) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const contentAfterIsValid = matchEnd < text.length ? isSeparator(text[matchEnd]) : isNextNodeValid(node);
|
|
71
|
+
return contentAfterIsValid;
|
|
72
|
+
}
|
|
73
|
+
function handleLinkCreation(node, matchers, onChange) {
|
|
74
|
+
const nodeText = node.getTextContent();
|
|
75
|
+
let text = nodeText;
|
|
76
|
+
let invalidMatchEnd = 0;
|
|
77
|
+
let remainingTextNode = node;
|
|
78
|
+
let match = null;
|
|
79
|
+
while (true) {
|
|
80
|
+
match = findFirstMatch(text, matchers);
|
|
81
|
+
if (match == null) {
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
const matchStart = match.index;
|
|
85
|
+
const matchLength = match.length;
|
|
86
|
+
const matchEnd = matchStart + matchLength;
|
|
87
|
+
const isValid = isContentAroundIsValid(invalidMatchEnd + matchStart, invalidMatchEnd + matchEnd, nodeText, node);
|
|
88
|
+
if (isValid) {
|
|
89
|
+
let linkTextNode;
|
|
90
|
+
if (invalidMatchEnd + matchStart === 0) {
|
|
91
|
+
;
|
|
92
|
+
[linkTextNode, remainingTextNode] = remainingTextNode.splitText(invalidMatchEnd + matchLength);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
;
|
|
96
|
+
[, linkTextNode, remainingTextNode] = remainingTextNode.splitText(invalidMatchEnd + matchStart, invalidMatchEnd + matchStart + matchLength);
|
|
97
|
+
}
|
|
98
|
+
const attributes = {
|
|
99
|
+
url: match.url,
|
|
100
|
+
linkType: 'custom',
|
|
101
|
+
...match.attributes,
|
|
102
|
+
};
|
|
103
|
+
const linkNode = $createAutoLinkNode({ attributes });
|
|
104
|
+
const textNode = $createTextNode(match.text);
|
|
105
|
+
textNode.setFormat(linkTextNode.getFormat());
|
|
106
|
+
textNode.setDetail(linkTextNode.getDetail());
|
|
107
|
+
linkNode.append(textNode);
|
|
108
|
+
linkTextNode.replace(linkNode);
|
|
109
|
+
onChange(match.url, null);
|
|
110
|
+
invalidMatchEnd = 0;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
invalidMatchEnd += matchEnd;
|
|
114
|
+
}
|
|
115
|
+
text = text.substring(matchEnd);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function handleLinkEdit(linkNode, matchers, onChange) {
|
|
119
|
+
// Check children are simple text
|
|
120
|
+
const children = linkNode.getChildren();
|
|
121
|
+
const childrenLength = children.length;
|
|
122
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
123
|
+
const child = children[i];
|
|
124
|
+
if (!$isTextNode(child) || !child.isSimpleText()) {
|
|
125
|
+
replaceWithChildren(linkNode);
|
|
126
|
+
onChange(null, linkNode.getAttributes()?.url ?? null);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Check text content fully matches
|
|
131
|
+
const text = linkNode.getTextContent();
|
|
132
|
+
const match = findFirstMatch(text, matchers);
|
|
133
|
+
if (match === null || match.text !== text) {
|
|
134
|
+
replaceWithChildren(linkNode);
|
|
135
|
+
onChange(null, linkNode.getAttributes()?.url ?? null);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// Check neighbors
|
|
139
|
+
if (!isPreviousNodeValid(linkNode) || !isNextNodeValid(linkNode)) {
|
|
140
|
+
replaceWithChildren(linkNode);
|
|
141
|
+
onChange(null, linkNode.getAttributes()?.url ?? null);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const url = linkNode.getAttributes()?.url;
|
|
145
|
+
if (url !== match?.url) {
|
|
146
|
+
const attrs = linkNode.getAttributes();
|
|
147
|
+
attrs.url = match?.url;
|
|
148
|
+
linkNode.setAttributes(attrs);
|
|
149
|
+
onChange(match.url, url ?? null);
|
|
150
|
+
}
|
|
151
|
+
if (match.attributes != null) {
|
|
152
|
+
const rel = linkNode.getAttributes().rel;
|
|
153
|
+
if (rel !== match.attributes.rel) {
|
|
154
|
+
const attrs = linkNode.getAttributes();
|
|
155
|
+
attrs.rel = match.attributes.rel ?? null;
|
|
156
|
+
linkNode.setAttributes(attrs);
|
|
157
|
+
onChange(match.attributes.rel ?? null, rel ?? null);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Bad neighbors are edits in neighbor nodes that make AutoLinks incompatible.
|
|
162
|
+
// Given the creation preconditions, these can only be simple text nodes.
|
|
163
|
+
function handleBadNeighbors(textNode, matchers, onChange) {
|
|
164
|
+
const previousSibling = textNode.getPreviousSibling();
|
|
165
|
+
const nextSibling = textNode.getNextSibling();
|
|
166
|
+
const text = textNode.getTextContent();
|
|
167
|
+
if ($isAutoLinkNode(previousSibling) && !startsWithSeparator(text)) {
|
|
168
|
+
previousSibling.append(textNode);
|
|
169
|
+
handleLinkEdit(previousSibling, matchers, onChange);
|
|
170
|
+
onChange(null, previousSibling.getAttributes()?.url ?? null);
|
|
171
|
+
}
|
|
172
|
+
if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {
|
|
173
|
+
replaceWithChildren(nextSibling);
|
|
174
|
+
handleLinkEdit(nextSibling, matchers, onChange);
|
|
175
|
+
onChange(null, nextSibling.getAttributes()?.url ?? null);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function replaceWithChildren(node) {
|
|
179
|
+
const children = node.getChildren();
|
|
180
|
+
const childrenLength = children.length;
|
|
181
|
+
for (let j = childrenLength - 1; j >= 0; j--) {
|
|
182
|
+
node.insertAfter(children[j]);
|
|
183
|
+
}
|
|
184
|
+
node.remove();
|
|
185
|
+
return children.map((child) => child.getLatest());
|
|
186
|
+
}
|
|
187
|
+
function useAutoLink(editor, matchers, onChange) {
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
if (!editor.hasNodes([AutoLinkNode])) {
|
|
190
|
+
invariant(false, 'LexicalAutoLinkPlugin: AutoLinkNode not registered on editor');
|
|
191
|
+
}
|
|
192
|
+
const onChangeWrapped = (url, prevUrl) => {
|
|
193
|
+
if (onChange != null) {
|
|
194
|
+
onChange(url, prevUrl);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
return mergeRegister(editor.registerNodeTransform(TextNode, (textNode) => {
|
|
198
|
+
const parent = textNode.getParentOrThrow();
|
|
199
|
+
const previous = textNode.getPreviousSibling();
|
|
200
|
+
if ($isAutoLinkNode(parent)) {
|
|
201
|
+
handleLinkEdit(parent, matchers, onChangeWrapped);
|
|
202
|
+
}
|
|
203
|
+
else if (!$isLinkNode(parent)) {
|
|
204
|
+
if (textNode.isSimpleText() &&
|
|
205
|
+
(startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))) {
|
|
206
|
+
handleLinkCreation(textNode, matchers, onChangeWrapped);
|
|
207
|
+
}
|
|
208
|
+
handleBadNeighbors(textNode, matchers, onChangeWrapped);
|
|
209
|
+
}
|
|
210
|
+
}));
|
|
211
|
+
}, [editor, matchers, onChange]);
|
|
212
|
+
}
|
|
213
|
+
export function AutoLinkPlugin({ matchers, onChange, }) {
|
|
214
|
+
const [editor] = useLexicalComposerContext();
|
|
215
|
+
useAutoLink(editor, matchers, onChange);
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=auto-link-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-link-plugin.js","sourceRoot":"","sources":["../../../../../src/field/plugins/link-plugin/auto-link/auto-link-plugin.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElG,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,YAAY,GAEb,MAAM,2BAA2B,CAAA;AAClC,OAAO,SAAS,MAAM,2BAA2B,CAAA;AAcjD,MAAM,UAAU,2BAA2B,CACzC,MAAc,EACd,iBAA2C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI;IAEzD,OAAO,CAAC,IAAY,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/B,IAAI,KAAK,KAAK,IAA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AE,eAAe,CAAC,CAAA;YACzD,CAAC;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,GAIT;IACC,MAAM,CAAC,MAAM,CAAC,GAAG,yBAAyB,EAAE,CAAA;IAC5C,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACvC,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type * as React from 'react';
|
|
9
|
+
export declare function AutoLinkPlugin(): React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/plugins/link-plugin/auto-link/index.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAsBnC,wBAAgB,cAAc,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAElD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createLinkMatcherWithRegExp, AutoLinkPlugin as LexicalAutoLinkPlugin, } from './auto-link-plugin';
|
|
4
|
+
const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
5
|
+
const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
6
|
+
const MATCHERS = [
|
|
7
|
+
createLinkMatcherWithRegExp(URL_REGEX, (text) => {
|
|
8
|
+
return text.startsWith('http') ? text : `https://${text}`;
|
|
9
|
+
}),
|
|
10
|
+
createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {
|
|
11
|
+
return `mailto:${text}`;
|
|
12
|
+
}),
|
|
13
|
+
];
|
|
14
|
+
export function AutoLinkPlugin() {
|
|
15
|
+
return _jsx(LexicalAutoLinkPlugin, { matchers: MATCHERS });
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/field/plugins/link-plugin/auto-link/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAYZ,OAAO,EACL,2BAA2B,EAC3B,cAAc,IAAI,qBAAqB,GACxC,MAAM,oBAAoB,CAAA;AAE3B,MAAM,SAAS,GACb,iHAAiH,CAAA;AAEnH,MAAM,WAAW,GACf,qJAAqJ,CAAA;AAEvJ,MAAM,QAAQ,GAAG;IACf,2BAA2B,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;QAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAA;IAC3D,CAAC,CAAC;IACF,2BAA2B,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE;QAChD,OAAO,UAAU,IAAI,EAAE,CAAA;IACzB,CAAC,CAAC;CACH,CAAA;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,KAAC,qBAAqB,IAAC,QAAQ,EAAE,QAAQ,GAAI,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ClientField, FormState, OptionObject } from 'payload';
|
|
2
|
+
import type { LinkData } from './types';
|
|
3
|
+
export declare const linkOptions: OptionObject[];
|
|
4
|
+
export declare const getFields: (validRelationships: string[]) => ClientField[];
|
|
5
|
+
export declare function getInitialState(data: LinkData | undefined): FormState;
|
|
6
|
+
export declare function isTextValid(value: string | undefined): boolean;
|
|
7
|
+
export declare function validateFields(fields: FormState): {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
fields: FormState;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../../src/field/plugins/link-plugin/link/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkB,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,WAAW,EAAE,YAAY,EASrC,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,oBAAoB,MAAM,EAAE,KAAG,WAAW,EAwCnE,CAAA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAyCrE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE9D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CA2BvF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export const linkOptions = [
|
|
2
|
+
{
|
|
3
|
+
label: 'Custom',
|
|
4
|
+
value: 'custom',
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
label: 'Internal',
|
|
8
|
+
value: 'internal',
|
|
9
|
+
},
|
|
10
|
+
];
|
|
11
|
+
export const getFields = (validRelationships) => [
|
|
12
|
+
{
|
|
13
|
+
name: 'text',
|
|
14
|
+
required: true,
|
|
15
|
+
localized: false,
|
|
16
|
+
label: 'Text',
|
|
17
|
+
type: 'text',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'linkType',
|
|
21
|
+
localized: false,
|
|
22
|
+
options: linkOptions,
|
|
23
|
+
required: true,
|
|
24
|
+
label: 'Type',
|
|
25
|
+
type: 'radio',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'url',
|
|
29
|
+
localized: false,
|
|
30
|
+
required: true,
|
|
31
|
+
label: 'URL',
|
|
32
|
+
type: 'text',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'doc',
|
|
36
|
+
localized: false,
|
|
37
|
+
required: true,
|
|
38
|
+
type: 'relationship',
|
|
39
|
+
label: 'Related',
|
|
40
|
+
relationTo: validRelationships,
|
|
41
|
+
admin: {
|
|
42
|
+
allowCreate: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'newTab',
|
|
47
|
+
localized: false,
|
|
48
|
+
label: 'Open in new tab',
|
|
49
|
+
type: 'checkbox',
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
export function getInitialState(data) {
|
|
53
|
+
return {
|
|
54
|
+
version: {
|
|
55
|
+
value: '',
|
|
56
|
+
initialValue: '',
|
|
57
|
+
valid: true,
|
|
58
|
+
},
|
|
59
|
+
text: {
|
|
60
|
+
value: data?.text,
|
|
61
|
+
initialValue: data?.text,
|
|
62
|
+
valid: true,
|
|
63
|
+
},
|
|
64
|
+
linkType: {
|
|
65
|
+
value: data?.fields?.linkType ?? 'custom',
|
|
66
|
+
initialValue: data?.fields?.linkType ?? 'custom',
|
|
67
|
+
valid: true,
|
|
68
|
+
},
|
|
69
|
+
url: {
|
|
70
|
+
value: data?.fields?.url,
|
|
71
|
+
initialValue: data?.fields?.url,
|
|
72
|
+
valid: true,
|
|
73
|
+
passesCondition: data?.fields?.linkType === 'custom',
|
|
74
|
+
},
|
|
75
|
+
doc: {
|
|
76
|
+
value: data?.fields.doc != null
|
|
77
|
+
? { value: data.fields.doc.value, relationTo: data.fields.doc.relationTo }
|
|
78
|
+
: {},
|
|
79
|
+
initialValue: data?.fields.doc != null
|
|
80
|
+
? { value: data.fields.doc.value, relationTo: data.fields.doc.relationTo }
|
|
81
|
+
: {},
|
|
82
|
+
valid: true,
|
|
83
|
+
passesCondition: data?.fields?.linkType === 'internal',
|
|
84
|
+
},
|
|
85
|
+
newTab: {
|
|
86
|
+
value: data?.fields?.newTab ?? false,
|
|
87
|
+
initialValue: data?.fields?.newTab ?? false,
|
|
88
|
+
valid: true,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function isTextValid(value) {
|
|
93
|
+
return value != null && value.length > 0;
|
|
94
|
+
}
|
|
95
|
+
export function validateFields(fields) {
|
|
96
|
+
let valid = true;
|
|
97
|
+
if (fields.text != null) {
|
|
98
|
+
if (isTextValid(fields.text?.value) === false) {
|
|
99
|
+
fields.text.valid = false;
|
|
100
|
+
valid = false;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
fields.text.valid = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (fields.linkType != null && fields.linkType?.value === 'custom') {
|
|
107
|
+
fields.url.passesCondition = true;
|
|
108
|
+
fields.doc.passesCondition = false;
|
|
109
|
+
}
|
|
110
|
+
if (fields.linkType != null && fields.linkType?.value === 'internal') {
|
|
111
|
+
fields.url.passesCondition = false;
|
|
112
|
+
fields.doc.passesCondition = true;
|
|
113
|
+
}
|
|
114
|
+
// Return
|
|
115
|
+
return {
|
|
116
|
+
valid,
|
|
117
|
+
fields,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../src/field/plugins/link-plugin/link/fields.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,WAAW,GAAmB;IACzC;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,UAAU;KAClB;CACF,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,kBAA4B,EAAiB,EAAE,CAAC;IACxE;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,MAAM;KACb;IACD;QACE,IAAI,EAAE,UAAU;QAChB,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,WAAW;QACpB,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,OAAO;KACd;IACD;QACE,IAAI,EAAE,KAAK;QACX,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,MAAM;KACb;IACD;QACE,IAAI,EAAE,KAAK;QACX,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,kBAAsC;QAClD,KAAK,EAAE;YACL,WAAW,EAAE,KAAK;SACnB;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,iBAAiB;QACxB,IAAI,EAAE,UAAU;KACjB;CACF,CAAA;AAED,MAAM,UAAU,eAAe,CAAC,IAA0B;IACxD,OAAO;QACL,OAAO,EAAE;YACP,KAAK,EAAE,EAAE;YACT,YAAY,EAAE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-width: 400px;
|
|
7
|
+
width: 100%;
|
|
8
|
+
opacity: 0;
|
|
9
|
+
background-color: #fff;
|
|
10
|
+
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
|
11
|
+
border-radius: 6px;
|
|
12
|
+
transition: opacity 0.5s;
|
|
13
|
+
will-change: transform;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.link-editor .button {
|
|
17
|
+
width: 20px;
|
|
18
|
+
height: 20px;
|
|
19
|
+
display: inline-block;
|
|
20
|
+
padding: 6px;
|
|
21
|
+
border-radius: 6px;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
margin: 0 2px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.link-editor .button.hovered {
|
|
27
|
+
width: 20px;
|
|
28
|
+
height: 20px;
|
|
29
|
+
display: inline-block;
|
|
30
|
+
background-color: #eee;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.link-editor .button i,
|
|
34
|
+
.actions i {
|
|
35
|
+
background-size: contain;
|
|
36
|
+
display: inline-block;
|
|
37
|
+
height: 20px;
|
|
38
|
+
width: 20px;
|
|
39
|
+
vertical-align: -0.25em;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.link-editor .button.active,
|
|
43
|
+
.toolbar .button.active {
|
|
44
|
+
background-color: rgb(223, 232, 250);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.link-editor .link-input {
|
|
48
|
+
display: block;
|
|
49
|
+
min-height: 26px;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
margin: 8px 4px 8px 10px;
|
|
52
|
+
padding: 2px;
|
|
53
|
+
border-radius: 8px;
|
|
54
|
+
background-color: #eee;
|
|
55
|
+
font-size: 15px;
|
|
56
|
+
color: rgb(5, 5, 5);
|
|
57
|
+
border: 0;
|
|
58
|
+
outline: 0;
|
|
59
|
+
position: relative;
|
|
60
|
+
font-family: inherit;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.link-editor .link-view a {
|
|
64
|
+
display: block;
|
|
65
|
+
word-break: break-word;
|
|
66
|
+
width: calc(100% - 33px);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.link-editor div.link-edit {
|
|
70
|
+
background-image: url(../../../images/icons/pencil-fill.svg);
|
|
71
|
+
background-size: 16px;
|
|
72
|
+
background-position: center;
|
|
73
|
+
background-repeat: no-repeat;
|
|
74
|
+
width: 35px;
|
|
75
|
+
vertical-align: -0.25em;
|
|
76
|
+
position: absolute;
|
|
77
|
+
right: 30px;
|
|
78
|
+
top: 0;
|
|
79
|
+
bottom: 0;
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.link-editor div.link-trash {
|
|
84
|
+
background-image: url(../../../images/icons/trash.svg);
|
|
85
|
+
background-size: 16px;
|
|
86
|
+
background-position: center;
|
|
87
|
+
background-repeat: no-repeat;
|
|
88
|
+
width: 35px;
|
|
89
|
+
vertical-align: -0.25em;
|
|
90
|
+
position: absolute;
|
|
91
|
+
right: 0;
|
|
92
|
+
top: 0;
|
|
93
|
+
bottom: 0;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.link-editor .link-input a {
|
|
98
|
+
color: rgb(33, 111, 219);
|
|
99
|
+
text-decoration: none;
|
|
100
|
+
display: block;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
margin-right: 30px;
|
|
104
|
+
text-overflow: ellipsis;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.link-editor .link-input a:hover {
|
|
108
|
+
text-decoration: underline;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.link-editor .font-size-wrapper,
|
|
112
|
+
.link-editor .font-family-wrapper {
|
|
113
|
+
display: flex;
|
|
114
|
+
margin: 0 4px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.link-editor select {
|
|
118
|
+
padding: 6px;
|
|
119
|
+
border: none;
|
|
120
|
+
background-color: rgba(0, 0, 0, 0.075);
|
|
121
|
+
border-radius: 4px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
html[data-theme="dark"] {
|
|
125
|
+
.link-editor {
|
|
126
|
+
background-color: var(--theme-elevation-100);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type * as React from 'react';
|
|
9
|
+
import './floating-link-editor.css';
|
|
10
|
+
export declare function FloatingLinkEditorPlugin({ anchorElem, }: {
|
|
11
|
+
anchorElem?: HTMLElement;
|
|
12
|
+
}): React.JSX.Element | null;
|
|
13
|
+
//# sourceMappingURL=floating-link-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating-link-editor.d.ts","sourceRoot":"","sources":["../../../../../src/field/plugins/link-plugin/link/floating-link-editor.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AA8BnC,OAAO,4BAA4B,CAAA;AAkVnC,wBAAgB,wBAAwB,CAAC,EACvC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAG3B"}
|