@byline/richtext-lexical 1.11.1 → 1.12.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/dist/field/apply-value-plugin.js +1 -3
- package/dist/field/config/default-extensions.d.ts +32 -0
- package/dist/field/config/default-extensions.js +49 -0
- package/dist/field/config/default.d.ts +8 -0
- package/dist/field/config/default.js +0 -28
- package/dist/field/config/editor-config-context.js +2 -6
- package/dist/field/config/extensions-list.d.ts +44 -0
- package/dist/field/config/extensions-list.js +55 -0
- package/dist/field/config/types.d.ts +28 -1
- package/dist/field/editor-context.d.ts +1 -1
- package/dist/field/editor-context.js +39 -35
- package/dist/field/editor.js +11 -57
- package/dist/field/{plugins/admonition-plugin/index.d.ts → extensions/admonition/admonition-extension.d.ts} +2 -1
- package/dist/field/{plugins/admonition-plugin/index.js → extensions/admonition/admonition-extension.js} +51 -4
- package/dist/field/{nodes/admonition-node → extensions/admonition}/admonition-node-component.d.ts +1 -1
- package/dist/field/{nodes/admonition-node → extensions/admonition}/admonition-node-component.js +1 -1
- package/dist/field/{nodes/admonition-node → extensions/admonition}/admonition-node.d.ts +1 -1
- package/dist/field/{plugins/admonition-plugin → extensions/admonition}/fields.d.ts +1 -1
- package/dist/field/{nodes/admonition-node → extensions/admonition}/index.js +1 -1
- package/dist/field/{plugins/admonition-plugin → extensions/admonition}/types.d.ts +1 -1
- package/dist/field/{plugins/auto-embed-plugin/index.d.ts → extensions/auto-embed/auto-embed-extension.d.ts} +1 -0
- package/dist/field/{plugins/auto-embed-plugin/index.js → extensions/auto-embed/auto-embed-extension.js} +47 -4
- package/dist/field/{plugins/auto-embed-plugin → extensions/auto-embed}/auto-embed-modal.d.ts +1 -1
- package/dist/field/extensions/byline-floating-ui/byline-floating-ui-extension.d.ts +68 -0
- package/dist/field/extensions/byline-floating-ui/byline-floating-ui-extension.js +19 -0
- package/dist/field/{nodes/admonition-node → extensions/byline-floating-ui}/index.d.ts +1 -2
- package/dist/field/extensions/byline-floating-ui/index.js +1 -0
- package/dist/field/extensions/byline-toolbar/byline-toolbar-extension.d.ts +69 -0
- package/dist/field/extensions/byline-toolbar/byline-toolbar-extension.js +19 -0
- package/dist/field/{nodes/inline-image-node → extensions/byline-toolbar}/index.d.ts +1 -2
- package/dist/field/extensions/byline-toolbar/index.js +1 -0
- package/dist/field/extensions/code-highlight/code-highlight-extension.d.ts +10 -0
- package/dist/field/extensions/code-highlight/code-highlight-extension.js +11 -0
- package/dist/field/extensions/floating-text-format/floating-text-format-extension.d.ts +18 -0
- package/dist/field/extensions/floating-text-format/floating-text-format-extension.js +17 -0
- package/dist/field/{plugins/floating-text-format-toolbar-plugin → extensions/floating-text-format}/index.js +1 -1
- package/dist/field/extensions/horizontal-rule/horizontal-rule-extension.d.ts +6 -0
- package/dist/field/extensions/horizontal-rule/horizontal-rule-extension.js +45 -0
- package/dist/field/{nodes/inline-image-node → extensions/inline-image}/index.js +1 -1
- package/dist/field/{plugins/inline-image-plugin/index.d.ts → extensions/inline-image/inline-image-extension.d.ts} +6 -3
- package/dist/field/{plugins/inline-image-plugin/index.js → extensions/inline-image/inline-image-extension.js} +57 -5
- package/dist/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node-component.d.ts +2 -2
- package/dist/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node-component.js +4 -4
- package/dist/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node.d.ts +2 -2
- package/dist/field/{nodes/inline-image-node/types.d.ts → extensions/inline-image/node-types.d.ts} +1 -1
- package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/types.d.ts +1 -1
- package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/utils.d.ts +1 -1
- package/dist/field/{plugins/layout-plugin/layout-plugin.d.ts → extensions/layout/layout-extension.d.ts} +1 -0
- package/dist/field/{plugins/layout-plugin/layout-plugin.js → extensions/layout/layout-extension.js} +53 -5
- package/dist/field/extensions/link/auto-link-extension.d.ts +12 -0
- package/dist/field/{plugins/link-plugin/auto-link/index.js → extensions/link/auto-link-extension.js} +14 -2
- package/dist/field/{plugins/link-plugin/auto-link → extensions/link}/auto-link-plugin.d.ts +1 -1
- package/dist/field/{plugins/link-plugin/auto-link → extensions/link}/auto-link-plugin.js +2 -2
- package/dist/field/{plugins/link-plugin → extensions}/link/floating-link-editor.css +2 -2
- package/dist/field/{plugins/link-plugin → extensions}/link/floating-link-editor.js +4 -4
- package/dist/field/extensions/link/index.d.ts +5 -0
- package/dist/field/extensions/link/index.js +5 -0
- package/dist/field/extensions/link/link-extension.d.ts +14 -0
- package/dist/field/extensions/link/link-extension.js +66 -0
- package/dist/field/{plugins/link-plugin/link/types.d.ts → extensions/link/link-modal-types.d.ts} +1 -1
- package/dist/field/{plugins/link-plugin → extensions}/link/link-modal.d.ts +1 -1
- package/dist/field/{plugins/link-plugin → extensions}/link/link-modal.js +3 -3
- package/dist/field/{nodes/link-nodes → extensions/link}/types.d.ts +1 -1
- package/dist/field/extensions/table/table-action-menu-plugin/index.d.ts +4 -0
- package/dist/field/{plugins → extensions/table}/table-action-menu-plugin/index.js +8 -6
- package/dist/field/extensions/table/table-extension.d.ts +17 -0
- package/dist/field/extensions/table/table-extension.js +58 -0
- package/dist/field/extensions/vimeo/vimeo-extension.d.ts +12 -0
- package/dist/field/extensions/vimeo/vimeo-extension.js +16 -0
- package/dist/field/extensions/youtube/youtube-extension.d.ts +12 -0
- package/dist/field/extensions/youtube/youtube-extension.js +16 -0
- package/dist/field/nodes/index.js +7 -7
- package/dist/field/plugins/table-plugin/index.js +5 -6
- package/dist/field/plugins/toolbar-plugin/index.js +40 -114
- package/dist/field/plugins/toolbar-plugin/toolbar-active-editor.d.ts +25 -0
- package/dist/field/plugins/toolbar-plugin/toolbar-active-editor.js +17 -0
- package/dist/field/themes/lexical-editor-theme.css +13 -3
- package/dist/field/themes/lexical-editor-theme.js +1 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +16 -0
- package/dist/lexical-editor.d.ts +25 -13
- package/dist/lexical-editor.js +9 -1
- package/dist/richtext-field.js +6 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/package.json +7 -10
- package/src/field/apply-value-plugin.tsx +6 -6
- package/src/field/config/default-extensions.ts +104 -0
- package/src/field/config/default.ts +8 -28
- package/src/field/config/editor-config-context.tsx +1 -7
- package/src/field/config/extensions-list.ts +107 -0
- package/src/field/config/types.ts +28 -28
- package/src/field/editor-context.tsx +77 -41
- package/src/field/editor.tsx +24 -72
- package/src/field/extensions/README.md +31 -0
- package/src/field/{plugins/admonition-plugin/index.tsx → extensions/admonition/admonition-extension.tsx} +45 -2
- package/src/field/{plugins/admonition-plugin → extensions/admonition}/admonition-modal.tsx +1 -1
- package/src/field/{nodes/admonition-node → extensions/admonition}/admonition-node-component.tsx +5 -5
- package/src/field/{nodes/admonition-node → extensions/admonition}/admonition-node.tsx +1 -1
- package/src/field/{plugins/admonition-plugin → extensions/admonition}/fields.ts +1 -1
- package/src/field/{nodes/admonition-node → extensions/admonition}/index.ts +5 -1
- package/src/field/{plugins/admonition-plugin → extensions/admonition}/types.ts +1 -1
- package/src/field/{plugins/auto-embed-plugin/index.tsx → extensions/auto-embed/auto-embed-extension.tsx} +46 -3
- package/src/field/{plugins/auto-embed-plugin → extensions/auto-embed}/auto-embed-modal.tsx +1 -1
- package/src/field/extensions/byline-floating-ui/byline-floating-ui-extension.ts +90 -0
- package/src/field/extensions/byline-floating-ui/index.ts +15 -0
- package/src/field/extensions/byline-toolbar/byline-toolbar-extension.ts +95 -0
- package/src/field/extensions/byline-toolbar/index.ts +15 -0
- package/src/field/extensions/code-highlight/code-highlight-extension.ts +18 -0
- package/src/field/extensions/floating-text-format/floating-text-format-extension.ts +39 -0
- package/src/field/{plugins/floating-text-format-toolbar-plugin → extensions/floating-text-format}/index.tsx +1 -1
- package/src/field/extensions/horizontal-rule/horizontal-rule-extension.tsx +57 -0
- package/src/field/{nodes/inline-image-node → extensions/inline-image}/index.ts +1 -1
- package/src/field/{plugins/inline-image-plugin/index.tsx → extensions/inline-image/inline-image-extension.tsx} +54 -6
- package/src/field/{plugins/inline-image-plugin → extensions/inline-image}/inline-image-modal.tsx +1 -1
- package/src/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node-component.tsx +6 -6
- package/src/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node.tsx +2 -2
- package/src/field/{nodes/inline-image-node/types.ts → extensions/inline-image/node-types.ts} +1 -1
- package/src/field/{plugins/inline-image-plugin → extensions/inline-image}/types.ts +1 -1
- package/src/field/{plugins/inline-image-plugin → extensions/inline-image}/utils.ts +1 -1
- package/src/field/{plugins/layout-plugin/layout-plugin.tsx → extensions/layout/layout-extension.tsx} +47 -8
- package/src/field/{plugins/link-plugin/auto-link/index.tsx → extensions/link/auto-link-extension.tsx} +13 -3
- package/src/field/{plugins/link-plugin/auto-link → extensions/link}/auto-link-plugin.tsx +2 -2
- package/src/field/{plugins/link-plugin → extensions}/link/floating-link-editor.css +2 -2
- package/src/field/{plugins/link-plugin → extensions}/link/floating-link-editor.tsx +5 -5
- package/src/field/extensions/link/index.ts +5 -0
- package/src/field/extensions/link/link-extension.tsx +131 -0
- package/src/field/{plugins/link-plugin/link/types.ts → extensions/link/link-modal-types.ts} +1 -1
- package/src/field/{plugins/link-plugin → extensions}/link/link-modal.tsx +6 -6
- package/src/field/{nodes/link-nodes → extensions/link}/types.ts +1 -1
- package/src/field/{plugins → extensions/table}/table-action-menu-plugin/index.tsx +12 -8
- package/src/field/extensions/table/table-extension.tsx +86 -0
- package/src/field/extensions/vimeo/vimeo-extension.ts +36 -0
- package/src/field/extensions/youtube/youtube-extension.ts +37 -0
- package/src/field/nodes/index.ts +7 -7
- package/src/field/plugins/table-plugin/index.tsx +10 -10
- package/src/field/plugins/toolbar-plugin/index.tsx +59 -122
- package/src/field/plugins/toolbar-plugin/toolbar-active-editor.tsx +48 -0
- package/src/field/themes/lexical-editor-theme.css +18 -3
- package/src/field/themes/lexical-editor-theme.tsx +1 -0
- package/src/index.ts +45 -2
- package/src/lexical-editor.tsx +35 -14
- package/src/richtext-field.tsx +8 -1
- package/src/server.ts +4 -4
- package/dist/field/nodes/link-nodes/index.d.ts +0 -3
- package/dist/field/nodes/link-nodes/index.js +0 -3
- package/dist/field/plugins/code-highlight-plugin/index.d.ts +0 -9
- package/dist/field/plugins/code-highlight-plugin/index.js +0 -11
- package/dist/field/plugins/link-plugin/auto-link/index.d.ts +0 -9
- package/dist/field/plugins/link-plugin/link/index.d.ts +0 -1
- package/dist/field/plugins/link-plugin/link/index.js +0 -43
- package/dist/field/plugins/table-action-menu-plugin/index.d.ts +0 -5
- package/dist/field/plugins/vimeo-plugin/index.d.ts +0 -3
- package/dist/field/plugins/vimeo-plugin/index.js +0 -24
- package/dist/field/plugins/youtube-plugin/index.d.ts +0 -3
- package/dist/field/plugins/youtube-plugin/index.js +0 -24
- package/dist/field/toolbar-extensions.d.ts +0 -31
- package/dist/field/toolbar-extensions.js +0 -56
- package/src/field/nodes/link-nodes/index.ts +0 -3
- package/src/field/plugins/code-highlight-plugin/index.ts +0 -23
- package/src/field/plugins/link-plugin/link/index.tsx +0 -99
- package/src/field/plugins/vimeo-plugin/index.ts +0 -42
- package/src/field/plugins/youtube-plugin/index.ts +0 -43
- package/src/field/themes/lexical-editor-theme.js +0 -104
- package/src/field/toolbar-extensions.tsx +0 -93
- /package/dist/field/{plugins/admonition-plugin → extensions/admonition}/admonition-modal.css +0 -0
- /package/dist/field/{plugins/admonition-plugin → extensions/admonition}/admonition-modal.d.ts +0 -0
- /package/dist/field/{plugins/admonition-plugin → extensions/admonition}/admonition-modal.js +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/admonition-node-component.css +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/admonition-node.js +0 -0
- /package/dist/field/{plugins/admonition-plugin → extensions/admonition}/fields.js +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/danger-icon.css +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/danger-icon.d.ts +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/danger-icon.js +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/index.d.ts +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/index.js +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/note-icon.css +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/note-icon.d.ts +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/note-icon.js +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/tip-icon.css +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/tip-icon.d.ts +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/tip-icon.js +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/warning-icon.css +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/warning-icon.d.ts +0 -0
- /package/dist/field/{nodes/admonition-node → extensions/admonition}/icons/warning-icon.js +0 -0
- /package/dist/field/{nodes/admonition-node/types.d.ts → extensions/admonition/node-types.d.ts} +0 -0
- /package/dist/field/{nodes/admonition-node/types.js → extensions/admonition/node-types.js} +0 -0
- /package/dist/field/{nodes/inline-image-node → extensions/admonition}/types.js +0 -0
- /package/dist/field/{plugins/auto-embed-plugin → extensions/auto-embed}/auto-embed-modal.css +0 -0
- /package/dist/field/{plugins/auto-embed-plugin → extensions/auto-embed}/auto-embed-modal.js +0 -0
- /package/dist/field/{plugins/floating-text-format-toolbar-plugin → extensions/floating-text-format}/index.css +0 -0
- /package/dist/field/{plugins/floating-text-format-toolbar-plugin → extensions/floating-text-format}/index.d.ts +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/fields.d.ts +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/fields.js +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/inline-image-modal.css +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/inline-image-modal.d.ts +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/inline-image-modal.js +0 -0
- /package/dist/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node-component.css +0 -0
- /package/dist/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node.js +0 -0
- /package/dist/field/{nodes/link-nodes/types.js → extensions/inline-image/node-types.js} +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/populate.d.ts +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/populate.js +0 -0
- /package/dist/field/{plugins/admonition-plugin → extensions/inline-image}/types.js +0 -0
- /package/dist/field/{plugins/inline-image-plugin → extensions/inline-image}/utils.js +0 -0
- /package/dist/field/{plugins/layout-plugin → extensions/layout}/insert-layout-modal.css +0 -0
- /package/dist/field/{plugins/layout-plugin → extensions/layout}/insert-layout-modal.d.ts +0 -0
- /package/dist/field/{plugins/layout-plugin → extensions/layout}/insert-layout-modal.js +0 -0
- /package/dist/field/{nodes/layout-container-node → extensions/layout}/layout-container-node.d.ts +0 -0
- /package/dist/field/{nodes/layout-container-node → extensions/layout}/layout-container-node.js +0 -0
- /package/dist/field/{nodes/layout-container-node → extensions/layout}/layout-item-node.d.ts +0 -0
- /package/dist/field/{nodes/layout-container-node → extensions/layout}/layout-item-node.js +0 -0
- /package/dist/field/{nodes/link-nodes → extensions/link}/auto-link-node.d.ts +0 -0
- /package/dist/field/{nodes/link-nodes → extensions/link}/auto-link-node.js +0 -0
- /package/dist/field/{plugins/link-plugin → extensions}/link/floating-link-editor.d.ts +0 -0
- /package/dist/field/{plugins/inline-image-plugin/types.js → extensions/link/link-modal-types.js} +0 -0
- /package/dist/field/{nodes/link-nodes → extensions/link}/link-node.d.ts +0 -0
- /package/dist/field/{nodes/link-nodes → extensions/link}/link-node.js +0 -0
- /package/dist/field/{plugins/link-plugin → extensions/link}/populate.d.ts +0 -0
- /package/dist/field/{plugins/link-plugin → extensions/link}/populate.js +0 -0
- /package/dist/field/{plugins/link-plugin → extensions}/link/types.js +0 -0
- /package/dist/field/{nodes/vimeo-node/index.d.ts → extensions/vimeo/vimeo-node.d.ts} +0 -0
- /package/dist/field/{nodes/vimeo-node/index.js → extensions/vimeo/vimeo-node.js} +0 -0
- /package/dist/field/{nodes/youtube-node/index.d.ts → extensions/youtube/youtube-node.d.ts} +0 -0
- /package/dist/field/{nodes/youtube-node/index.js → extensions/youtube/youtube-node.js} +0 -0
- /package/src/field/{plugins/admonition-plugin → extensions/admonition}/admonition-modal.css +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/admonition-node-component.css +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/danger-icon.css +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/danger-icon.js +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/danger-icon.tsx +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/index.js +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/index.ts +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/note-icon.css +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/note-icon.js +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/note-icon.tsx +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/tip-icon.css +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/tip-icon.js +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/tip-icon.tsx +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/warning-icon.css +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/warning-icon.js +0 -0
- /package/src/field/{nodes/admonition-node → extensions/admonition}/icons/warning-icon.tsx +0 -0
- /package/src/field/{nodes/admonition-node/types.ts → extensions/admonition/node-types.ts} +0 -0
- /package/src/field/{plugins/auto-embed-plugin → extensions/auto-embed}/auto-embed-modal.css +0 -0
- /package/src/field/{plugins/floating-text-format-toolbar-plugin → extensions/floating-text-format}/index.css +0 -0
- /package/src/field/{plugins/inline-image-plugin → extensions/inline-image}/fields.ts +0 -0
- /package/src/field/{plugins/inline-image-plugin → extensions/inline-image}/inline-image-modal.css +0 -0
- /package/src/field/{nodes/inline-image-node → extensions/inline-image}/inline-image-node-component.css +0 -0
- /package/src/field/{plugins/inline-image-plugin → extensions/inline-image}/populate.ts +0 -0
- /package/src/field/{plugins/layout-plugin → extensions/layout}/insert-layout-modal.css +0 -0
- /package/src/field/{plugins/layout-plugin → extensions/layout}/insert-layout-modal.tsx +0 -0
- /package/src/field/{nodes/layout-container-node → extensions/layout}/layout-container-node.ts +0 -0
- /package/src/field/{nodes/layout-container-node → extensions/layout}/layout-item-node.ts +0 -0
- /package/src/field/{nodes/link-nodes → extensions/link}/auto-link-node.ts +0 -0
- /package/src/field/{nodes/link-nodes → extensions/link}/link-node.ts +0 -0
- /package/src/field/{plugins/link-plugin → extensions/link}/populate.ts +0 -0
- /package/src/field/{nodes/vimeo-node/index.tsx → extensions/vimeo/vimeo-node.tsx} +0 -0
- /package/src/field/{nodes/youtube-node/index.tsx → extensions/youtube/youtube-node.tsx} +0 -0
package/src/richtext-field.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { ErrorText, Label, LocaleBadge, useFieldError, useFieldValue } from '@by
|
|
|
13
13
|
import cx from 'classnames'
|
|
14
14
|
|
|
15
15
|
import { defaultEditorConfig } from './field/config/default'
|
|
16
|
+
import { defaultExtensionsList } from './field/config/default-extensions'
|
|
16
17
|
import { EditorField } from './field/editor-field'
|
|
17
18
|
import styles from './richtext-field.module.css'
|
|
18
19
|
import type { EditorConfig } from './field/config/types'
|
|
@@ -74,8 +75,14 @@ export const RichTextField = ({
|
|
|
74
75
|
// 3. `defaultEditorConfig` — package default.
|
|
75
76
|
// The schema-level value is typed as `unknown` at the `@byline/core` boundary,
|
|
76
77
|
// so the cast lives here where the Lexical config shape is known.
|
|
77
|
-
const
|
|
78
|
+
const resolved: EditorConfig =
|
|
78
79
|
(field.editorConfig as EditorConfig | undefined) ?? editorConfig ?? defaultEditorConfig
|
|
80
|
+
// Schema-side configs and the server-safe `defaultEditorConfig` carry no
|
|
81
|
+
// `extensions` field — extension references aren't JSON-safe. Materialise
|
|
82
|
+
// the package's client-only default list when one isn't already present so
|
|
83
|
+
// every render has a complete graph to feed `EditorContext`.
|
|
84
|
+
const baseEditorConfig: EditorConfig =
|
|
85
|
+
resolved.extensions != null ? resolved : { ...resolved, extensions: defaultExtensionsList() }
|
|
79
86
|
|
|
80
87
|
// Adapter-agnostic field-level lever — when present, override the resolved
|
|
81
88
|
// editor settings so the inline-image / link modals see this field's policy.
|
package/src/server.ts
CHANGED
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
import type { BylineClient } from '@byline/client'
|
|
31
31
|
import type { RichTextPopulateContext, RichTextPopulateFn } from '@byline/core'
|
|
32
32
|
|
|
33
|
+
import { inlineImageVisitor } from './field/extensions/inline-image/populate'
|
|
34
|
+
import { linkVisitor } from './field/extensions/link/populate'
|
|
33
35
|
import { type LexicalNodeVisitor, runLexicalPopulate } from './field/lexical-populate-shared'
|
|
34
|
-
import { inlineImageVisitor } from './field/plugins/inline-image-plugin/populate'
|
|
35
|
-
import { linkVisitor } from './field/plugins/link-plugin/populate'
|
|
36
36
|
|
|
37
37
|
// ---------------------------------------------------------------------------
|
|
38
38
|
// Schema-data re-exports — data-only Lexical config that's safe to evaluate
|
|
@@ -41,8 +41,8 @@ import { linkVisitor } from './field/plugins/link-plugin/populate'
|
|
|
41
41
|
// their CSS imports; the `/server` subpath stays React-free.
|
|
42
42
|
// ---------------------------------------------------------------------------
|
|
43
43
|
export { defaultEditorConfig } from './field/config/default'
|
|
44
|
-
export { inlineImageVisitor } from './field/
|
|
45
|
-
export { linkVisitor } from './field/
|
|
44
|
+
export { inlineImageVisitor } from './field/extensions/inline-image/populate'
|
|
45
|
+
export { linkVisitor } from './field/extensions/link/populate'
|
|
46
46
|
export type { EditorConfig, EditorSettings, EditorSettingsOverride } from './field/config/types'
|
|
47
47
|
export type {
|
|
48
48
|
LexicalNodeLike,
|
|
@@ -1,9 +0,0 @@
|
|
|
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 CodeHighlightPlugin(): React.JSX.Element | null;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { registerCodeHighlighting } from "@lexical/code";
|
|
3
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
4
|
-
function CodeHighlightPlugin() {
|
|
5
|
-
const [editor] = useLexicalComposerContext();
|
|
6
|
-
useEffect(()=>registerCodeHighlighting(editor), [
|
|
7
|
-
editor
|
|
8
|
-
]);
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
export { CodeHighlightPlugin };
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function LinkPlugin(): null;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
4
|
-
import { mergeRegister } from "@lexical/utils";
|
|
5
|
-
import { $getSelection, $isElementNode, $isRangeSelection, COMMAND_PRIORITY_LOW, PASTE_COMMAND } from "lexical";
|
|
6
|
-
import { $toggleLink, LinkNode, TOGGLE_LINK_COMMAND } from "../../../nodes/link-nodes/index.js";
|
|
7
|
-
import { validateUrl } from "../../../utils/url.js";
|
|
8
|
-
function LinkPlugin() {
|
|
9
|
-
const [editor] = useLexicalComposerContext();
|
|
10
|
-
useEffect(()=>{
|
|
11
|
-
if (!editor.hasNodes([
|
|
12
|
-
LinkNode
|
|
13
|
-
])) throw new Error('LinkPlugin: LinkNode not registered on editor');
|
|
14
|
-
return mergeRegister(editor.registerCommand(TOGGLE_LINK_COMMAND, (payload)=>{
|
|
15
|
-
if (null === payload) {
|
|
16
|
-
$toggleLink(payload);
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
if ('custom' === payload.linkType) {
|
|
20
|
-
const url = payload.url ?? '';
|
|
21
|
-
if (!url.startsWith('/') && !validateUrl(url)) return false;
|
|
22
|
-
}
|
|
23
|
-
$toggleLink(payload);
|
|
24
|
-
return true;
|
|
25
|
-
}, COMMAND_PRIORITY_LOW), editor.registerCommand(PASTE_COMMAND, (event)=>{
|
|
26
|
-
const selection = $getSelection();
|
|
27
|
-
if (!$isRangeSelection(selection) || selection.isCollapsed() || !(event instanceof ClipboardEvent) || null == event.clipboardData) return false;
|
|
28
|
-
const clipboardText = event.clipboardData.getData('text');
|
|
29
|
-
if (!validateUrl(clipboardText)) return false;
|
|
30
|
-
if (selection.getNodes().some((node)=>$isElementNode(node))) return false;
|
|
31
|
-
editor.dispatchCommand(TOGGLE_LINK_COMMAND, {
|
|
32
|
-
linkType: 'custom',
|
|
33
|
-
url: clipboardText
|
|
34
|
-
});
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
return true;
|
|
37
|
-
}, COMMAND_PRIORITY_LOW));
|
|
38
|
-
}, [
|
|
39
|
-
editor
|
|
40
|
-
]);
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
export { LinkPlugin };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
4
|
-
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
5
|
-
import { COMMAND_PRIORITY_EDITOR, createCommand } from "lexical";
|
|
6
|
-
import { $createVimeoNode, VimeoNode } from "../../nodes/vimeo-node/index.js";
|
|
7
|
-
const INSERT_VIMEO_COMMAND = createCommand('INSERT_VIMEO_COMMAND');
|
|
8
|
-
function VimeoPlugin() {
|
|
9
|
-
const [editor] = useLexicalComposerContext();
|
|
10
|
-
useEffect(()=>{
|
|
11
|
-
if (!editor.hasNodes([
|
|
12
|
-
VimeoNode
|
|
13
|
-
])) throw new Error('VimeoPlugin: VimeoNode not registered on editor');
|
|
14
|
-
return editor.registerCommand(INSERT_VIMEO_COMMAND, (payload)=>{
|
|
15
|
-
const vimeoNode = $createVimeoNode(payload);
|
|
16
|
-
$insertNodeToNearestRoot(vimeoNode);
|
|
17
|
-
return true;
|
|
18
|
-
}, COMMAND_PRIORITY_EDITOR);
|
|
19
|
-
}, [
|
|
20
|
-
editor
|
|
21
|
-
]);
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
export { INSERT_VIMEO_COMMAND, VimeoPlugin };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
4
|
-
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
5
|
-
import { COMMAND_PRIORITY_EDITOR, createCommand } from "lexical";
|
|
6
|
-
import { $createYouTubeNode, YouTubeNode } from "../../nodes/youtube-node/index.js";
|
|
7
|
-
const INSERT_YOUTUBE_COMMAND = createCommand('INSERT_YOUTUBE_COMMAND');
|
|
8
|
-
function YouTubePlugin() {
|
|
9
|
-
const [editor] = useLexicalComposerContext();
|
|
10
|
-
useEffect(()=>{
|
|
11
|
-
if (!editor.hasNodes([
|
|
12
|
-
YouTubeNode
|
|
13
|
-
])) throw new Error('YouTubePlugin: YouTubeNode not registered on editor');
|
|
14
|
-
return editor.registerCommand(INSERT_YOUTUBE_COMMAND, (payload)=>{
|
|
15
|
-
const youTubeNode = $createYouTubeNode(payload);
|
|
16
|
-
$insertNodeToNearestRoot(youTubeNode);
|
|
17
|
-
return true;
|
|
18
|
-
}, COMMAND_PRIORITY_EDITOR);
|
|
19
|
-
}, [
|
|
20
|
-
editor
|
|
21
|
-
]);
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
export { INSERT_YOUTUBE_COMMAND, YouTubePlugin };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
|
-
import type * as React from 'react';
|
|
9
|
-
import { type LexicalEditor } from 'lexical';
|
|
10
|
-
export type ToolbarExtensionItem = {
|
|
11
|
-
id: string;
|
|
12
|
-
order?: number;
|
|
13
|
-
node: React.ReactNode;
|
|
14
|
-
};
|
|
15
|
-
type ToolbarExtensionsContextType = {
|
|
16
|
-
items: ToolbarExtensionItem[];
|
|
17
|
-
register: (item: ToolbarExtensionItem) => () => void;
|
|
18
|
-
/**
|
|
19
|
-
* The editor instance for the current selection. This matters when using nested composers.
|
|
20
|
-
*/
|
|
21
|
-
editor: LexicalEditor;
|
|
22
|
-
/**
|
|
23
|
-
* The root editor instance for this composer.
|
|
24
|
-
*/
|
|
25
|
-
rootEditor: LexicalEditor;
|
|
26
|
-
};
|
|
27
|
-
export declare function ToolbarExtensionsProvider({ children, }: {
|
|
28
|
-
children: React.ReactNode;
|
|
29
|
-
}): React.JSX.Element;
|
|
30
|
-
export declare function useToolbarExtensions(): ToolbarExtensionsContextType;
|
|
31
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
4
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
5
|
-
import { COMMAND_PRIORITY_CRITICAL, SELECTION_CHANGE_COMMAND } from "lexical";
|
|
6
|
-
const ToolbarExtensionsContext = /*#__PURE__*/ createContext(null);
|
|
7
|
-
function ToolbarExtensionsProvider({ children }) {
|
|
8
|
-
const [rootEditor] = useLexicalComposerContext();
|
|
9
|
-
const [activeEditor, setActiveEditor] = useState(rootEditor);
|
|
10
|
-
const [itemsById, setItemsById] = useState(()=>new Map());
|
|
11
|
-
useEffect(()=>rootEditor.registerCommand(SELECTION_CHANGE_COMMAND, (_payload, newEditor)=>{
|
|
12
|
-
setActiveEditor(newEditor);
|
|
13
|
-
return false;
|
|
14
|
-
}, COMMAND_PRIORITY_CRITICAL), [
|
|
15
|
-
rootEditor
|
|
16
|
-
]);
|
|
17
|
-
const register = useCallback((item)=>{
|
|
18
|
-
setItemsById((prev)=>{
|
|
19
|
-
const next = new Map(prev);
|
|
20
|
-
next.set(item.id, item);
|
|
21
|
-
return next;
|
|
22
|
-
});
|
|
23
|
-
return ()=>{
|
|
24
|
-
setItemsById((prev)=>{
|
|
25
|
-
if (!prev.has(item.id)) return prev;
|
|
26
|
-
const next = new Map(prev);
|
|
27
|
-
next.delete(item.id);
|
|
28
|
-
return next;
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
32
|
-
const items = useMemo(()=>Array.from(itemsById.values()), [
|
|
33
|
-
itemsById
|
|
34
|
-
]);
|
|
35
|
-
const value = useMemo(()=>({
|
|
36
|
-
items,
|
|
37
|
-
register,
|
|
38
|
-
editor: activeEditor,
|
|
39
|
-
rootEditor
|
|
40
|
-
}), [
|
|
41
|
-
items,
|
|
42
|
-
register,
|
|
43
|
-
activeEditor,
|
|
44
|
-
rootEditor
|
|
45
|
-
]);
|
|
46
|
-
return /*#__PURE__*/ jsx(ToolbarExtensionsContext.Provider, {
|
|
47
|
-
value: value,
|
|
48
|
-
children: children
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function useToolbarExtensions() {
|
|
52
|
-
const context = useContext(ToolbarExtensionsContext);
|
|
53
|
-
if (null == context) throw new Error('useToolbarExtensions must be used within a ToolbarExtensionsProvider');
|
|
54
|
-
return context;
|
|
55
|
-
}
|
|
56
|
-
export { ToolbarExtensionsProvider, useToolbarExtensions };
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
|
|
9
|
-
import type * as React from 'react'
|
|
10
|
-
import { useEffect } from 'react'
|
|
11
|
-
|
|
12
|
-
import { registerCodeHighlighting } from '@lexical/code'
|
|
13
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
|
|
14
|
-
|
|
15
|
-
export function CodeHighlightPlugin(): React.JSX.Element | null {
|
|
16
|
-
const [editor] = useLexicalComposerContext()
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
return registerCodeHighlighting(editor)
|
|
20
|
-
}, [editor])
|
|
21
|
-
|
|
22
|
-
return null
|
|
23
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
5
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) Infonomic Company Limited
|
|
9
|
-
*
|
|
10
|
-
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { useEffect } from 'react'
|
|
14
|
-
|
|
15
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
|
|
16
|
-
import { mergeRegister } from '@lexical/utils'
|
|
17
|
-
import {
|
|
18
|
-
$getSelection,
|
|
19
|
-
$isElementNode,
|
|
20
|
-
$isRangeSelection,
|
|
21
|
-
COMMAND_PRIORITY_LOW,
|
|
22
|
-
PASTE_COMMAND,
|
|
23
|
-
} from 'lexical'
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
$toggleLink,
|
|
27
|
-
type LinkAttributes,
|
|
28
|
-
LinkNode,
|
|
29
|
-
TOGGLE_LINK_COMMAND,
|
|
30
|
-
} from '../../../nodes/link-nodes'
|
|
31
|
-
import { validateUrl } from '../../../utils/url'
|
|
32
|
-
|
|
33
|
-
export function LinkPlugin(): null {
|
|
34
|
-
const [editor] = useLexicalComposerContext()
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (!editor.hasNodes([LinkNode])) {
|
|
38
|
-
throw new Error('LinkPlugin: LinkNode not registered on editor')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return mergeRegister(
|
|
42
|
-
editor.registerCommand(
|
|
43
|
-
TOGGLE_LINK_COMMAND,
|
|
44
|
-
(payload: LinkAttributes | null) => {
|
|
45
|
-
if (payload === null) {
|
|
46
|
-
$toggleLink(payload)
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// For custom links, accept either a fully-formed URL or a
|
|
51
|
-
// root-relative path (starts with `/`). Drop the command when the
|
|
52
|
-
// URL is unusable so the toolbar doesn't insert garbage.
|
|
53
|
-
if (payload.linkType === 'custom') {
|
|
54
|
-
const url = payload.url ?? ''
|
|
55
|
-
if (!url.startsWith('/') && !validateUrl(url)) {
|
|
56
|
-
return false
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
$toggleLink(payload)
|
|
61
|
-
return true
|
|
62
|
-
},
|
|
63
|
-
COMMAND_PRIORITY_LOW
|
|
64
|
-
),
|
|
65
|
-
|
|
66
|
-
editor.registerCommand(
|
|
67
|
-
PASTE_COMMAND,
|
|
68
|
-
(event) => {
|
|
69
|
-
const selection = $getSelection()
|
|
70
|
-
if (
|
|
71
|
-
!$isRangeSelection(selection) ||
|
|
72
|
-
selection.isCollapsed() ||
|
|
73
|
-
!(event instanceof ClipboardEvent) ||
|
|
74
|
-
event.clipboardData == null
|
|
75
|
-
) {
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
78
|
-
const clipboardText = event.clipboardData.getData('text')
|
|
79
|
-
if (!validateUrl(clipboardText)) {
|
|
80
|
-
return false
|
|
81
|
-
}
|
|
82
|
-
// Don't auto-link when the selection spans block-level nodes.
|
|
83
|
-
if (selection.getNodes().some((node) => $isElementNode(node))) {
|
|
84
|
-
return false
|
|
85
|
-
}
|
|
86
|
-
editor.dispatchCommand(TOGGLE_LINK_COMMAND, {
|
|
87
|
-
linkType: 'custom',
|
|
88
|
-
url: clipboardText,
|
|
89
|
-
})
|
|
90
|
-
event.preventDefault()
|
|
91
|
-
return true
|
|
92
|
-
},
|
|
93
|
-
COMMAND_PRIORITY_LOW
|
|
94
|
-
)
|
|
95
|
-
)
|
|
96
|
-
}, [editor])
|
|
97
|
-
|
|
98
|
-
return null
|
|
99
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { useEffect } from 'react'
|
|
12
|
-
|
|
13
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
|
|
14
|
-
import { $insertNodeToNearestRoot } from '@lexical/utils'
|
|
15
|
-
import { COMMAND_PRIORITY_EDITOR, createCommand, type LexicalCommand } from 'lexical'
|
|
16
|
-
|
|
17
|
-
import { $createVimeoNode, VimeoNode } from '../../nodes/vimeo-node'
|
|
18
|
-
|
|
19
|
-
export const INSERT_VIMEO_COMMAND: LexicalCommand<string> = createCommand('INSERT_VIMEO_COMMAND')
|
|
20
|
-
|
|
21
|
-
export function VimeoPlugin(): React.JSX.Element | null {
|
|
22
|
-
const [editor] = useLexicalComposerContext()
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!editor.hasNodes([VimeoNode])) {
|
|
26
|
-
throw new Error('VimeoPlugin: VimeoNode not registered on editor')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return editor.registerCommand<string>(
|
|
30
|
-
INSERT_VIMEO_COMMAND,
|
|
31
|
-
(payload) => {
|
|
32
|
-
const vimeoNode = $createVimeoNode(payload)
|
|
33
|
-
$insertNodeToNearestRoot(vimeoNode)
|
|
34
|
-
|
|
35
|
-
return true
|
|
36
|
-
},
|
|
37
|
-
COMMAND_PRIORITY_EDITOR
|
|
38
|
-
)
|
|
39
|
-
}, [editor])
|
|
40
|
-
|
|
41
|
-
return null
|
|
42
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { useEffect } from 'react'
|
|
12
|
-
|
|
13
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
|
|
14
|
-
import { $insertNodeToNearestRoot } from '@lexical/utils'
|
|
15
|
-
import { COMMAND_PRIORITY_EDITOR, createCommand, type LexicalCommand } from 'lexical'
|
|
16
|
-
|
|
17
|
-
import { $createYouTubeNode, YouTubeNode } from '../../nodes/youtube-node'
|
|
18
|
-
|
|
19
|
-
export const INSERT_YOUTUBE_COMMAND: LexicalCommand<string> =
|
|
20
|
-
createCommand('INSERT_YOUTUBE_COMMAND')
|
|
21
|
-
|
|
22
|
-
export function YouTubePlugin(): React.JSX.Element | null {
|
|
23
|
-
const [editor] = useLexicalComposerContext()
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (!editor.hasNodes([YouTubeNode])) {
|
|
27
|
-
throw new Error('YouTubePlugin: YouTubeNode not registered on editor')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return editor.registerCommand<string>(
|
|
31
|
-
INSERT_YOUTUBE_COMMAND,
|
|
32
|
-
(payload) => {
|
|
33
|
-
const youTubeNode = $createYouTubeNode(payload)
|
|
34
|
-
$insertNodeToNearestRoot(youTubeNode)
|
|
35
|
-
|
|
36
|
-
return true
|
|
37
|
-
},
|
|
38
|
-
COMMAND_PRIORITY_EDITOR
|
|
39
|
-
)
|
|
40
|
-
}, [editor])
|
|
41
|
-
|
|
42
|
-
return null
|
|
43
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
export const theme = {
|
|
3
|
-
blockCursor: 'LexicalEditorTheme__blockCursor',
|
|
4
|
-
characterLimit: 'LexicalEditorTheme__characterLimit',
|
|
5
|
-
code: 'LexicalEditorTheme__code',
|
|
6
|
-
codeHighlight: {
|
|
7
|
-
atrule: 'LexicalEditorTheme__tokenAttr',
|
|
8
|
-
attr: 'LexicalEditorTheme__tokenAttr',
|
|
9
|
-
boolean: 'LexicalEditorTheme__tokenProperty',
|
|
10
|
-
builtin: 'LexicalEditorTheme__tokenSelector',
|
|
11
|
-
cdata: 'LexicalEditorTheme__tokenComment',
|
|
12
|
-
char: 'LexicalEditorTheme__tokenSelector',
|
|
13
|
-
class: 'LexicalEditorTheme__tokenFunction',
|
|
14
|
-
'class-name': 'LexicalEditorTheme__tokenFunction',
|
|
15
|
-
comment: 'LexicalEditorTheme__tokenComment',
|
|
16
|
-
constant: 'LexicalEditorTheme__tokenProperty',
|
|
17
|
-
deleted: 'LexicalEditorTheme__tokenProperty',
|
|
18
|
-
doctype: 'LexicalEditorTheme__tokenComment',
|
|
19
|
-
entity: 'LexicalEditorTheme__tokenOperator',
|
|
20
|
-
function: 'LexicalEditorTheme__tokenFunction',
|
|
21
|
-
important: 'LexicalEditorTheme__tokenVariable',
|
|
22
|
-
inserted: 'LexicalEditorTheme__tokenSelector',
|
|
23
|
-
keyword: 'LexicalEditorTheme__tokenAttr',
|
|
24
|
-
namespace: 'LexicalEditorTheme__tokenVariable',
|
|
25
|
-
number: 'LexicalEditorTheme__tokenProperty',
|
|
26
|
-
operator: 'LexicalEditorTheme__tokenOperator',
|
|
27
|
-
prolog: 'LexicalEditorTheme__tokenComment',
|
|
28
|
-
property: 'LexicalEditorTheme__tokenProperty',
|
|
29
|
-
punctuation: 'LexicalEditorTheme__tokenPunctuation',
|
|
30
|
-
regex: 'LexicalEditorTheme__tokenVariable',
|
|
31
|
-
selector: 'LexicalEditorTheme__tokenSelector',
|
|
32
|
-
string: 'LexicalEditorTheme__tokenSelector',
|
|
33
|
-
symbol: 'LexicalEditorTheme__tokenProperty',
|
|
34
|
-
tag: 'LexicalEditorTheme__tokenProperty',
|
|
35
|
-
url: 'LexicalEditorTheme__tokenOperator',
|
|
36
|
-
variable: 'LexicalEditorTheme__tokenVariable',
|
|
37
|
-
},
|
|
38
|
-
embedBlock: {
|
|
39
|
-
base: 'LexicalEditorTheme__embedBlock',
|
|
40
|
-
focus: 'LexicalEditorTheme__embedBlockFocus',
|
|
41
|
-
},
|
|
42
|
-
hashtag: 'LexicalEditorTheme__hashtag',
|
|
43
|
-
heading: {
|
|
44
|
-
h1: 'LexicalEditorTheme__h1',
|
|
45
|
-
h2: 'LexicalEditorTheme__h2',
|
|
46
|
-
h3: 'LexicalEditorTheme__h3',
|
|
47
|
-
h4: 'LexicalEditorTheme__h4',
|
|
48
|
-
h5: 'LexicalEditorTheme__h5',
|
|
49
|
-
h6: 'LexicalEditorTheme__h6',
|
|
50
|
-
},
|
|
51
|
-
image: 'editor-image',
|
|
52
|
-
inlineImage: 'LexicalEditor__inline-image',
|
|
53
|
-
layoutContainer: 'LexicalEditor__layoutContainer',
|
|
54
|
-
layoutItem: 'LexicalEditor__layoutItem',
|
|
55
|
-
admonition: 'LexicalEditor__admonition',
|
|
56
|
-
indent: 'LexicalEditorTheme__indent',
|
|
57
|
-
link: 'LexicalEditorTheme__link',
|
|
58
|
-
list: {
|
|
59
|
-
listitem: 'LexicalEditorTheme__listItem',
|
|
60
|
-
listitemChecked: 'LexicalEditorTheme__listItemChecked',
|
|
61
|
-
listitemUnchecked: 'LexicalEditorTheme__listItemUnchecked',
|
|
62
|
-
nested: {
|
|
63
|
-
listitem: 'LexicalEditorTheme__nestedListItem',
|
|
64
|
-
},
|
|
65
|
-
olDepth: [
|
|
66
|
-
'LexicalEditorTheme__ol1',
|
|
67
|
-
'LexicalEditorTheme__ol2',
|
|
68
|
-
'LexicalEditorTheme__ol3',
|
|
69
|
-
'LexicalEditorTheme__ol4',
|
|
70
|
-
'LexicalEditorTheme__ol5',
|
|
71
|
-
],
|
|
72
|
-
ul: 'LexicalEditorTheme__ul',
|
|
73
|
-
},
|
|
74
|
-
ltr: 'LexicalEditorTheme__ltr',
|
|
75
|
-
mark: 'LexicalEditorTheme__mark',
|
|
76
|
-
markOverlap: 'LexicalEditorTheme__markOverlap',
|
|
77
|
-
paragraph: 'LexicalEditorTheme__paragraph',
|
|
78
|
-
quote: 'LexicalEditorTheme__quote',
|
|
79
|
-
rtl: 'LexicalEditorTheme__rtl',
|
|
80
|
-
table: 'LexicalEditorTheme__table',
|
|
81
|
-
tableAddColumns: 'LexicalEditorTheme__tableAddColumns',
|
|
82
|
-
tableAddRows: 'LexicalEditorTheme__tableAddRows',
|
|
83
|
-
tableCell: 'LexicalEditorTheme__tableCell',
|
|
84
|
-
tableCellActionButton: 'LexicalEditorTheme__tableCellActionButton',
|
|
85
|
-
tableCellActionButtonContainer: 'LexicalEditorTheme__tableCellActionButtonContainer',
|
|
86
|
-
tableCellEditing: 'LexicalEditorTheme__tableCellEditing',
|
|
87
|
-
tableCellHeader: 'LexicalEditorTheme__tableCellHeader',
|
|
88
|
-
tableCellPrimarySelected: 'LexicalEditorTheme__tableCellPrimarySelected',
|
|
89
|
-
tableCellResizer: 'LexicalEditorTheme__tableCellResizer',
|
|
90
|
-
tableCellSelected: 'LexicalEditorTheme__tableCellSelected',
|
|
91
|
-
tableCellSortedIndicator: 'LexicalEditorTheme__tableCellSortedIndicator',
|
|
92
|
-
tableResizeRuler: 'LexicalEditorTheme__tableCellResizeRuler',
|
|
93
|
-
tableSelected: 'LexicalEditorTheme__tableSelected',
|
|
94
|
-
text: {
|
|
95
|
-
bold: 'LexicalEditorTheme__textBold',
|
|
96
|
-
code: 'LexicalEditorTheme__textCode',
|
|
97
|
-
italic: 'LexicalEditorTheme__textItalic',
|
|
98
|
-
strikethrough: 'LexicalEditorTheme__textStrikethrough',
|
|
99
|
-
subscript: 'LexicalEditorTheme__textSubscript',
|
|
100
|
-
superscript: 'LexicalEditorTheme__textSuperscript',
|
|
101
|
-
underline: 'LexicalEditorTheme__textUnderline',
|
|
102
|
-
underlineStrikethrough: 'LexicalEditorTheme__textUnderlineStrikethrough',
|
|
103
|
-
},
|
|
104
|
-
}
|