@webiny/lexical-editor 0.0.0-unstable.df7a8bb475 → 0.0.0-unstable.e2758ee1cf

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.
Files changed (52) hide show
  1. package/components/Editor/RichTextEditor.d.ts +1 -0
  2. package/components/Editor/RichTextEditor.js +9 -3
  3. package/components/Editor/RichTextEditor.js.map +1 -1
  4. package/components/Toolbar/StaticToolbar.css +416 -0
  5. package/components/ToolbarActions/FontColorAction.js +0 -4
  6. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  7. package/context/RichTextEditorContext.d.ts +1 -0
  8. package/context/RichTextEditorContext.js +14 -1
  9. package/context/RichTextEditorContext.js.map +1 -1
  10. package/hooks/useCurrentElement.js +1 -2
  11. package/hooks/useCurrentElement.js.map +1 -1
  12. package/index.d.ts +0 -1
  13. package/index.js +0 -1
  14. package/index.js.map +1 -1
  15. package/package.json +16 -15
  16. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +4 -10
  17. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +15 -145
  18. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -1
  19. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +2 -3
  20. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +5 -6
  21. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -1
  22. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +1 -136
  23. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +5 -5
  24. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +2 -6
  25. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  26. package/plugins/FloatingLinkEditorPlugin/types.d.ts +10 -0
  27. package/plugins/FloatingLinkEditorPlugin/types.js +3 -0
  28. package/plugins/FloatingLinkEditorPlugin/types.js.map +1 -0
  29. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +8 -0
  30. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +128 -0
  31. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -0
  32. package/plugins/ImagesPlugin/ImagesPlugin.js +1 -2
  33. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  34. package/plugins/LinkPlugin/LinkPlugin.js +1 -2
  35. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  36. package/plugins/ListPLugin/ListPlugin.js +1 -2
  37. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  38. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +1 -2
  39. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  40. package/utils/setFloatingElemPosition.d.ts +1 -1
  41. package/utils/setFloatingElemPosition.js +23 -21
  42. package/utils/setFloatingElemPosition.js.map +1 -1
  43. package/components/Toolbar/Toolbar.css +0 -643
  44. package/components/Toolbar/Toolbar.d.ts +0 -6
  45. package/components/Toolbar/Toolbar.js +0 -148
  46. package/components/Toolbar/Toolbar.js.map +0 -1
  47. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +0 -8
  48. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +0 -104
  49. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +0 -1
  50. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +0 -9
  51. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +0 -34
  52. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +0 -1
@@ -9,6 +9,7 @@ export type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>["
9
9
  export interface RichTextEditorProps {
10
10
  children?: React.ReactNode | React.ReactNode[];
11
11
  classes?: string;
12
+ disabled?: boolean;
12
13
  contentEditableStyles?: React.CSSProperties;
13
14
  focus?: boolean;
14
15
  height?: number | string;
@@ -25,6 +25,7 @@ const BaseRichTextEditor = ({
25
25
  focus,
26
26
  styles,
27
27
  width,
28
+ disabled = false,
28
29
  height,
29
30
  contentEditableStyles,
30
31
  placeholderStyles,
@@ -55,6 +56,7 @@ const BaseRichTextEditor = ({
55
56
  }, plugin.element));
56
57
  const initialConfig = {
57
58
  editorId: useId(),
59
+ editable: !disabled,
58
60
  namespace: "webiny",
59
61
  onError: () => {
60
62
  // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
@@ -88,7 +90,10 @@ const BaseRichTextEditor = ({
88
90
  }, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
89
91
  theme: props.theme,
90
92
  toolbarActionPlugins: props.toolbarActionPlugins
91
- }, staticToolbar ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
93
+ }, staticToolbar && !disabled ? staticToolbar : null, /*#__PURE__*/React.createElement("div", {
94
+ "data-role": "overlays",
95
+ className: "relative"
96
+ }), /*#__PURE__*/React.createElement("div", {
92
97
  /* This className is necessary for targeting of editor container from CSS files. */
93
98
  className: "editor-shell",
94
99
  ref: scrollRef,
@@ -100,7 +105,7 @@ const BaseRichTextEditor = ({
100
105
  }
101
106
  }, /*#__PURE__*/React.createElement(StateHandlingPlugin, {
102
107
  value: props.value,
103
- onChange: onChange
108
+ onChange: disabled ? undefined : onChange
104
109
  }), /*#__PURE__*/React.createElement(ClearEditorPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, {
105
110
  externalHistoryState: historyState
106
111
  }), onBlur && /*#__PURE__*/React.createElement(BlurEventPlugin, {
@@ -115,6 +120,7 @@ const BaseRichTextEditor = ({
115
120
  className: "editor",
116
121
  ref: onRef
117
122
  }, /*#__PURE__*/React.createElement(ContentEditable, {
123
+ disabled: disabled,
118
124
  style: {
119
125
  outline: 0,
120
126
  ...contentEditableStyles
@@ -122,7 +128,7 @@ const BaseRichTextEditor = ({
122
128
  }))),
123
129
  placeholder: placeholderElem,
124
130
  ErrorBoundary: LexicalErrorBoundary
125
- }), floatingAnchorElem && toolbar))))
131
+ }), disabled ? null : floatingAnchorElem && toolbar))))
126
132
  );
127
133
  };
128
134
 
