@webiny/lexical-nodes 6.0.0-beta.0 → 6.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/FontColorNode.d.ts +24 -22
  2. package/FontColorNode.js +114 -103
  3. package/FontColorNode.js.map +1 -1
  4. package/HeadingNode.d.ts +30 -20
  5. package/HeadingNode.js +185 -176
  6. package/HeadingNode.js.map +1 -1
  7. package/ImageNode.d.ts +2 -12
  8. package/ImageNode.js +119 -193
  9. package/ImageNode.js.map +1 -1
  10. package/LinkNode.d.ts +6 -6
  11. package/LinkNode.js +249 -347
  12. package/LinkNode.js.map +1 -1
  13. package/ListItemNode.d.ts +6 -5
  14. package/ListItemNode.js +275 -352
  15. package/ListItemNode.js.map +1 -1
  16. package/ListNode.d.ts +32 -19
  17. package/ListNode.js +170 -210
  18. package/ListNode.js.map +1 -1
  19. package/ParagraphNode.d.ts +30 -20
  20. package/ParagraphNode.js +144 -201
  21. package/ParagraphNode.js.map +1 -1
  22. package/QuoteNode.d.ts +27 -20
  23. package/QuoteNode.js +102 -208
  24. package/QuoteNode.js.map +1 -1
  25. package/README.md +9 -4
  26. package/components/ImageNode/ImageComponent.d.ts +2 -7
  27. package/components/ImageNode/ImageComponent.js +72 -166
  28. package/components/ImageNode/ImageComponent.js.map +1 -1
  29. package/components/ImageNode/ImageResizer.d.ts +1 -8
  30. package/components/ImageNode/ImageResizer.js +80 -95
  31. package/components/ImageNode/ImageResizer.js.map +1 -1
  32. package/generateInitialLexicalValue.d.ts +4 -0
  33. package/generateInitialLexicalValue.js +27 -0
  34. package/generateInitialLexicalValue.js.map +1 -0
  35. package/index.d.ts +19 -23
  36. package/index.js +50 -233
  37. package/index.js.map +1 -1
  38. package/package.json +22 -19
  39. package/prepareLexicalState.d.ts +2 -0
  40. package/prepareLexicalState.js +53 -0
  41. package/prepareLexicalState.js.map +1 -0
  42. package/types.d.ts +5 -9
  43. package/types.js +1 -5
  44. package/types.js.map +1 -1
  45. package/utils/clearNodeFormating.d.ts +2 -2
  46. package/utils/clearNodeFormating.js +12 -18
  47. package/utils/clearNodeFormating.js.map +1 -1
  48. package/utils/formatList.d.ts +4 -4
  49. package/utils/formatList.js +171 -208
  50. package/utils/formatList.js.map +1 -1
  51. package/utils/formatToHeading.d.ts +2 -2
  52. package/utils/formatToHeading.js +8 -15
  53. package/utils/formatToHeading.js.map +1 -1
  54. package/utils/formatToParagraph.d.ts +1 -1
  55. package/utils/formatToParagraph.js +8 -16
  56. package/utils/formatToParagraph.js.map +1 -1
  57. package/utils/formatToQuote.d.ts +1 -1
  58. package/utils/formatToQuote.js +10 -17
  59. package/utils/formatToQuote.js.map +1 -1
  60. package/utils/getStyleId.d.ts +11 -0
  61. package/utils/getStyleId.js +14 -0
  62. package/utils/getStyleId.js.map +1 -0
  63. package/utils/listNode.d.ts +14 -4
  64. package/utils/listNode.js +43 -49
  65. package/utils/listNode.js.map +1 -1
  66. package/utils/toggleLink.d.ts +1 -1
  67. package/utils/toggleLink.js +41 -45
  68. package/utils/toggleLink.js.map +1 -1
  69. package/TypographyNode.d.ts +0 -39
  70. package/TypographyNode.js +0 -147
  71. package/TypographyNode.js.map +0 -1
  72. package/components/ImageNode/ContentEditable.css +0 -22
  73. package/components/ImageNode/ContentEditable.d.ts +0 -12
  74. package/components/ImageNode/ContentEditable.js +0 -26
  75. package/components/ImageNode/ContentEditable.js.map +0 -1
  76. package/components/ImageNode/ImageComponent.css +0 -43
  77. package/components/ImageNode/Placeholder.css +0 -20
  78. package/components/ImageNode/Placeholder.d.ts +0 -15
  79. package/components/ImageNode/Placeholder.js +0 -30
  80. package/components/ImageNode/Placeholder.js.map +0 -1
  81. package/components/ImageNode/SharedHistoryContext.d.ts +0 -10
  82. package/components/ImageNode/SharedHistoryContext.js +0 -27
  83. package/components/ImageNode/SharedHistoryContext.js.map +0 -1
package/ParagraphNode.js CHANGED
@@ -1,215 +1,158 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.$createParagraphNode = $createParagraphNode;
8
- exports.$isParagraphNode = $isParagraphNode;
9
- exports.ParagraphNode = void 0;
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
15
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
16
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
17
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
18
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
- var _lexical = require("lexical");
20
- var _lexicalTheme = require("@webiny/lexical-theme");
21
- var _utils = require("@lexical/utils");
22
- var ParagraphNode = exports.ParagraphNode = /*#__PURE__*/function (_BaseParagraphNode) {
23
- function ParagraphNode(typographyStyleId, key) {
24
- var _this;
25
- (0, _classCallCheck2.default)(this, ParagraphNode);
26
- _this = (0, _callSuper2.default)(this, ParagraphNode, [key]);
27
- (0, _defineProperty2.default)(_this, "__styles", []);
28
- if (typographyStyleId) {
29
- _this.__styles.push({
30
- styleId: typographyStyleId,
31
- type: "typography"
32
- });
33
- }
34
- return _this;
35
- }
36
- (0, _inherits2.default)(ParagraphNode, _BaseParagraphNode);
37
- return (0, _createClass2.default)(ParagraphNode, [{
38
- key: "setDefaultTypography",
39
- value: function setDefaultTypography(themeEmotionMap) {
40
- var typographyStyle = (0, _lexicalTheme.findTypographyStyleByHtmlTag)("p", themeEmotionMap);
41
- if (typographyStyle) {
42
- this.__styles.push({
43
- styleId: typographyStyle.id,
44
- type: "typography"
45
- });
46
- }
47
- }
48
- }, {
49
- key: "setTypography",
50
- value: function setTypography(typographyStyleId) {
51
- var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getWritable", this).call(this);
52
- var themeStyle = {
53
- styleId: typographyStyleId,
54
- type: "typography"
55
- };
56
- self.__styles.push(themeStyle);
57
- return self;
58
- }
59
- }, {
60
- key: "getTypographyStyleId",
61
- value: function getTypographyStyleId() {
62
- var style = this.__styles.find(function (x) {
63
- return x.type === "typography";
64
- });
65
- return style?.styleId || undefined;
66
- }
67
- }, {
68
- key: "clearTypographyStyle",
69
- value: function clearTypographyStyle() {
70
- var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getWritable", this).call(this);
71
- self.__styles = self.__styles.filter(function (s) {
72
- return s.type !== "typography";
73
- });
74
- return self;
75
- }
76
- }, {
77
- key: "hasTypographyStyle",
78
- value: function hasTypographyStyle() {
79
- return !!this.getTypographyStyleId();
80
- }
81
- }, {
82
- key: "getThemeStyles",
83
- value: function getThemeStyles() {
84
- // getLatest() ensures we are getting the most
85
- // up-to-date value from the EditorState.
86
- var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getLatest", this).call(this);
87
- return self.__styles;
1
+ import { ParagraphNode as BaseParagraphNode, addClassNamesToElement } from "lexical";
2
+ import { Theme } from "@webiny/lexical-theme";
3
+ import { getStyleId } from "./utils/getStyleId.js";
4
+ function convertParagraphElement(element) {
5
+ const node = $createParagraphNode();
6
+ if (element.style) {
7
+ node.setFormat(element.style.textAlign);
8
+ }
9
+ return {
10
+ node
11
+ };
12
+ }
13
+ export class ParagraphNode extends BaseParagraphNode {
14
+ constructor(options = {}) {
15
+ const {
16
+ styleId,
17
+ key,
18
+ className
19
+ } = options;
20
+ super(key);
21
+ this.__styleId = styleId;
22
+ this.__className = className;
23
+ }
24
+ getStyleId() {
25
+ return this.__styleId;
26
+ }
27
+ setStyleId(styleId) {
28
+ this.__styleId = styleId;
29
+ }
30
+ setClassName(className) {
31
+ this.__className = className;
32
+ }
33
+ getClassName() {
34
+ return this.__className;
35
+ }
36
+ static getType() {
37
+ return "wby-paragraph";
38
+ }
39
+ static clone(node) {
40
+ return new ParagraphNode({
41
+ styleId: node.getStyleId(),
42
+ className: node.getClassName(),
43
+ key: node.__key
44
+ });
45
+ }
46
+ insertNewAfter(rangeSelection, restoreSelection) {
47
+ const newElement = $createParagraphNode();
48
+ newElement.setTextFormat(rangeSelection.format);
49
+ newElement.setTextStyle(rangeSelection.style);
50
+ const direction = this.getDirection();
51
+ newElement.setDirection(direction);
52
+ newElement.setFormat(this.getFormatType());
53
+ newElement.setStyle(this.getStyle());
54
+ this.insertAfter(newElement, restoreSelection);
55
+ return newElement;
56
+ }
57
+ createDOM(config) {
58
+ const element = super.createDOM(config);
59
+ return this.updateElementWithThemeClasses(element, Theme.from(config.theme));
60
+ }
61
+ exportDOM(editor) {
62
+ const base = super.exportDOM(editor);
63
+ const element = base.element;
64
+ if (element && this.__className) {
65
+ element.classList.add(this.__className);
66
+ }
67
+ return {
68
+ ...base,
69
+ element
70
+ };
71
+ }
72
+ updateDOM(prevNode, dom, config) {
73
+ const prevTypoStyleId = prevNode.getStyleId();
74
+ const nextTypoStyleId = this.getStyleId();
75
+ if (!nextTypoStyleId) {
76
+ this.updateElementWithThemeClasses(dom, Theme.from(config.theme));
77
+ return false;
88
78
  }
89
- }, {
90
- key: "setThemeStyles",
91
- value: function setThemeStyles(styles) {
92
- // getWritable() creates a clone of the node
93
- // if needed, to ensure we don't try and mutate
94
- // a stale version of this node.
95
- var self = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "getWritable", this).call(this);
96
- self.__styles = (0, _toConsumableArray2.default)(styles);
97
- return self;
79
+ if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {
80
+ this.updateElementWithThemeClasses(dom, Theme.from(config.theme));
98
81
  }
99
- }, {
100
- key: "updateElementWithThemeClasses",
101
- value: function updateElementWithThemeClasses(element, theme) {
102
- if (!theme?.emotionMap) {
103
- return element;
104
- }
105
- if (!this.hasTypographyStyle()) {
106
- this.setDefaultTypography(theme.emotionMap);
107
- }
108
- var typoStyleId = this.getTypographyStyleId();
109
- var themeClasses;
82
+ // Returning false tells Lexical that this node does not need its
83
+ // DOM element replacing with a new copy from createDOM.
84
+ return false;
85
+ }
110
86
 
111
- // Typography css class
112
- if (typoStyleId) {
113
- var typographyStyle = theme.emotionMap[typoStyleId];
114
- if (typographyStyle) {
115
- themeClasses = typographyStyle.className;
116
- }
117
- }
118
- if (themeClasses) {
119
- (0, _utils.addClassNamesToElement)(element, themeClasses);
120
- }
121
- return element;
122
- }
123
- }, {
124
- key: "createDOM",
125
- value: function createDOM(config) {
126
- var element = (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "createDOM", this).call(this, config);
127
- return this.updateElementWithThemeClasses(element, config.theme);
128
- }
129
- }, {
130
- key: "updateDOM",
131
- value: function updateDOM(prevNode, dom, config) {
132
- var prevTypoStyleId = prevNode.getTypographyStyleId();
133
- var nextTypoStyleId = this.getTypographyStyleId();
134
- if (!nextTypoStyleId) {
135
- this.updateElementWithThemeClasses(dom, config.theme);
136
- return false;
137
- }
138
- if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {
139
- this.updateElementWithThemeClasses(dom, config.theme);
140
- }
141
- // Returning false tells Lexical that this node does not need its
142
- // DOM element replacing with a new copy from createDOM.
143
- return false;
144
- }
87
+ /*
88
+ * On copy/paste event this method will be executed in and create a node
89
+ * */
90
+ static importDOM() {
91
+ return {
92
+ p: () => ({
93
+ conversion: convertParagraphElement,
94
+ priority: 0
95
+ })
96
+ };
97
+ }
145
98
 
146
- /*
147
- * On copy/paste event this method will be executed in and create a node
148
- * */
149
- }, {
150
- key: "exportJSON",
151
- value:
152
- /*
153
- * Serialize the node to JSON data representation.
154
- * */
155
- function exportJSON() {
156
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(ParagraphNode.prototype), "exportJSON", this).call(this)), {}, {
157
- styles: this.__styles,
158
- type: "paragraph-element",
159
- version: 1
160
- });
161
- }
162
- }], [{
163
- key: "getType",
164
- value: function getType() {
165
- return "paragraph-element";
99
+ /*
100
+ * Serialize the JSON data back into a node
101
+ */
102
+ static importJSON(serializedNode) {
103
+ const node = $createParagraphNode();
104
+ node.setFormat(serializedNode.format);
105
+ node.setIndent(serializedNode.indent);
106
+ node.setDirection(serializedNode.direction);
107
+ const styleId = getStyleId({
108
+ styleId: serializedNode.styleId,
109
+ styles: serializedNode.styles
110
+ });
111
+ node.setStyleId(styleId);
112
+ node.setClassName(serializedNode.className);
113
+ return node;
114
+ }
115
+
116
+ /*
117
+ * Serialize the node to JSON data representation.
118
+ * */
119
+ exportJSON() {
120
+ return {
121
+ ...super.exportJSON(),
122
+ styleId: this.__styleId,
123
+ className: this.__className,
124
+ type: "wby-paragraph"
125
+ };
126
+ }
127
+ updateElementWithThemeClasses(element, theme) {
128
+ if (!this.__styleId || !this.__className) {
129
+ this.setDefaultTypography(theme, this.__styleId);
166
130
  }
167
- }, {
168
- key: "clone",
169
- value: function clone(node) {
170
- return new ParagraphNode(node.getTypographyStyleId(), node.__key);
131
+ if (this.__className) {
132
+ addClassNamesToElement(element, this.__className);
171
133
  }
172
- }, {
173
- key: "importDOM",
174
- value: function importDOM() {
175
- return {
176
- p: function p() {
177
- return {
178
- conversion: convertParagraphElement,
179
- priority: 0
180
- };
181
- }
182
- };
134
+ return element;
135
+ }
136
+ setDefaultTypography(theme, styleId) {
137
+ let typographyStyle = theme.getTypographyByTag("p");
138
+ if (styleId) {
139
+ const byStyleId = theme.getTypographyById(styleId);
140
+ if (byStyleId) {
141
+ typographyStyle = byStyleId;
142
+ }
183
143
  }
184
-
185
- /*
186
- * Serialize the JSON data back into a node
187
- */
188
- }, {
189
- key: "importJSON",
190
- value: function importJSON(serializedNode) {
191
- var node = $createParagraphNode();
192
- node.setFormat(serializedNode.format);
193
- node.setIndent(serializedNode.indent);
194
- node.setDirection(serializedNode.direction);
195
- node.setThemeStyles(serializedNode.styles);
196
- return node;
144
+ if (typographyStyle) {
145
+ this.__styleId = typographyStyle.id;
146
+ this.__className = typographyStyle.className;
197
147
  }
198
- }]);
199
- }(_lexical.ParagraphNode);
200
- function convertParagraphElement(element) {
201
- var node = $createParagraphNode();
202
- if (element.style) {
203
- node.setFormat(element.style.textAlign);
204
148
  }
205
- return {
206
- node: node
207
- };
208
149
  }
209
- function $createParagraphNode(typographyStyleId) {
210
- return (0, _lexical.$applyNodeReplacement)(new ParagraphNode(typographyStyleId));
150
+ export function $createParagraphNode(styleId) {
151
+ return new ParagraphNode({
152
+ styleId
153
+ });
211
154
  }
212
- function $isParagraphNode(node) {
155
+ export function $isParagraphNode(node) {
213
156
  return node instanceof ParagraphNode;
214
157
  }
215
158
 
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","_lexicalTheme","_utils","ParagraphNode","exports","_BaseParagraphNode","typographyStyleId","key","_this","_classCallCheck2","default","_callSuper2","_defineProperty2","__styles","push","styleId","type","_inherits2","_createClass2","value","setDefaultTypography","themeEmotionMap","typographyStyle","findTypographyStyleByHtmlTag","id","setTypography","self","_get2","_getPrototypeOf2","prototype","call","themeStyle","getTypographyStyleId","style","find","x","undefined","clearTypographyStyle","filter","s","hasTypographyStyle","getThemeStyles","setThemeStyles","styles","_toConsumableArray2","updateElementWithThemeClasses","element","theme","emotionMap","typoStyleId","themeClasses","className","addClassNamesToElement","createDOM","config","updateDOM","prevNode","dom","prevTypoStyleId","nextTypoStyleId","exportJSON","_objectSpread2","version","getType","clone","node","__key","importDOM","p","conversion","convertParagraphElement","priority","importJSON","serializedNode","$createParagraphNode","setFormat","format","setIndent","indent","setDirection","direction","BaseParagraphNode","textAlign","$applyNodeReplacement","$isParagraphNode"],"sources":["ParagraphNode.ts"],"sourcesContent":["import {\n $applyNodeReplacement,\n DOMConversionMap,\n DOMConversionOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n ParagraphNode as BaseParagraphNode,\n SerializedParagraphNode as SerializedBaseParagraphNode,\n Spread\n} from \"lexical\";\nimport { EditorConfig } from \"lexical\";\nimport { WebinyTheme, ThemeEmotionMap, findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from \"~/types\";\n\nexport type SerializeParagraphNode = Spread<\n {\n styles: ThemeStyleValue[];\n type: \"paragraph-element\";\n },\n SerializedBaseParagraphNode\n>;\n\nexport class ParagraphNode\n extends BaseParagraphNode\n implements TextNodeThemeStyles, TypographyStylesNode\n{\n __styles: ThemeStyleValue[] = [];\n\n constructor(typographyStyleId?: string, key?: NodeKey) {\n super(key);\n\n if (typographyStyleId) {\n this.__styles.push({ styleId: typographyStyleId, type: \"typography\" });\n }\n }\n\n protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap) {\n const typographyStyle = findTypographyStyleByHtmlTag(\"p\", themeEmotionMap);\n if (typographyStyle) {\n this.__styles.push({ styleId: typographyStyle.id, type: \"typography\" });\n }\n }\n\n setTypography(typographyStyleId: string): this {\n const self = super.getWritable();\n const themeStyle = {\n styleId: typographyStyleId,\n type: \"typography\"\n } as ThemeStyleValue;\n self.__styles.push(themeStyle);\n return self;\n }\n\n getTypographyStyleId(): string | undefined {\n const style = this.__styles.find(x => x.type === \"typography\");\n return style?.styleId || undefined;\n }\n\n clearTypographyStyle(): this {\n const self = super.getWritable();\n self.__styles = self.__styles.filter(s => s.type !== \"typography\");\n return self;\n }\n\n hasTypographyStyle(): boolean {\n return !!this.getTypographyStyleId();\n }\n\n getThemeStyles(): ThemeStyleValue[] {\n // getLatest() ensures we are getting the most\n // up-to-date value from the EditorState.\n const self = super.getLatest();\n return self.__styles;\n }\n\n setThemeStyles(styles: ThemeStyleValue[]) {\n // getWritable() creates a clone of the node\n // if needed, to ensure we don't try and mutate\n // a stale version of this node.\n const self = super.getWritable();\n self.__styles = [...styles];\n return self;\n }\n\n static override getType(): string {\n return \"paragraph-element\";\n }\n\n static override clone(node: ParagraphNode): ParagraphNode {\n return new ParagraphNode(node.getTypographyStyleId(), node.__key);\n }\n\n protected updateElementWithThemeClasses(element: HTMLElement, theme: WebinyTheme): HTMLElement {\n if (!theme?.emotionMap) {\n return element;\n }\n\n if (!this.hasTypographyStyle()) {\n this.setDefaultTypography(theme.emotionMap);\n }\n\n const typoStyleId = this.getTypographyStyleId();\n\n let themeClasses;\n\n // Typography css class\n if (typoStyleId) {\n const typographyStyle = theme.emotionMap[typoStyleId];\n if (typographyStyle) {\n themeClasses = typographyStyle.className;\n }\n }\n\n if (themeClasses) {\n addClassNamesToElement(element, themeClasses);\n }\n\n return element;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.updateElementWithThemeClasses(element, config.theme as WebinyTheme);\n }\n\n override updateDOM(\n prevNode: BaseParagraphNode,\n dom: HTMLElement,\n config: EditorConfig\n ): boolean {\n const prevTypoStyleId = prevNode.getTypographyStyleId();\n const nextTypoStyleId = this.getTypographyStyleId();\n\n if (!nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as WebinyTheme);\n return false;\n }\n\n if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, config.theme as WebinyTheme);\n }\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n\n /*\n * On copy/paste event this method will be executed in and create a node\n * */\n static override importDOM(): DOMConversionMap | null {\n return {\n p: () => ({\n conversion: convertParagraphElement,\n priority: 0\n })\n };\n }\n\n /*\n * Serialize the JSON data back into a node\n */\n static override importJSON(serializedNode: SerializeParagraphNode): BaseParagraphNode {\n const node = $createParagraphNode();\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n node.setThemeStyles(serializedNode.styles);\n return node;\n }\n\n /*\n * Serialize the node to JSON data representation.\n * */\n override exportJSON(): SerializeParagraphNode {\n return {\n ...super.exportJSON(),\n styles: this.__styles,\n type: \"paragraph-element\",\n version: 1\n };\n }\n}\n\nfunction convertParagraphElement(element: HTMLElement): DOMConversionOutput {\n const node = $createParagraphNode();\n if (element.style) {\n node.setFormat(element.style.textAlign as ElementFormatType);\n }\n\n return { node };\n}\n\nexport function $createParagraphNode(typographyStyleId?: string): ParagraphNode {\n return $applyNodeReplacement(new ParagraphNode(typographyStyleId));\n}\n\nexport function $isParagraphNode(node: LexicalNode | null | undefined): node is ParagraphNode {\n return node instanceof ParagraphNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAYA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAAwD,IAW3CG,aAAa,GAAAC,OAAA,CAAAD,aAAA,0BAAAE,kBAAA;EAMtB,SAAAF,cAAYG,iBAA0B,EAAEC,GAAa,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAP,aAAA;IACnDK,KAAA,OAAAG,WAAA,CAAAD,OAAA,QAAAP,aAAA,GAAMI,GAAG;IAAE,IAAAK,gBAAA,CAAAF,OAAA,EAAAF,KAAA,cAHe,EAAE;IAK5B,IAAIF,iBAAiB,EAAE;MACnBE,KAAA,CAAKK,QAAQ,CAACC,IAAI,CAAC;QAAEC,OAAO,EAAET,iBAAiB;QAAEU,IAAI,EAAE;MAAa,CAAC,CAAC;IAC1E;IAAC,OAAAR,KAAA;EACL;EAAC,IAAAS,UAAA,CAAAP,OAAA,EAAAP,aAAA,EAAAE,kBAAA;EAAA,WAAAa,aAAA,CAAAR,OAAA,EAAAP,aAAA;IAAAI,GAAA;IAAAY,KAAA,EAED,SAAAC,qBAA+BC,eAAgC,EAAE;M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aAAa,CAACG,iBAAiB,CAAC,CAAC;AACtE;AAEO,SAAS8E,gBAAgBA,CAACnB,IAAoC,EAAyB;EAC1F,OAAOA,IAAI,YAAY9D,aAAa;AACxC","ignoreList":[]}
1
+ {"version":3,"names":["ParagraphNode","BaseParagraphNode","addClassNamesToElement","Theme","getStyleId","convertParagraphElement","element","node","$createParagraphNode","style","setFormat","textAlign","constructor","options","styleId","key","className","__styleId","__className","setStyleId","setClassName","getClassName","getType","clone","__key","insertNewAfter","rangeSelection","restoreSelection","newElement","setTextFormat","format","setTextStyle","direction","getDirection","setDirection","getFormatType","setStyle","getStyle","insertAfter","createDOM","config","updateElementWithThemeClasses","from","theme","exportDOM","editor","base","classList","add","updateDOM","prevNode","dom","prevTypoStyleId","nextTypoStyleId","importDOM","p","conversion","priority","importJSON","serializedNode","setIndent","indent","styles","exportJSON","type","setDefaultTypography","typographyStyle","getTypographyByTag","byStyleId","getTypographyById","id","$isParagraphNode"],"sources":["ParagraphNode.ts"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMConversionOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n SerializedParagraphNode as SerializedBaseParagraphNode,\n Spread,\n LexicalEditor,\n DOMExportOutput,\n RangeSelection\n} from \"lexical\";\nimport { ParagraphNode as BaseParagraphNode, addClassNamesToElement } from \"lexical\";\nimport type { EditorConfig } from \"lexical\";\nimport { Theme } from \"@webiny/lexical-theme\";\nimport type { TypographyStylesNode, ThemeStyleValue } from \"~/types.js\";\nimport { getStyleId } from \"./utils/getStyleId.js\";\n\nfunction convertParagraphElement(element: HTMLElement): DOMConversionOutput {\n const node = $createParagraphNode();\n if (element.style) {\n node.setFormat(element.style.textAlign as ElementFormatType);\n }\n\n return { node };\n}\n\nexport type SerializeParagraphNode = Spread<\n {\n styles?: ThemeStyleValue[];\n styleId?: string;\n className?: string;\n type: \"wby-paragraph\";\n },\n SerializedBaseParagraphNode\n>;\n\ninterface ParagraphNodeOptions {\n className?: string;\n styleId?: string;\n key?: NodeKey;\n}\n\nexport class ParagraphNode extends BaseParagraphNode implements TypographyStylesNode {\n private __styleId: string | undefined;\n private __className: string | undefined;\n\n constructor(options: ParagraphNodeOptions = {}) {\n const { styleId, key, className } = options;\n super(key);\n\n this.__styleId = styleId;\n this.__className = className;\n }\n\n getStyleId(): string | undefined {\n return this.__styleId;\n }\n\n setStyleId(styleId: string | undefined) {\n this.__styleId = styleId;\n }\n\n setClassName(className: string | undefined) {\n this.__className = className;\n }\n\n getClassName(): string | undefined {\n return this.__className;\n }\n\n static override getType(): string {\n return \"wby-paragraph\";\n }\n\n static override clone(node: ParagraphNode): ParagraphNode {\n return new ParagraphNode({\n styleId: node.getStyleId(),\n className: node.getClassName(),\n key: node.__key\n });\n }\n\n override insertNewAfter(\n rangeSelection: RangeSelection,\n restoreSelection: boolean\n ): ParagraphNode {\n const newElement = $createParagraphNode();\n newElement.setTextFormat(rangeSelection.format);\n newElement.setTextStyle(rangeSelection.style);\n const direction = this.getDirection();\n newElement.setDirection(direction);\n newElement.setFormat(this.getFormatType());\n newElement.setStyle(this.getStyle());\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.updateElementWithThemeClasses(element, Theme.from(config.theme));\n }\n\n override exportDOM(editor: LexicalEditor): DOMExportOutput {\n const base = super.exportDOM(editor);\n\n const element = base.element as HTMLElement;\n if (element && this.__className) {\n element.classList.add(this.__className);\n }\n\n return { ...base, element };\n }\n\n override updateDOM(prevNode: ParagraphNode, dom: HTMLElement, config: EditorConfig): boolean {\n const prevTypoStyleId = prevNode.getStyleId();\n const nextTypoStyleId = this.getStyleId();\n\n if (!nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, Theme.from(config.theme));\n return false;\n }\n\n if (prevTypoStyleId !== nextTypoStyleId && nextTypoStyleId) {\n this.updateElementWithThemeClasses(dom, Theme.from(config.theme));\n }\n // Returning false tells Lexical that this node does not need its\n // DOM element replacing with a new copy from createDOM.\n return false;\n }\n\n /*\n * On copy/paste event this method will be executed in and create a node\n * */\n static override importDOM(): DOMConversionMap | null {\n return {\n p: () => ({\n conversion: convertParagraphElement,\n priority: 0\n })\n };\n }\n\n /*\n * Serialize the JSON data back into a node\n */\n static override importJSON(serializedNode: SerializeParagraphNode): BaseParagraphNode {\n const node = $createParagraphNode();\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n\n const styleId = getStyleId({\n styleId: serializedNode.styleId,\n styles: serializedNode.styles\n });\n\n node.setStyleId(styleId);\n node.setClassName(serializedNode.className);\n return node;\n }\n\n /*\n * Serialize the node to JSON data representation.\n * */\n override exportJSON(): SerializeParagraphNode {\n return {\n ...super.exportJSON(),\n styleId: this.__styleId,\n className: this.__className,\n type: \"wby-paragraph\"\n };\n }\n\n protected updateElementWithThemeClasses(element: HTMLElement, theme: Theme): HTMLElement {\n if (!this.__styleId || !this.__className) {\n this.setDefaultTypography(theme, this.__styleId);\n }\n\n if (this.__className) {\n addClassNamesToElement(element, this.__className);\n }\n\n return element;\n }\n\n private setDefaultTypography(theme: Theme, styleId?: string) {\n let typographyStyle = theme.getTypographyByTag(\"p\");\n if (styleId) {\n const byStyleId = theme.getTypographyById(styleId);\n if (byStyleId) {\n typographyStyle = byStyleId;\n }\n }\n\n if (typographyStyle) {\n this.__styleId = typographyStyle.id;\n this.__className = typographyStyle.className;\n }\n }\n}\n\nexport function $createParagraphNode(styleId?: string): ParagraphNode {\n return new ParagraphNode({ styleId });\n}\n\nexport function $isParagraphNode(node: LexicalNode | null | undefined): node is ParagraphNode {\n return node instanceof ParagraphNode;\n}\n"],"mappings":"AAYA,SAASA,aAAa,IAAIC,iBAAiB,EAAEC,sBAAsB,QAAQ,SAAS;AAEpF,SAASC,KAAK,QAAQ,uBAAuB;AAE7C,SAASC,UAAU;AAEnB,SAASC,uBAAuBA,CAACC,OAAoB,EAAuB;EACxE,MAAMC,IAAI,GAAGC,o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,CAACC,WAAW,EAAE;MACtC,IAAI,CAAC+C,oBAAoB,CAACtB,KAAK,EAAE,IAAI,CAAC1B,SAAS,CAAC;IACpD;IAEA,IAAI,IAAI,CAACC,WAAW,EAAE;MAClBhB,sBAAsB,CAACI,OAAO,EAAE,IAAI,CAACY,WAAW,CAAC;IACrD;IAEA,OAAOZ,OAAO;EAClB;EAEQ2D,oBAAoBA,CAACtB,KAAY,EAAE7B,OAAgB,EAAE;IACzD,IAAIoD,eAAe,GAAGvB,KAAK,CAACwB,kBAAkB,CAAC,GAAG,CAAC;IACnD,IAAIrD,OAAO,EAAE;MACT,MAAMsD,SAAS,GAAGzB,KAAK,CAAC0B,iBAAiB,CAACvD,OAAO,CAAC;MAClD,IAAIsD,SAAS,EAAE;QACXF,eAAe,GAAGE,SAAS;MAC/B;IACJ;IAEA,IAAIF,eAAe,EAAE;MACjB,IAAI,CAACjD,SAAS,GAAGiD,eAAe,CAACI,EAAE;MACnC,IAAI,CAACpD,WAAW,GAAGgD,eAAe,CAAClD,SAAS;IAChD;EACJ;AACJ;AAEA,OAAO,SAASR,oBAAoBA,CAACM,OAAgB,EAAiB;EAClE,OAAO,IAAId,aAAa,CAAC;IAAEc;EAAQ,CAAC,CAAC;AACzC;AAEA,OAAO,SAASyD,gBAAgBA,CAAChE,IAAoC,EAAyB;EAC1F,OAAOA,IAAI,YAAYP,aAAa;AACxC","ignoreList":[]}
package/QuoteNode.d.ts CHANGED
@@ -1,31 +1,38 @@
1
- import { DOMConversion, DOMConversionMap, EditorConfig, LexicalNode, NodeKey, Spread } from "lexical";
2
- import { EditorTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
3
- import { QuoteNode as BaseQuoteNode, SerializedQuoteNode as BaseSerializedQuoteNode } from "@lexical/rich-text";
4
- import { TextNodeThemeStyles, ThemeStyleValue, TypographyStylesNode } from "./types";
5
- export declare type SerializedQuoteNode = Spread<{
1
+ import type { DOMConversion, DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, Spread } from "lexical";
2
+ import { Theme } from "@webiny/lexical-theme";
3
+ import type { SerializedQuoteNode as BaseSerializedQuoteNode } from "@lexical/rich-text";
4
+ import { QuoteNode as BaseQuoteNode } from "@lexical/rich-text";
5
+ import type { ThemeStyleValue, TypographyStylesNode } from "./types.js";
6
+ export type SerializedQuoteNode = Spread<{
6
7
  styleId?: string;
7
- styles: ThemeStyleValue[];
8
- type: "webiny-quote";
8
+ styles?: ThemeStyleValue[];
9
+ className?: string;
10
+ type: "wby-quote";
9
11
  }, BaseSerializedQuoteNode>;
10
- export declare class QuoteNode extends BaseQuoteNode implements TextNodeThemeStyles, TypographyStylesNode {
11
- __styles: ThemeStyleValue[];
12
- constructor(themeStyleId?: string, key?: NodeKey);
13
- protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap): void;
14
- protected typographyStyleExist(themeEmotionMap: ThemeEmotionMap): boolean;
15
- setTypography(typographyStyleId: string): this;
16
- getTypographyStyleId(): string | undefined;
17
- clearTypographyStyle(): this;
18
- hasTypographyStyle(): boolean;
19
- getThemeStyles(): ThemeStyleValue[];
20
- setThemeStyles(styles: ThemeStyleValue[]): this;
12
+ interface QuoteNodeOptions {
13
+ className?: string;
14
+ styleId?: string;
15
+ key?: NodeKey;
16
+ }
17
+ export declare class QuoteNode extends BaseQuoteNode implements TypographyStylesNode {
18
+ private __styleId;
19
+ private __className;
20
+ constructor(options?: QuoteNodeOptions);
21
+ getStyleId(): string | undefined;
22
+ setStyleId(styleId: string | undefined): void;
23
+ setClassName(className: string | undefined): void;
24
+ getClassName(): string | undefined;
25
+ private setDefaultTypography;
21
26
  static getType(): string;
22
27
  static clone(node: QuoteNode): QuoteNode;
23
- addThemeStylesToHTMLElement(element: HTMLElement, theme: EditorTheme): HTMLElement;
24
28
  createDOM(config: EditorConfig): HTMLElement;
29
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
25
30
  static importDomConversionMap(): DOMConversion<HTMLElement> | null;
26
31
  static importDOM(): DOMConversionMap | null;
27
32
  static importJSON(serializedNode: SerializedQuoteNode): QuoteNode;
28
33
  exportJSON(): SerializedQuoteNode;
34
+ protected updateElementWithThemeClasses(element: HTMLElement, theme: Theme): HTMLElement;
29
35
  }
30
- export declare function $createQuoteNode(themeStyleId?: string, key?: NodeKey): QuoteNode;
36
+ export declare function $createQuoteNode(styleId?: string, key?: NodeKey): QuoteNode;
31
37
  export declare function $isQuoteNode(node: LexicalNode | null | undefined): node is QuoteNode;
38
+ export {};