@@ -1 +1 @@
1
- {"version":3,"names":["React","Fragment","useId","useRef","useState","LexicalComposer","AutoFocusPlugin","ClearEditorPlugin","RichTextPlugin","LexicalErrorBoundary","makeDecoratable","HistoryPlugin","ContentEditable","allNodes","RichTextEditorProvider","BlurEventPlugin","Placeholder","SharedHistoryContext","useSharedHistoryContext","LexicalEditorWithConfig","useLexicalEditorConfig","StateHandlingPlugin","BaseRichTextEditor","onChange","toolbar","staticToolbar","nodes","placeholder","children","onBlur","focus","styles","width","height","contentEditableStyles","placeholderStyles","props","editorTheme","theme","config","historyState","placeholderElem","createElement","scrollRef","floatingAnchorElem","setFloatingAnchorElem","undefined","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","key","name","element","initialConfig","editorId","namespace","onError","current","tokens","$colors","colors","$typography","typography","$cacheKey","JSON","stringify","configRef","length","toolbarActionPlugins","className","ref","style","overflow","position","value","externalHistoryState","contentEditable","outline","ErrorBoundary","RichTextEditor"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useId, useRef, useState } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin.js\";\nimport type { LexicalValue, ToolbarActionPlugin } from \"~/types.js\";\nimport { Placeholder } from \"~/ui/Placeholder.js\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext.js\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\nexport type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>[\"initialConfig\"] & {\n editorId: string;\n};\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (value: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;\n width?: number | string;\n}\n\nconst BaseRichTextEditor = ({\n onChange,\n toolbar,\n staticToolbar,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n height,\n contentEditableStyles,\n placeholderStyles,\n ...props\n}: RichTextEditorProps) => {\n const editorTheme = useRef(props.theme);\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\n ));\n\n const initialConfig = {\n editorId: useId(),\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n if (props.configRef) {\n props.configRef.current = initialConfig;\n }\n\n return (\n /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar ? staticToolbar : null}\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{\n ...styles,\n ...sizeStyle,\n overflow: \"auto\",\n position: \"relative\"\n }}\n >\n {/* State plugins. */}\n <StateHandlingPlugin value={props.value} onChange={onChange} />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components. */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {floatingAnchorElem && toolbar}\n </div>\n </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n\nexport namespace RichTextEditor {\n export type InitialConfig = InitialEditorConfig;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,iBAAiB,QAAQ,yCAAyC;AAC3E,SAASC,cAAc,QAAQ,sCAAsC;AACrE,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa,QAAQ,qCAAqC;AACnE,SAASC,eAAe,QAAQ,uCAAuC;AAEvE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,sBAAsB;AAC/B,SAASC,eAAe;AAExB,SAASC,WAAW;AACpB,SAASC,oBAAoB,EAAEC,uBAAuB;AACtD,SACIC,uBAAuB,EACvBC,sBAAsB;AAE1B,SAASC,mBAAmB;AA4B5B,MAAMC,kBAAkB,GAAGA,CAAC;EACxBC,QAAQ;EACRC,OAAO;EACPC,aAAa;EACbC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,qBAAqB;EACrBC,iBAAi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C;IAAa,CAAE,CAAC,EAEpDX,MAAM,iBAAI7B,KAAA,CAAA0C,aAAA,CAAC3B,eAAe;MAACc,MAAM,EAAEA;IAAO,CAAE,CAAC,EAC7CC,KAAK,iBAAI9B,KAAA,CAAA0C,aAAA,CAACpC,eAAe,MAAE,CAAC,EAE5B+C,aAAa,EACbzB,QAAQ,eACT5B,KAAA,CAAA0C,aAAA,CAAClC,cAAc;MACX0E,eAAe,eACXlF,KAAA,CAAA0C,aAAA;QAAKiC,SAAS,EAAC,iBAAiB;QAACE,KAAK,EAAE;UAAE,GAAG5B;QAAU;MAAE,gBACrDjD,KAAA,CAAA0C,aAAA;QAAKiC,SAAS,EAAC,QAAQ;QAACC,GAAG,EAAE7B;MAAM,gBAC/B/C,KAAA,CAAA0C,aAAA,CAAC9B,eAAe;QACZiE,KAAK,EAAE;UAAEM,OAAO,EAAE,CAAC;UAAE,GAAGjD;QAAsB;MAAE,CACnD,CACA,CACJ,CACR;MACDP,WAAW,EAAEc,eAAgB;MAC7B2C,aAAa,EAAE3E;IAAqB,CACvC,CAAC,EAEDmC,kBAAkB,IAAIpB,OACtB,CACe,CACX,CACC;EAAC;AAE/B,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAM6D,cAAc,GAAG3E,eAAe,CAAC,gBAAgB,EAAG0B,KAA0B,IAAK;EAC5F,oBACIpC,KAAA,CAAA0C,aAAA,CAACvB,uBAAuB,qBACpBnB,KAAA,CAAA0C,aAAA,CAACpB,kBAAkB,EAAKc,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Fragment","useId","useRef","useState","LexicalComposer","AutoFocusPlugin","ClearEditorPlugin","RichTextPlugin","LexicalErrorBoundary","makeDecoratable","HistoryPlugin","ContentEditable","allNodes","RichTextEditorProvider","BlurEventPlugin","Placeholder","SharedHistoryContext","useSharedHistoryContext","LexicalEditorWithConfig","useLexicalEditorConfig","StateHandlingPlugin","BaseRichTextEditor","onChange","toolbar","staticToolbar","nodes","placeholder","children","onBlur","focus","styles","width","disabled","height","contentEditableStyles","placeholderStyles","props","editorTheme","theme","config","historyState","placeholderElem","createElement","scrollRef","floatingAnchorElem","setFloatingAnchorElem","undefined","onRef","_floatingAnchorElem","sizeStyle","configNodes","map","node","configPlugins","plugins","plugin","key","name","element","initialConfig","editorId","editable","namespace","onError","current","tokens","$colors","colors","$typography","typography","$cacheKey","JSON","stringify","configRef","length","toolbarActionPlugins","className","ref","style","overflow","position","value","externalHistoryState","contentEditable","outline","ErrorBoundary","RichTextEditor"],"sources":["RichTextEditor.tsx"],"sourcesContent":["import React, { Fragment, useId, useRef, useState } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { ClearEditorPlugin } from \"@lexical/react/LexicalClearEditorPlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin.js\";\nimport type { LexicalValue, ToolbarActionPlugin } from \"~/types.js\";\nimport { Placeholder } from \"~/ui/Placeholder.js\";\nimport { SharedHistoryContext, useSharedHistoryContext } from \"~/context/SharedHistoryContext.js\";\nimport {\n LexicalEditorWithConfig,\n useLexicalEditorConfig\n} from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\nexport type InitialEditorConfig = React.ComponentProps<typeof LexicalComposer>[\"initialConfig\"] & {\n editorId: string;\n};\n\nexport interface RichTextEditorProps {\n children?: React.ReactNode | React.ReactNode[];\n classes?: string;\n disabled?: boolean;\n contentEditableStyles?: React.CSSProperties;\n focus?: boolean;\n height?: number | string;\n nodes?: Klass<LexicalNode>[];\n onBlur?: (editorState: LexicalValue) => void;\n onChange?: (value: LexicalValue) => void;\n placeholder?: string;\n placeholderStyles?: React.CSSProperties;\n staticToolbar?: React.ReactNode;\n styles?: React.CSSProperties;\n tag?: string;\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n toolbar?: React.ReactNode;\n value: LexicalValue | null | undefined;\n configRef?: React.MutableRefObject<InitialEditorConfig | undefined>;\n width?: number | string;\n}\n\nconst BaseRichTextEditor = ({\n onChange,\n toolbar,\n staticToolbar,\n nodes,\n placeholder,\n children,\n onBlur,\n focus,\n styles,\n width,\n disabled = false,\n height,\n contentEditableStyles,\n placeholderStyles,\n ...props\n}: RichTextEditorProps) => {\n const editorTheme = useRef(props.theme);\n const config = useLexicalEditorConfig();\n const { historyState } = useSharedHistoryContext();\n const placeholderElem = (\n <Placeholder styles={placeholderStyles}>{placeholder || \"Enter text...\"}</Placeholder>\n );\n const scrollRef = useRef(null);\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLElement | undefined>(\n undefined\n );\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem);\n }\n };\n\n const sizeStyle = {\n height: height || \"\",\n width: width || \"\"\n };\n\n const configNodes = config.nodes.map(node => node.node);\n const configPlugins = config.plugins.map(plugin => (\n <Fragment key={plugin.name}>{plugin.element}</Fragment>\n ));\n\n const initialConfig = {\n editorId: useId(),\n editable: !disabled,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n nodes: [...allNodes, ...configNodes, ...(nodes || [])],\n theme: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n if (props.configRef) {\n props.configRef.current = initialConfig;\n }\n\n return (\n /**\n * Once the LexicalComposer is mounted, it caches the `initialConfig` internally, and all future\n * updates to the config will be ignored. This is a problem because we pull in Nodes from our config,\n * and initially, there can be multiple re-renders, while the config object is settled.\n *\n * To bypass this issue, we generate a naive `key` based on the number of Nodes.\n */\n <SharedHistoryContext>\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider\n theme={props.theme}\n toolbarActionPlugins={props.toolbarActionPlugins}\n >\n {staticToolbar && !disabled ? staticToolbar : null}\n <div data-role={\"overlays\"} className={\"relative\"}></div>\n <div\n /* This className is necessary for targeting of editor container from CSS files. */\n className={\"editor-shell\"}\n ref={scrollRef}\n style={{\n ...styles,\n ...sizeStyle,\n overflow: \"auto\",\n position: \"relative\"\n }}\n >\n {/* State plugins. */}\n <StateHandlingPlugin\n value={props.value}\n onChange={disabled ? undefined : onChange}\n />\n <ClearEditorPlugin />\n <HistoryPlugin externalHistoryState={historyState} />\n {/* Event plugins. */}\n {onBlur && <BlurEventPlugin onBlur={onBlur} />}\n {focus && <AutoFocusPlugin />}\n {/* External plugins and components. */}\n {configPlugins}\n {children}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\" style={{ ...sizeStyle }}>\n <div className=\"editor\" ref={onRef}>\n <ContentEditable\n disabled={disabled}\n style={{ outline: 0, ...contentEditableStyles }}\n />\n </div>\n </div>\n }\n placeholder={placeholderElem}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {/* Toolbar. */}\n {disabled ? null : floatingAnchorElem && toolbar}\n </div>\n </RichTextEditorProvider>\n </LexicalComposer>\n </SharedHistoryContext>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const RichTextEditor = makeDecoratable(\"RichTextEditor\", (props: RichTextEditorProps) => {\n return (\n <LexicalEditorWithConfig>\n <BaseRichTextEditor {...props} />\n </LexicalEditorWithConfig>\n );\n});\n\nexport namespace RichTextEditor {\n export type InitialConfig = InitialEditorConfig;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,iBAAiB,QAAQ,yCAAyC;AAC3E,SAASC,cAAc,QAAQ,sCAAsC;AACrE,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa,QAAQ,qCAAqC;AACnE,SAASC,eAAe,QAAQ,uCAAuC;AAEvE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,sBAAsB;AAC/B,SAASC,eAAe;AAExB,SAASC,WAAW;AACpB,SAASC,oBAAoB,EAAEC,uBAAuB;AACtD,SACIC,uBAAuB,EACvBC,sBAAsB;AAE1B,SAASC,mBAAmB;AA6B5B,MAAMC,kBAAkB,GAAGA,CAAC;EACxBC,QAAQ;EACRC,OAAO;EACPC,aAAa;EACbC,KAAK;EACLC,WAAW;EACXC,QAAQ;EACRC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,KAAK;EACLC,QAAQ,GAAG,KAAK;EAChBC,MAAM;EACNC,qBAAqB;EACrBC,iBAAiB;EACjB,GAAGC;AACc,CAAC,KAAK;EACvB,MAAMC,WAAW,GAAGnC,MAAM,CAACkC,KAAK,CAACE,KAAK,CAAC;EACvC,MAAMC,MAAM,GAAGpB,sBAAsB,CAAC,CAAC;EACvC,MAAM;IAAEqB;EAAa,CAAC,GAAGvB,uBAAuB,CAAC,CAAC;EAClD,MAAMwB,eAAe,gBACjB1C,K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AC5B,eAAe;MAACc,MAAM,EAAEA;IAAO,CAAE,CAAC,EAC7CC,KAAK,iBAAI9B,KAAA,CAAA2C,aAAA,CAACrC,eAAe,MAAE,CAAC,EAE5BgD,aAAa,EACb1B,QAAQ,eACT5B,KAAA,CAAA2C,aAAA,CAACnC,cAAc;MACX4E,eAAe,eACXpF,KAAA,CAAA2C,aAAA;QAAKkC,SAAS,EAAC,iBAAiB;QAACE,KAAK,EAAE;UAAE,GAAG7B;QAAU;MAAE,gBACrDlD,KAAA,CAAA2C,aAAA;QAAKkC,SAAS,EAAC,QAAQ;QAACC,GAAG,EAAE9B;MAAM,gBAC/BhD,KAAA,CAAA2C,aAAA,CAAC/B,eAAe;QACZqB,QAAQ,EAAEA,QAAS;QACnB8C,KAAK,EAAE;UAAEM,OAAO,EAAE,CAAC;UAAE,GAAGlD;QAAsB;MAAE,CACnD,CACA,CACJ,CACR;MACDR,WAAW,EAAEe,eAAgB;MAC7B4C,aAAa,EAAE7E;IAAqB,CACvC,CAAC,EAEDwB,QAAQ,GAAG,IAAI,GAAGY,kBAAkB,IAAIrB,OACxC,CACe,CACX,CACC;EAAC;AAE/B,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAM+D,cAAc,GAAG7E,eAAe,CAAC,gBAAgB,EAAG2B,KAA0B,IAAK;EAC5F,oBACIrC,KAAA,CAAA2C,aAAA,CAACxB,uBAAuB,qBACpBnB,KAAA,CAAA2C,aAAA,CAACrB,kBAAkB,EAAKe,KAAQ,CACX,CAAC;AAElC,CAAC,CAAC","ignoreList":[]}
@@ -258,3 +258,419 @@
258
258
  .static-toolbar button.item.dropdown-item-active i {
259
259
  opacity: 1;
260
260
  }
261
+
262
+ i.bold {
263
+ background-image: url("../../images/icons/type-bold.svg");
264
+ }
265
+
266
+ i.italic {
267
+ background-image: url("../../images/icons/type-italic.svg");
268
+ }
269
+
270
+ i.code {
271
+ background-image: url("../../images/icons/code.svg");
272
+ }
273
+
274
+ i.underline {
275
+ background-image: url("../../images/icons/type-underline.svg");
276
+ }
277
+
278
+ i.strikethrough {
279
+ background-image: url("../../images/icons/type-strikethrough.svg");
280
+ }
281
+
282
+ i.link {
283
+ background-image: url("../../images/icons/link.svg");
284
+ }
285
+
286
+ i.quote {
287
+ background-image: url("../../images/icons/chat-square-quote.svg");
288
+ }
289
+
290
+ .icon.left-align,
291
+ i.left-align {
292
+ background-image: url("../../images/icons/text-left.svg");
293
+ }
294
+
295
+ i.center-align {
296
+ background-image: url("../../images/icons/text-center.svg");
297
+ }
298
+
299
+ i.right-align {
300
+ background-image: url("../../images/icons/text-right.svg");
301
+ }
302
+
303
+ i.indent {
304
+ background-image: url("../../images/icons/indent.svg");
305
+ }
306
+
307
+ i.outdent {
308
+ background-image: url("../../images/icons/outdent.svg");
309
+ }
310
+
311
+ i.justify-align {
312
+ background-image: url("../../images/icons/justify.svg");
313
+ }
314
+
315
+ i.chevron-down {
316
+ background-color: transparent;
317
+ background-size: contain;
318
+ display: inline-block;
319
+ height: 8px;
320
+ width: 8px;
321
+ background-image: url("../../images/icons/chevron-down.svg");
322
+ }
323
+
324
+ i.insert-image,
325
+ .icon.insert-image {
326
+ background-color: transparent;
327
+ background-size: contain;
328
+ display: inline-block;
329
+ height: 8px;
330
+ width: 8px;
331
+ background-image: url("../../images/icons/insert-image.svg");
332
+ }
333
+
334
+ .icon.bullet-list,
335
+ .icon.bullet {
336
+ background-image: url("../../images/icons/list-ul.svg");
337
+ }
338
+
339
+ .icon.numbered-list,
340
+ .icon.number {
341
+ background-image: url("../../images/icons/list-ol.svg");
342
+ }
343
+
344
+ i.font-color,
345
+ .icon.font-color {
346
+ background-image: url("../../images/icons/font-color.svg");
347
+ }
348
+
349
+ .link-editor .button.active,
350
+ .toolbar .button.active {
351
+ background-color: rgb(223, 232, 250);
352
+ }
353
+
354
+ .toolbar .divider {
355
+ width: 1px;
356
+ background-color: #eee;
357
+ margin: 0 4px;
358
+ }
359
+
360
+ .lexical-dropdown-container {
361
+ position: absolute;
362
+ bottom: -5px;
363
+ left: 0;
364
+ }
365
+
366
+ .lexical-dropdown {
367
+ z-index: 10;
368
+ display: block;
369
+ position: fixed;
370
+ box-shadow:
371
+ 0 12px 28px 0 rgba(0, 0, 0, 0.2),
372
+ 0 2px 4px 0 rgba(0, 0, 0, 0.1),
373
+ inset 0 0 0 1px rgba(255, 255, 255, 0.5);
374
+ border-radius: 8px;
375
+ min-height: 40px;
376
+ background-color: #fff;
377
+ max-height: 250px;
378
+ overflow: hidden;
379
+ overflow-y: auto;
380
+ }
381
+
382
+ .lexical-dropdown.no-scroll {
383
+ max-height: inherit;
384
+ overflow: auto;
385
+ overflow-y: auto;
386
+ }
387
+
388
+ .lexical-dropdown .item {
389
+ margin: 0 8px 0 8px;
390
+ padding: 8px;
391
+ color: #050505;
392
+ cursor: pointer;
393
+ line-height: 16px;
394
+ font-size: 15px;
395
+ display: flex;
396
+ align-content: center;
397
+ flex-direction: row;
398
+ flex-shrink: 0;
399
+ justify-content: space-between;
400
+ background-color: #fff;
401
+ border-radius: 8px;
402
+ border: 0;
403
+ max-width: 250px;
404
+ min-width: 100px;
405
+ }
406
+
407
+ .lexical-dropdown .item.fontsize-item,
408
+ .lexical-dropdown .item.fontsize-item .text {
409
+ min-width: unset;
410
+ }
411
+
412
+ .lexical-dropdown .item .active {
413
+ display: flex;
414
+ width: 20px;
415
+ height: 20px;
416
+ background-size: contain;
417
+ }
418
+
419
+ .lexical-dropdown .item:first-child {
420
+ margin-top: 8px;
421
+ }
422
+
423
+ .lexical-dropdown .item:last-child {
424
+ margin-bottom: 8px;
425
+ }
426
+
427
+ .lexical-dropdown .item:hover {
428
+ background-color: #eee;
429
+ }
430
+
431
+ .lexical-dropdown .item .text {
432
+ display: flex;
433
+ line-height: 20px;
434
+ flex-grow: 1;
435
+ min-width: 150px;
436
+ }
437
+
438
+ .lexical-dropdown .item .icon {
439
+ display: flex;
440
+ width: 20px;
441
+ height: 20px;
442
+ user-select: none;
443
+ margin-right: 12px;
444
+ line-height: 16px;
445
+ background-size: contain;
446
+ background-position: center;
447
+ background-repeat: no-repeat;
448
+ }
449
+
450
+ .lexical-dropdown .divider {
451
+ width: auto;
452
+ background-color: #eee;
453
+ margin: 4px 8px;
454
+ height: 1px;
455
+ }
456
+
457
+ @media screen and (max-width: 1100px) {
458
+ .dropdown-button-text {
459
+ display: none !important;
460
+ }
461
+ .font-size .dropdown-button-text {
462
+ display: flex !important;
463
+ }
464
+ .code-language .dropdown-button-text {
465
+ display: flex !important;
466
+ }
467
+ }
468
+
469
+ button.item i {
470
+ opacity: 0.6;
471
+ }
472
+
473
+ button.item.dropdown-item-active {
474
+ background-color: rgba(223, 232, 250, 0.3);
475
+ }
476
+
477
+ button.item.dropdown-item-active i {
478
+ opacity: 1;
479
+ }
480
+
481
+ .editor-shell span.editor-image {
482
+ cursor: default;
483
+ display: inline-block;
484
+ position: relative;
485
+ user-select: none;
486
+ }
487
+
488
+ .editor-shell .editor-image img {
489
+ max-width: 100%;
490
+ cursor: default;
491
+ }
492
+
493
+ .editor-shell .editor-image img.focused {
494
+ outline: 2px solid rgb(60, 132, 244);
495
+ user-select: none;
496
+ }
497
+
498
+ .editor-shell .editor-image img.focused.draggable {
499
+ cursor: grab;
500
+ }
501
+
502
+ .editor-shell .editor-image img.focused.draggable:active {
503
+ cursor: grabbing;
504
+ }
505
+
506
+ .editor-shell .editor-image .image-caption-container .tree-view-output {
507
+ margin: 0;
508
+ border-radius: 0;
509
+ }
510
+
511
+ .editor-shell .editor-image .image-caption-container {
512
+ display: block;
513
+ position: absolute;
514
+ bottom: 4px;
515
+ left: 0;
516
+ right: 0;
517
+ padding: 0;
518
+ margin: 0;
519
+ border-top: 1px solid #fff;
520
+ background-color: #ffffffe6;
521
+ min-width: 100px;
522
+ color: #000;
523
+ overflow: hidden;
524
+ }
525
+
526
+ .editor-shell .editor-image .image-caption-button {
527
+ display: block;
528
+ position: absolute;
529
+ bottom: 20px;
530
+ left: 0;
531
+ right: 0;
532
+ width: 30%;
533
+ padding: 10px;
534
+ margin: 0 auto;
535
+ border: 1px solid rgba(255, 255, 255, 0.3);
536
+ border-radius: 5px;
537
+ background-color: #00000080;
538
+ min-width: 100px;
539
+ color: #fff;
540
+ cursor: pointer;
541
+ user-select: none;
542
+ }
543
+
544
+ .editor-shell .editor-image .image-caption-button:hover {
545
+ background-color: #3c84f480;
546
+ }
547
+
548
+ .editor-shell .editor-image .image-resizer {
549
+ display: block;
550
+ width: 7px;
551
+ height: 7px;
552
+ position: absolute;
553
+ background-color: #3c84f4;
554
+ border: 1px solid #fff;
555
+ }
556
+
557
+ .editor-shell .editor-image .image-resizer.image-resizer-n {
558
+ top: -6px;
559
+ left: 48%;
560
+ cursor: n-resize;
561
+ }
562
+
563
+ .editor-shell .editor-image .image-resizer.image-resizer-ne {
564
+ top: -6px;
565
+ right: -6px;
566
+ cursor: ne-resize;
567
+ }
568
+
569
+ .editor-shell .editor-image .image-resizer.image-resizer-e {
570
+ bottom: 48%;
571
+ right: -6px;
572
+ cursor: e-resize;
573
+ }
574
+
575
+ .editor-shell .editor-image .image-resizer.image-resizer-se {
576
+ bottom: -2px;
577
+ right: -6px;
578
+ cursor: nwse-resize;
579
+ }
580
+
581
+ .editor-shell .editor-image .image-resizer.image-resizer-s {
582
+ bottom: -2px;
583
+ left: 48%;
584
+ cursor: s-resize;
585
+ }
586
+
587
+ .editor-shell .editor-image .image-resizer.image-resizer-sw {
588
+ bottom: -2px;
589
+ left: -6px;
590
+ cursor: sw-resize;
591
+ }
592
+
593
+ .editor-shell .editor-image .image-resizer.image-resizer-w {
594
+ bottom: 48%;
595
+ left: -6px;
596
+ cursor: w-resize;
597
+ }
598
+
599
+ .editor-shell .editor-image .image-resizer.image-resizer-nw {
600
+ top: -6px;
601
+ left: -6px;
602
+ cursor: nw-resize;
603
+ }
604
+
605
+ .editor-shell span.inline-editor-image {
606
+ cursor: default;
607
+ display: inline-block;
608
+ position: relative;
609
+ z-index: 1;
610
+ }
611
+
612
+ .editor-shell .inline-editor-image img {
613
+ max-width: 100%;
614
+ cursor: default;
615
+ }
616
+
617
+ .editor-shell .inline-editor-image img.focused {
618
+ outline: 2px solid rgb(60, 132, 244);
619
+ }
620
+
621
+ .editor-shell .inline-editor-image img.focused.draggable {
622
+ cursor: grab;
623
+ }
624
+
625
+ .editor-shell .inline-editor-image img.focused.draggable:active {
626
+ cursor: grabbing;
627
+ }
628
+
629
+ .editor-shell .inline-editor-image .image-caption-container .tree-view-output {
630
+ margin: 0;
631
+ border-radius: 0;
632
+ }
633
+
634
+ .editor-shell .inline-editor-image.position-full {
635
+ margin: 1em 0;
636
+ }
637
+
638
+ .editor-shell .inline-editor-image.position-left {
639
+ float: left;
640
+ width: 50%;
641
+ margin: 1em 1em 0 0;
642
+ }
643
+
644
+ .editor-shell .inline-editor-image.position-right {
645
+ float: right;
646
+ width: 50%;
647
+ margin: 1em 0 0 1em;
648
+ }
649
+
650
+ .editor-shell .inline-editor-image .image-edit-button {
651
+ display: block;
652
+ position: absolute;
653
+ top: 12px;
654
+ right: 12px;
655
+ padding: 6px 8px;
656
+ margin: 0 auto;
657
+ border: 1px solid rgba(255, 255, 255, 0.3);
658
+ border-radius: 5px;
659
+ background-color: #00000080;
660
+ min-width: 60px;
661
+ color: #fff;
662
+ cursor: pointer;
663
+ user-select: none;
664
+ }
665
+
666
+ .editor-shell .inline-editor-image .image-edit-button:hover {
667
+ background-color: #3c84f480;
668
+ }
669
+
670
+ .editor-shell .inline-editor-image .image-caption-container {
671
+ display: block;
672
+ background-color: #f4f4f4;
673
+ min-width: 100%;
674
+ color: #000;
675
+ overflow: hidden;
676
+ }
@@ -33,10 +33,6 @@ export const FontColorAction = () => {
33
33
  return $isFontColorNode(node) ? node.getColorStyle().color : "#000";
34
34
  });
35
35
  const onFontColorSelect = useCallback((colorValue, themeColorName) => {
36
- console.log({
37
- colorValue,
38
- themeColorName
39
- });
40
36
  editor.dispatchCommand(ADD_FONT_COLOR_COMMAND, {
41
37
  color: new ThemeColorValue(colorValue, themeColorName)
42
38
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useEffect","useMemo","Compose","makeDecoratable","FontColorActionContext","$isFontColorNode","ADD_FONT_COLOR_COMMAND","ThemeColorValue","getSelectedNode","useDeriveValueFromSelection","useRichTextEditor","FontColorPicker","console","log","FontActionColorPicker","element","createElement","component","with","FontColorAction","editor","fontColor","rangeSelection","node","getColorStyle","color","onFontColorSelect","colorValue","themeColorName","dispatchCommand","context","value","applyColor","Provider","ColorPicker"],"sources":["FontColorAction.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport type { LexicalCommand } from \"lexical\";\nimport { Compose, makeDecoratable } from \"@webiny/react-composition\";\nimport { FontColorActionContext } from \"~/context/FontColorActionContext.js\";\nimport type { FontColorPayload } from \"@webiny/lexical-nodes\";\nimport { $isFontColorNode, ADD_FONT_COLOR_COMMAND, ThemeColorValue } from \"@webiny/lexical-nodes\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode.js\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const FontColorPicker = makeDecoratable(\"FontColorPicker\", (): JSX.Element | null => {\n useEffect(() => {\n console.log(\"Default FontColorPicker, please add your own component\");\n }, []);\n return null;\n});\n\ninterface FontActionColorPicker {\n element: JSX.Element;\n}\n\nconst FontActionColorPicker = ({ element }: FontActionColorPicker): JSX.Element => {\n return <Compose component={FontColorPicker} with={() => () => element} />;\n};\n\nexport type FontColorAction = React.ComponentType<unknown> & {\n ColorPicker: typeof FontActionColorPicker;\n};\n\nexport const FontColorAction: FontColorAction = () => {\n const { editor } = useRichTextEditor();\n const fontColor = useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return \"#000\";\n }\n\n const node = getSelectedNode(rangeSelection);\n return $isFontColorNode(node) ? node.getColorStyle().color : \"#000\";\n });\n\n const onFontColorSelect = useCallback(\n (colorValue: string, themeColorName: string | undefined) => {\n console.log({ colorValue, themeColorName });\n editor.dispatchCommand<LexicalCommand<FontColorPayload>>(ADD_FONT_COLOR_COMMAND, {\n color: new ThemeColorValue(colorValue, themeColorName)\n });\n },\n []\n );\n\n const context = useMemo(\n () => ({\n value: fontColor,\n applyColor: onFontColorSelect\n }),\n [onFontColorSelect, fontColor]\n );\n\n return (\n <FontColorActionContext.Provider value={context}>\n <FontColorPicker />\n </FontColorActionContext.Provider>\n );\n};\n\nFontColorAction.ColorPicker = FontActionColorPicker;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAE9D,SAASC,OAAO,EAAEC,eAAe,QAAQ,2BAA2B;AACpE,SAASC,sBAAsB;AAE/B,SAASC,gBAAgB,EAAEC,sBAAsB,EAAEC,eAAe,QAAQ,uBAAuB;AACjG,SAASC,eAAe;AACxB,SAASC,2BAA2B;AACpC,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,eAAe,GAAGR,eAAe,CAAC,iBAAiB,EAAE,MAA0B;EACxFH,SAAS,CAAC,MAAM;IACZY,OAAO,CAACC,GAAG,CAAC,wDAAwD,CAAC;EACzE,CAAC,EAAE,EAAE,CAAC;EACN,OAAO,IAAI;AACf,CAAC,CAAC;AAMF,MAAMC,qBAAqB,GAAGA,CAAC;EAAEC;AAA+B,CAAC,KAAkB;EAC/E,oBAAOjB,KAAA,CAAAkB,aAAA,CAACd,OAAO;IAACe,SAAS,EAAEN,eAAgB;IAACO,IAAI,EAAEA,CAAA,KAAM,MAAMH;EAAQ,CAAE,CAAC;AAC7E,CAAC;AAMD,OAAO,MAAMI,eAAgC,GAAGA,CAAA,KAAM;EAClD,MAAM;IAAEC;EAAO,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EACtC,MAAMW,SAAS,GAAGZ,2BAA2B,CAAC,CAAC;IAAEa;EAAe,CAAC,KAAK;IAClE,IAAI,CAACA,cAAc,EAAE;MACjB,OAAO,MAAM;IACjB;IAEA,MAAMC,IAAI,GAAGf,eAAe,CAACc,cAAc,CAAC;IAC5C,OAAOjB,gBAAgB,CAACkB,IAAI,CAAC,GAAGA,IAAI,CAACC,aAAa,CAAC,CAAC,CAACC,KAAK,GAAG,MAAM;EACvE,CAAC,CAAC;EAEF,MAAMC,iBAAiB,GAAG3B,WAAW,CACjC,CAAC4B,UAAkB,EAAEC,cAAkC,KAAK;IACxDhB,OAAO,CAACC,GAAG,CAAC;MAAEc,UAAU;MAAEC;IAAe,CAAC,CAAC;IAC3CR,MAAM,CAACS,eAAe,CAAmCvB,sBAAsB,EAAE;MAC7EmB,KAAK,EAAE,IAAIlB,eAAe,CAACoB,UAAU,EAAEC,cAAc;IACzD,CAAC,CAAC;EACN,CAAC,EACD,EACJ,CAAC;EAED,MAAME,OAAO,GAAG7B,OAAO,CACnB,OAAO;IACH8B,KAAK,EAAEV,SAAS;IAChBW,UAAU,EAAEN;EAChB,CAAC,CAAC,EACF,CAACA,iBAAiB,EAAEL,SAAS,CACjC,CAAC;EAED,oBACIvB,KAAA,CAAAkB,aAAA,CAACZ,sBAAsB,CAAC6B,QAAQ;IAACF,KAAK,EAAED;EAAQ,gBAC5ChC,KAAA,CAAAkB,aAAA,CAACL,eAAe,MAAE,CACW,CAAC;AAE1C,CAAC;AAEDQ,eAAe,CAACe,WAAW,GAAGpB,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["React","useCallback","useEffect","useMemo","Compose","makeDecoratable","FontColorActionContext","$isFontColorNode","ADD_FONT_COLOR_COMMAND","ThemeColorValue","getSelectedNode","useDeriveValueFromSelection","useRichTextEditor","FontColorPicker","console","log","FontActionColorPicker","element","createElement","component","with","FontColorAction","editor","fontColor","rangeSelection","node","getColorStyle","color","onFontColorSelect","colorValue","themeColorName","dispatchCommand","context","value","applyColor","Provider","ColorPicker"],"sources":["FontColorAction.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport type { LexicalCommand } from \"lexical\";\nimport { Compose, makeDecoratable } from \"@webiny/react-composition\";\nimport { FontColorActionContext } from \"~/context/FontColorActionContext.js\";\nimport type { FontColorPayload } from \"@webiny/lexical-nodes\";\nimport { $isFontColorNode, ADD_FONT_COLOR_COMMAND, ThemeColorValue } from \"@webiny/lexical-nodes\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode.js\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const FontColorPicker = makeDecoratable(\"FontColorPicker\", (): JSX.Element | null => {\n useEffect(() => {\n console.log(\"Default FontColorPicker, please add your own component\");\n }, []);\n return null;\n});\n\ninterface FontActionColorPicker {\n element: JSX.Element;\n}\n\nconst FontActionColorPicker = ({ element }: FontActionColorPicker): JSX.Element => {\n return <Compose component={FontColorPicker} with={() => () => element} />;\n};\n\nexport type FontColorAction = React.ComponentType<unknown> & {\n ColorPicker: typeof FontActionColorPicker;\n};\n\nexport const FontColorAction: FontColorAction = () => {\n const { editor } = useRichTextEditor();\n const fontColor = useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return \"#000\";\n }\n\n const node = getSelectedNode(rangeSelection);\n return $isFontColorNode(node) ? node.getColorStyle().color : \"#000\";\n });\n\n const onFontColorSelect = useCallback(\n (colorValue: string, themeColorName: string | undefined) => {\n editor.dispatchCommand<LexicalCommand<FontColorPayload>>(ADD_FONT_COLOR_COMMAND, {\n color: new ThemeColorValue(colorValue, themeColorName)\n });\n },\n []\n );\n\n const context = useMemo(\n () => ({\n value: fontColor,\n applyColor: onFontColorSelect\n }),\n [onFontColorSelect, fontColor]\n );\n\n return (\n <FontColorActionContext.Provider value={context}>\n <FontColorPicker />\n </FontColorActionContext.Provider>\n );\n};\n\nFontColorAction.ColorPicker = FontActionColorPicker;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAE9D,SAASC,OAA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,MAAME,OAAO,GAAG7B,OAAO,CACnB,OAAO;IACH8B,KAAK,EAAEV,SAAS;IAChBW,UAAU,EAAEN;EAChB,CAAC,CAAC,EACF,CAACA,iBAAiB,EAAEL,SAAS,CACjC,CAAC;EAED,oBACIvB,KAAA,CAAAkB,aAAA,CAACZ,sBAAsB,CAAC6B,QAAQ;IAACF,KAAK,EAAED;EAAQ,gBAC5ChC,KAAA,CAAAkB,aAAA,CAACL,eAAe,MAAE,CACW,CAAC;AAE1C,CAAC;AAEDQ,eAAe,CAACe,WAAW,GAAGpB,qBAAqB","ignoreList":[]}
@@ -4,6 +4,7 @@ import { type EditorTheme, Theme } from "@webiny/lexical-theme";
4
4
  import type { ToolbarActionPlugin } from "../types.js";
5
5
  export interface RichTextEditorContext {
6
6
  editor: LexicalEditor;
7
+ getOverlaysElement: () => HTMLElement;
7
8
  toolbarActionPlugins: ToolbarActionPlugin[];
8
9
  theme: Theme;
9
10
  }
@@ -1,4 +1,4 @@
1
- import React, { createContext, useMemo } from "react";
1
+ import React, { createContext, useCallback, useMemo } from "react";
2
2
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
3
  import { Theme } from "@webiny/lexical-theme";
4
4
  export const RichTextEditorContext = /*#__PURE__*/createContext(undefined);
@@ -8,10 +8,23 @@ export const RichTextEditorProvider = ({
8
8
  children
9
9
  }) => {
10
10
  const [editor] = useLexicalComposerContext();
11
+ const getOverlaysElement = useCallback(() => {
12
+ const rootElement = editor.getRootElement();
13
+ if (!rootElement) {
14
+ return document.body;
15
+ }
16
+ const shell = rootElement.closest(".editor-shell");
17
+ if (!shell) {
18
+ return document.body;
19
+ }
20
+ const overlays = shell.previousElementSibling;
21
+ return overlays ?? document.body;
22
+ }, [editor]);
11
23
  const internalTheme = useMemo(() => new Theme(theme.colors, theme.typography, theme.tokens), [theme]);
12
24
  return /*#__PURE__*/React.createElement(RichTextEditorContext.Provider, {
13
25
  value: {
14
26
  editor,
27
+ getOverlaysElement,
15
28
  theme: internalTheme,
16
29
  toolbarActionPlugins
17
30
  }
@@ -1 +1 @@
1
- {"version":3,"names":["React","createContext","useMemo","useLexicalComposerContext","Theme","RichTextEditorContext","undefined","RichTextEditorProvider","theme","toolbarActionPlugins","children","editor","internalTheme","colors","typography","tokens","createElement","Provider","value"],"sources":["RichTextEditorContext.tsx"],"sourcesContent":["import React, { createContext, useMemo } from \"react\";\nimport type { LexicalEditor } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { type EditorTheme, Theme } from \"@webiny/lexical-theme\";\nimport type { ToolbarActionPlugin } from \"~/types.js\";\n\nexport interface RichTextEditorContext {\n editor: LexicalEditor;\n toolbarActionPlugins: ToolbarActionPlugin[];\n theme: Theme;\n}\n\nexport const RichTextEditorContext = createContext<RichTextEditorContext | undefined>(undefined);\n\ninterface RichTextEditorProviderProps {\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const RichTextEditorProvider = ({\n theme,\n toolbarActionPlugins = [],\n children\n}: RichTextEditorProviderProps) => {\n const [editor] = useLexicalComposerContext();\n\n const internalTheme = useMemo(\n () => new Theme(theme.colors, theme.typography, theme.tokens),\n [theme]\n );\n\n return (\n <RichTextEditorContext.Provider\n value={{\n editor,\n theme: internalTheme,\n toolbarActionPlugins\n }}\n >\n {children}\n </RichTextEditorContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,OAAO,QAAQ,OAAO;AAErD,SAASC,yBAAyB,QAAQ,uCAAuC;AACjF,SAA2BC,KAAK,QAAQ,uBAAuB;AAS/D,OAAO,MAAMC,qBAAqB,gBAAGJ,aAAa,CAAoCK,SAAS,CAAC;AAQhG,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EACnCC,KAAK;EACLC,oBAAoB,GAAG,EAAE;EACzBC;AACyB,CAAC,KAAK;EAC/B,MAAM,CAACC,MAAM,CAAC,GAAGR,yBAAyB,CAAC,CAAC;EAE5C,MAAMS,aAAa,GAAGV,OAAO,CACzB,MAAM,IAAIE,KAAK,CAACI,KAAK,CAACK,MAAM,EAAEL,KAAK,CAACM,UAAU,EAAEN,KAAK,CAACO,MAAM,CAAC,EAC7D,CAACP,KAAK,CACV,CAAC;EAED,oBACIR,KAAA,CAAAgB,aAAA,CAACX,qBAAqB,CAACY,QAAQ;IAC3BC,KAAK,EAAE;MACHP,MAAM;MACNH,KAAK,EAAEI,aAAa;MACpBH;IACJ;EAAE,GAEDC,QAC2B,CAAC;AAEzC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","createContext","useCallback","useMemo","useLexicalComposerContext","Theme","RichTextEditorContext","undefined","RichTextEditorProvider","theme","toolbarActionPlugins","children","editor","getOverlaysElement","rootElement","getRootElement","document","body","shell","closest","overlays","previousElementSibling","internalTheme","colors","typography","tokens","createElement","Provider","value"],"sources":["RichTextEditorContext.tsx"],"sourcesContent":["import React, { createContext, useCallback, useMemo } from \"react\";\nimport type { LexicalEditor } from \"lexical\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { type EditorTheme, Theme } from \"@webiny/lexical-theme\";\nimport type { ToolbarActionPlugin } from \"~/types.js\";\n\nexport interface RichTextEditorContext {\n editor: LexicalEditor;\n getOverlaysElement: () => HTMLElement;\n toolbarActionPlugins: ToolbarActionPlugin[];\n theme: Theme;\n}\n\nexport const RichTextEditorContext = createContext<RichTextEditorContext | undefined>(undefined);\n\ninterface RichTextEditorProviderProps {\n theme: EditorTheme;\n toolbarActionPlugins?: ToolbarActionPlugin[];\n children?: React.ReactNode | React.ReactNode[];\n}\n\nexport const RichTextEditorProvider = ({\n theme,\n toolbarActionPlugins = [],\n children\n}: RichTextEditorProviderProps) => {\n const [editor] = useLexicalComposerContext();\n\n const getOverlaysElement = useCallback(() => {\n const rootElement = editor.getRootElement();\n if (!rootElement) {\n return document.body;\n }\n\n const shell = rootElement.closest(\".editor-shell\");\n if (!shell) {\n return document.body;\n }\n const overlays = shell.previousElementSibling;\n\n return (overlays ?? document.body) as HTMLElement;\n }, [editor]);\n\n const internalTheme = useMemo(\n () => new Theme(theme.colors, theme.typography, theme.tokens),\n [theme]\n );\n\n return (\n <RichTextEditorContext.Provider\n value={{\n editor,\n getOverlaysElement,\n theme: internalTheme,\n toolbarActionPlugins\n }}\n >\n {children}\n </RichTextEditorContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAElE,SAASC,yBAAyB,QAAQ,uCAAuC;AACjF,SAA2BC,KAAK,QAAQ,uBAAuB;AAU/D,OAAO,MAAMC,qBAAqB,gBAAGL,aAAa,CAAoCM,SAAS,CAAC;AAQhG,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EACnCC,KAAK;EACLC,oBAAoB,GAAG,EAAE;EACzBC;AACyB,CAAC,KAAK;EAC/B,MAAM,CAACC,MAAM,CAAC,GAAGR,yBAAyB,CAAC,CAAC;EAE5C,MAAMS,kBAAkB,GAAGX,WAAW,CAAC,MAAM;IACzC,MAAMY,WAAW,GAAGF,MAAM,CAACG,cAAc,CAAC,CAAC;IAC3C,IAAI,CAACD,WAAW,EAAE;MACd,OAAOE,QAAQ,CAACC,IAAI;IACxB;IAEA,MAAMC,KAAK,GAAGJ,WAAW,CAACK,OAAO,CAAC,eAAe,CAAC;IAClD,IAAI,CAACD,KAAK,EAAE;MACR,OAAOF,QAAQ,CAACC,IAAI;IACxB;IACA,MAAMG,QAAQ,GAAGF,KAAK,CAACG,sBAAsB;IAE7C,OAAQD,QAAQ,IAAIJ,QAAQ,CAACC,IAAI;EACrC,CAAC,EAAE,CAACL,MAAM,CAAC,CAAC;EAEZ,MAAMU,aAAa,GAAGnB,OAAO,CACzB,MAAM,IAAIE,KAAK,CAACI,KAAK,CAACc,MAAM,EAAEd,KAAK,CAACe,UAAU,EAAEf,KAAK,CAACgB,MAAM,CAAC,EAC7D,CAAChB,KAAK,CACV,CAAC;EAED,oBACIT,KAAA,CAAA0B,aAAA,CAACpB,qBAAqB,CAACqB,QAAQ;IAC3BC,KAAK,EAAE;MACHhB,MAAM;MACNC,kBAAkB;MAClBJ,KAAK,EAAEa,aAAa;MACpBZ;IACJ;EAAE,GAEDC,QAC2B,CAAC;AAEzC,CAAC","ignoreList":[]}
@@ -1,5 +1,4 @@
1
- import { $findMatchingParent } from "@lexical/utils";
2
- import { $isRootOrShadowRoot } from "lexical";
1
+ import { $isRootOrShadowRoot, $findMatchingParent } from "lexical";
3
2
  import { useDeriveValueFromSelection } from "./useCurrentSelection.js";
4
3
  export function useCurrentElement() {
5
4
  return useDeriveValueFromSelection(({
@@ -1 +1 @@
1
- {"version":3,"names":["$findMatchingParent","$isRootOrShadowRoot","useDeriveValueFromSelection","useCurrentElement","rangeSelection","element","getNodeFromSelection","selection","anchorNode","anchor","getNode","getKey","e","parent","getParent","getTopLevelElementOrThrow"],"sources":["useCurrentElement.ts"],"sourcesContent":["import { $findMatchingParent } from \"@lexical/utils\";\nimport type { RangeSelection } from \"lexical\";\nimport { $isRootOrShadowRoot } from \"lexical\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\n\nexport function useCurrentElement() {\n return useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return { element: null };\n }\n\n return { element: getNodeFromSelection(rangeSelection) };\n });\n}\n\nexport function getNodeFromSelection(selection: RangeSelection) {\n const anchorNode = selection.anchor.getNode();\n\n const element =\n anchorNode.getKey() === \"root\"\n ? anchorNode\n : $findMatchingParent(anchorNode, e => {\n const parent = e.getParent();\n return parent !== null && $isRootOrShadowRoot(parent);\n });\n\n return element || anchorNode.getTopLevelElementOrThrow();\n}\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,gBAAgB;AAEpD,SAASC,mBAAmB,QAAQ,SAAS;AAC7C,SAASC,2BAA2B;AAEpC,OAAO,SAASC,iBAAiBA,CAAA,EAAG;EAChC,OAAOD,2BAA2B,CAAC,CAAC;IAAEE;EAAe,CAAC,KAAK;IACvD,IAAI,CAACA,cAAc,EAAE;MACjB,OAAO;QAAEC,OAAO,EAAE;MAAK,CAAC;IAC5B;IAEA,OAAO;MAAEA,OAAO,EAAEC,oBAAoB,CAACF,cAAc;IAAE,CAAC;EAC5D,CAAC,CAAC;AACN;AAEA,OAAO,SAASE,oBAAoBA,CAACC,SAAyB,EAAE;EAC5D,MAAMC,UAAU,GAAGD,SAAS,CAACE,MAAM,CAACC,OAAO,CAAC,CAAC;EAE7C,MAAML,OAAO,GACTG,UAAU,CAACG,MAAM,CAAC,CAAC,KAAK,MAAM,GACxBH,UAAU,GACVR,mBAAmB,CAACQ,UAAU,EAAEI,CAAC,IAAI;IACjC,MAAMC,MAAM,GAAGD,CAAC,CAACE,SAAS,CAAC,CAAC;IAC5B,OAAOD,MAAM,KAAK,IAAI,IAAIZ,mBAAmB,CAACY,MAAM,CAAC;EACzD,CAAC,CAAC;EAEZ,OAAOR,OAAO,IAAIG,UAAU,CAACO,yBAAyB,CAAC,CAAC;AAC5D","ignoreList":[]}
1
+ {"version":3,"names":["$isRootOrShadowRoot","$findMatchingParent","useDeriveValueFromSelection","useCurrentElement","rangeSelection","element","getNodeFromSelection","selection","anchorNode","anchor","getNode","getKey","e","parent","getParent","getTopLevelElementOrThrow"],"sources":["useCurrentElement.ts"],"sourcesContent":["import type { RangeSelection } from \"lexical\";\nimport { $isRootOrShadowRoot, $findMatchingParent } from \"lexical\";\nimport { useDeriveValueFromSelection } from \"~/hooks/useCurrentSelection.js\";\n\nexport function useCurrentElement() {\n return useDeriveValueFromSelection(({ rangeSelection }) => {\n if (!rangeSelection) {\n return { element: null };\n }\n\n return { element: getNodeFromSelection(rangeSelection) };\n });\n}\n\nexport function getNodeFromSelection(selection: RangeSelection) {\n const anchorNode = selection.anchor.getNode();\n\n const element =\n anchorNode.getKey() === \"root\"\n ? anchorNode\n : $findMatchingParent(anchorNode, e => {\n const parent = e.getParent();\n return parent !== null && $isRootOrShadowRoot(parent);\n });\n\n return element || anchorNode.getTopLevelElementOrThrow();\n}\n"],"mappings":"AACA,SAASA,mBAAmB,EAAEC,mBAAmB,QAAQ,SAAS;AAClE,SAASC,2BAA2B;AAEpC,OAAO,SAASC,iBAAiBA,CAAA,EAAG;EAChC,OAAOD,2BAA2B,CAAC,CAAC;IAAEE;EAAe,CAAC,KAAK;IACvD,IAAI,CAACA,cAAc,EAAE;MACjB,OAAO;QAAEC,OAAO,EAAE;MAAK,CAAC;IAC5B;IAEA,OAAO;MAAEA,OAAO,EAAEC,oBAAoB,CAACF,cAAc;IAAE,CAAC;EAC5D,CAAC,CAAC;AACN;AAEA,OAAO,SAASE,oBAAoBA,CAACC,SAAyB,EAAE;EAC5D,MAAMC,UAAU,GAAGD,SAAS,CAACE,MAAM,CAACC,OAAO,CAAC,CAAC;EAE7C,MAAML,OAAO,GACTG,UAAU,CAACG,MAAM,CAAC,CAAC,KAAK,MAAM,GACxBH,UAAU,GACVP,mBAAmB,CAACO,UAAU,EAAEI,CAAC,IAAI;IACjC,MAAMC,MAAM,GAAGD,CAAC,CAACE,SAAS,CAAC,CAAC;IAC5B,OAAOD,MAAM,KAAK,IAAI,IAAIb,mBAAmB,CAACa,MAAM,CAAC;EACzD,CAAC,CAAC;EAEZ,OAAOR,OAAO,IAAIG,UAAU,CAACO,yBAAyB,CAAC,CAAC;AAC5D","ignoreList":[]}
package/index.d.ts CHANGED
@@ -15,7 +15,6 @@ export { UnderlineAction } from "./components/ToolbarActions/UnderlineAction.js"
15
15
  export { TypographyAction } from "./components/ToolbarActions/TypographyAction.js";
16
16
  export { TextAlignmentAction } from "./components/ToolbarActions/TextAlignmentAction.js";
17
17
  export { ImageAction } from "./components/ToolbarActions/ImageAction.js";
18
- export { Toolbar } from "./components/Toolbar/Toolbar.js";
19
18
  export { StaticToolbar } from "./components/Toolbar/StaticToolbar.js";
20
19
  export { RichTextEditor } from "./components/Editor/RichTextEditor.js";
21
20
  export { LinkPlugin } from "./plugins/LinkPlugin/LinkPlugin.js";