@webiny/lexical-nodes 5.40.0 → 5.40.1-beta.1

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.
@@ -1,16 +1,19 @@
1
- import { EditorConfig, LexicalCommand, LexicalEditor, LexicalNode, NodeKey, RangeSelection, SerializedTextNode, Spread, TextNode } from "lexical";
1
+ import { EditorConfig, LexicalNode, SerializedTextNode, Spread, TextNode } from "lexical";
2
2
  import { EditorTheme } from "@webiny/lexical-theme";
3
- export declare const ADD_FONT_COLOR_COMMAND: LexicalCommand<FontColorPayload>;
3
+ export declare class ThemeColorValue {
4
+ private readonly name;
5
+ private value;
6
+ constructor(value: string, name?: string);
7
+ getValue(): string;
8
+ getName(): string;
9
+ updateFromTheme(theme: EditorTheme): void;
10
+ }
11
+ export declare const ADD_FONT_COLOR_COMMAND: import("lexical").LexicalCommand<FontColorPayload>;
4
12
  export interface FontColorPayload {
5
- color: string;
6
- themeColorName: string | undefined;
7
- caption?: LexicalEditor;
8
- key?: NodeKey;
13
+ color: ThemeColorValue;
9
14
  }
10
- declare type ThemeStyleColorName = string;
11
- declare type ThemeColor = "custom" | ThemeStyleColorName;
12
15
  export declare type SerializedFontColorNode = Spread<{
13
- themeColor: ThemeColor;
16
+ themeColor: string;
14
17
  color: string;
15
18
  type: "font-color-node";
16
19
  version: 1;
@@ -20,22 +23,21 @@ export declare type SerializedFontColorNode = Spread<{
20
23
  * Extends the original TextNode node to add additional transformation and support for webiny theme font color.
21
24
  */
22
25
  export declare class FontColorNode extends TextNode {
23
- __themeColor: ThemeColor;
24
- __color: string;
25
- constructor(text: string, color: string, themeColor?: ThemeColor, key?: NodeKey);
26
+ private readonly __color;
27
+ constructor(text: string, color: ThemeColorValue, key?: string);
26
28
  static getType(): string;
27
29
  static clone(node: FontColorNode): FontColorNode;
28
30
  static importJSON(serializedNode: SerializedFontColorNode): TextNode;
31
+ splitText(...splitOffsets: Array<number>): Array<FontColorNode>;
29
32
  exportJSON(): SerializedFontColorNode;
30
- addColorValueToHTMLElement(element: HTMLElement, theme: EditorTheme): HTMLElement;
33
+ private addColorValueToHTMLElement;
31
34
  updateDOM(prevNode: FontColorNode, dom: HTMLElement, config: EditorConfig): boolean;
32
35
  getColorStyle(): {
33
36
  color: string;
34
- themeColor: ThemeColor;
37
+ themeColor: string;
35
38
  };
36
39
  createDOM(config: EditorConfig): HTMLElement;
37
40
  }
38
- export declare const $createFontColorNode: (text: string, color: string, themeColor?: ThemeColor, key?: NodeKey) => FontColorNode;
41
+ export declare const $createFontColorNode: (text: string, color: ThemeColorValue) => FontColorNode;
39
42
  export declare const $isFontColorNode: (node: LexicalNode) => node is FontColorNode;
40
- export declare function $applyStylesToNode(node: FontColorNode, nodeStyleProvider: RangeSelection): void;
41
- export {};
43
+ export declare function $applyStylesToNode(node: TextNode, source: TextNode): void;
package/FontColorNode.js CHANGED
@@ -5,15 +5,44 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.$applyStylesToNode = $applyStylesToNode;
8
- exports.FontColorNode = exports.ADD_FONT_COLOR_COMMAND = exports.$isFontColorNode = exports.$createFontColorNode = void 0;
8
+ exports.ThemeColorValue = exports.FontColorNode = exports.ADD_FONT_COLOR_COMMAND = exports.$isFontColorNode = exports.$createFontColorNode = void 0;
9
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
10
  var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
13
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
+ var _get3 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
14
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
16
16
  var _lexical = require("lexical");
17
+ var ThemeColorValue = exports.ThemeColorValue = /*#__PURE__*/function () {
18
+ // Webiny theme color variable, like color1, color2, etc.
19
+
20
+ // This can be a HEX value or a CSS variable.
21
+
22
+ function ThemeColorValue(value, name) {
23
+ (0, _classCallCheck2.default)(this, ThemeColorValue);
24
+ this.value = value;
25
+ this.name = name ?? "custom";
26
+ }
27
+ return (0, _createClass2.default)(ThemeColorValue, [{
28
+ key: "getValue",
29
+ value: function getValue() {
30
+ return this.value;
31
+ }
32
+ }, {
33
+ key: "getName",
34
+ value: function getName() {
35
+ return this.name;
36
+ }
37
+ }, {
38
+ key: "updateFromTheme",
39
+ value: function updateFromTheme(theme) {
40
+ if (theme?.styles?.colors && this.name !== "custom") {
41
+ this.value = theme.styles?.colors[this.name];
42
+ }
43
+ }
44
+ }]);
45
+ }();
17
46
  var ADD_FONT_COLOR_COMMAND = exports.ADD_FONT_COLOR_COMMAND = (0, _lexical.createCommand)("ADD_FONT_COLOR_COMMAND");
18
47
  var FontColorNodeAttrName = "data-theme-font-color-name";
19
48
  /**
@@ -21,21 +50,56 @@ var FontColorNodeAttrName = "data-theme-font-color-name";
21
50
  * Extends the original TextNode node to add additional transformation and support for webiny theme font color.
22
51
  */
23
52
  var FontColorNode = exports.FontColorNode = /*#__PURE__*/function (_TextNode) {
24
- function FontColorNode(text, color, themeColor, key) {
53
+ function FontColorNode(text, color, key) {
25
54
  var _this;
26
55
  (0, _classCallCheck2.default)(this, FontColorNode);
27
56
  _this = (0, _callSuper2.default)(this, FontColorNode, [text, key]);
28
- _this.__themeColor = themeColor || "custom";
29
57
  _this.__color = color;
30
58
  return _this;
31
59
  }
32
60
  (0, _inherits2.default)(FontColorNode, _TextNode);
33
61
  return (0, _createClass2.default)(FontColorNode, [{
62
+ key: "splitText",
63
+ value: function splitText() {
64
+ var _get2,
65
+ _this2 = this;
66
+ for (var _len = arguments.length, splitOffsets = new Array(_len), _key = 0; _key < _len; _key++) {
67
+ splitOffsets[_key] = arguments[_key];
68
+ }
69
+ var newNodes = (_get2 = (0, _get3.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "splitText", this)).call.apply(_get2, [this].concat(splitOffsets));
70
+ var selection = (0, _lexical.$getSelection)();
71
+
72
+ // After splitting, we need to re-apply styling to the new TextNodes.
73
+ var fontColorNodes = newNodes.map(function (node) {
74
+ if (node instanceof FontColorNode) {
75
+ return node;
76
+ }
77
+ var fontColorNode = $createFontColorNode(node.getTextContent(), _this2.__color);
78
+ $applyStylesToNode(fontColorNode, _this2);
79
+ var newNode = node.replace(fontColorNode);
80
+
81
+ // Since we're replacing the existing node, we need to update the selection keys.
82
+ // This is very important to not break the editor functionality!
83
+ if ((0, _lexical.$isRangeSelection)(selection)) {
84
+ var anchor = selection.anchor;
85
+ var focus = selection.focus;
86
+ if (anchor.key === node.getKey()) {
87
+ anchor.key = newNode.getKey();
88
+ }
89
+ if (focus.key === node.getKey()) {
90
+ focus.key = newNode.getKey();
91
+ }
92
+ }
93
+ return newNode;
94
+ });
95
+ return fontColorNodes;
96
+ }
97
+ }, {
34
98
  key: "exportJSON",
35
99
  value: function exportJSON() {
36
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "exportJSON", this).call(this)), {}, {
37
- themeColor: this.__themeColor,
38
- color: this.__color,
100
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get3.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "exportJSON", this).call(this)), {}, {
101
+ themeColor: this.__color.getName(),
102
+ color: this.__color.getValue(),
39
103
  type: "font-color-node",
40
104
  version: 1
41
105
  });
@@ -43,41 +107,33 @@ var FontColorNode = exports.FontColorNode = /*#__PURE__*/function (_TextNode) {
43
107
  }, {
44
108
  key: "addColorValueToHTMLElement",
45
109
  value: function addColorValueToHTMLElement(element, theme) {
46
- var hasThemeColor = this.__themeColor !== "custom";
47
- // get the updated color from webiny theme
48
- if (hasThemeColor && theme?.styles?.colors) {
49
- this.__color = theme.styles.colors[this.__themeColor];
50
- }
51
- element.setAttribute(FontColorNodeAttrName, this.__themeColor);
52
- element.style.color = this.__color;
110
+ // Update color from webiny theme
111
+ this.__color.updateFromTheme(theme);
112
+ element.setAttribute(FontColorNodeAttrName, this.__color.getName());
113
+ element.style.color = this.__color.getValue();
53
114
  return element;
54
115
  }
55
116
  }, {
56
117
  key: "updateDOM",
57
118
  value: function updateDOM(prevNode, dom, config) {
58
- var theme = config.theme;
59
- var isUpdated = (0, _get2.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "updateDOM", this).call(this, prevNode, dom, config);
60
- var hasThemeColor = this.__themeColor !== "custom";
61
- // get the updated color from webiny theme
62
- if (hasThemeColor && theme?.styles?.colors) {
63
- this.__color = theme.styles.colors[this.__themeColor];
64
- }
65
- dom.setAttribute(FontColorNodeAttrName, this.__themeColor);
66
- dom.style.color = this.__color;
119
+ var isUpdated = (0, _get3.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "updateDOM", this).call(this, prevNode, dom, config);
120
+ this.__color.updateFromTheme(config.theme);
121
+ dom.setAttribute(FontColorNodeAttrName, this.__color.getName());
122
+ dom.style.color = this.__color.getValue();
67
123
  return isUpdated;
68
124
  }
69
125
  }, {
70
126
  key: "getColorStyle",
71
127
  value: function getColorStyle() {
72
128
  return {
73
- color: this.__color,
74
- themeColor: this.__themeColor
129
+ color: this.__color.getValue(),
130
+ themeColor: this.__color.getName()
75
131
  };
76
132
  }
77
133
  }, {
78
134
  key: "createDOM",
79
135
  value: function createDOM(config) {
80
- var element = (0, _get2.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "createDOM", this).call(this, config);
136
+ var element = (0, _get3.default)((0, _getPrototypeOf2.default)(FontColorNode.prototype), "createDOM", this).call(this, config);
81
137
  return this.addColorValueToHTMLElement(element, config.theme);
82
138
  }
83
139
  }], [{
@@ -88,12 +144,12 @@ var FontColorNode = exports.FontColorNode = /*#__PURE__*/function (_TextNode) {
88
144
  }, {
89
145
  key: "clone",
90
146
  value: function clone(node) {
91
- return new FontColorNode(node.__text, node.__color, node.__themeColor, node.__key);
147
+ return new FontColorNode(node.__text, node.__color, node.__key);
92
148
  }
93
149
  }, {
94
150
  key: "importJSON",
95
151
  value: function importJSON(serializedNode) {
96
- var node = new FontColorNode(serializedNode.text, serializedNode.color, serializedNode.themeColor);
152
+ var node = new FontColorNode(serializedNode.text, new ThemeColorValue(serializedNode.color, serializedNode.themeColor));
97
153
  node.setTextContent(serializedNode.text);
98
154
  node.setFormat(serializedNode.format);
99
155
  node.setDetail(serializedNode.detail);
@@ -103,15 +159,15 @@ var FontColorNode = exports.FontColorNode = /*#__PURE__*/function (_TextNode) {
103
159
  }
104
160
  }]);
105
161
  }(_lexical.TextNode);
106
- var $createFontColorNode = exports.$createFontColorNode = function $createFontColorNode(text, color, themeColor, key) {
107
- return new FontColorNode(text, color, themeColor, key);
162
+ var $createFontColorNode = exports.$createFontColorNode = function $createFontColorNode(text, color) {
163
+ return new FontColorNode(text, color);
108
164
  };
109
165
  var $isFontColorNode = exports.$isFontColorNode = function $isFontColorNode(node) {
110
166
  return node instanceof FontColorNode;
111
167
  };
112
- function $applyStylesToNode(node, nodeStyleProvider) {
113
- node.setFormat(nodeStyleProvider.format);
114
- node.setStyle(nodeStyleProvider.style);
168
+ function $applyStylesToNode(node, source) {
169
+ node.setFormat(source.getFormat());
170
+ node.setStyle(source.getStyle());
115
171
  }
116
172
 
117
173
  //# sourceMappingURL=FontColorNode.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","ADD_FONT_COLOR_COMMAND","exports","createCommand","FontColorNodeAttrName","FontColorNode","_TextNode","text","color","themeColor","key","_this","_classCallCheck2","default","_callSuper2","__themeColor","__color","_inherits2","_createClass2","value","exportJSON","_objectSpread2","_get2","_getPrototypeOf2","prototype","call","type","version","addColorValueToHTMLElement","element","theme","hasThemeColor","styles","colors","setAttribute","style","updateDOM","prevNode","dom","config","isUpdated","getColorStyle","createDOM","getType","clone","node","__text","__key","importJSON","serializedNode","setTextContent","setFormat","format","setDetail","detail","setMode","mode","setStyle","TextNode","$createFontColorNode","$isFontColorNode","$applyStylesToNode","nodeStyleProvider"],"sources":["FontColorNode.ts"],"sourcesContent":["import {\n createCommand,\n EditorConfig,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n RangeSelection,\n SerializedTextNode,\n Spread,\n TextNode\n} from \"lexical\";\nimport { EditorTheme } from \"@webiny/lexical-theme\";\n\nexport const ADD_FONT_COLOR_COMMAND: LexicalCommand<FontColorPayload> =\n createCommand(\"ADD_FONT_COLOR_COMMAND\");\nconst FontColorNodeAttrName = \"data-theme-font-color-name\";\n\nexport interface FontColorPayload {\n // This color can be hex string\n color: string;\n // webiny theme color variable like color1, color2...\n themeColorName: string | undefined;\n caption?: LexicalEditor;\n key?: NodeKey;\n}\n\ntype ThemeStyleColorName = string;\ntype ThemeColor = \"custom\" | ThemeStyleColorName;\n\nexport type SerializedFontColorNode = Spread<\n {\n themeColor: ThemeColor;\n color: string;\n type: \"font-color-node\";\n version: 1;\n },\n SerializedTextNode\n>;\n\n/**\n * Main responsibility of this node is to apply custom or Webiny theme color to selected text.\n * Extends the original TextNode node to add additional transformation and support for webiny theme font color.\n */\nexport class FontColorNode extends TextNode {\n __themeColor: ThemeColor;\n __color: string;\n\n constructor(text: string, color: string, themeColor?: ThemeColor, key?: NodeKey) {\n super(text, key);\n this.__themeColor = themeColor || \"custom\";\n this.__color = color;\n }\n\n static override getType(): string {\n return \"font-color-node\";\n }\n\n static override clone(node: FontColorNode): FontColorNode {\n return new FontColorNode(node.__text, node.__color, node.__themeColor, node.__key);\n }\n\n static override importJSON(serializedNode: SerializedFontColorNode): TextNode {\n const node = new FontColorNode(\n serializedNode.text,\n serializedNode.color,\n serializedNode.themeColor\n );\n node.setTextContent(serializedNode.text);\n node.setFormat(serializedNode.format);\n node.setDetail(serializedNode.detail);\n node.setMode(serializedNode.mode);\n node.setStyle(serializedNode.style);\n return node;\n }\n\n override exportJSON(): SerializedFontColorNode {\n return {\n ...super.exportJSON(),\n themeColor: this.__themeColor,\n color: this.__color,\n type: \"font-color-node\",\n version: 1\n };\n }\n\n addColorValueToHTMLElement(element: HTMLElement, theme: EditorTheme): HTMLElement {\n const hasThemeColor = this.__themeColor !== \"custom\";\n // get the updated color from webiny theme\n if (hasThemeColor && theme?.styles?.colors) {\n this.__color = theme.styles.colors[this.__themeColor];\n }\n\n element.setAttribute(FontColorNodeAttrName, this.__themeColor);\n element.style.color = this.__color;\n return element;\n }\n\n override updateDOM(prevNode: FontColorNode, dom: HTMLElement, config: EditorConfig): boolean {\n const theme = config.theme;\n const isUpdated = super.updateDOM(prevNode, dom, config);\n const hasThemeColor = this.__themeColor !== \"custom\";\n // get the updated color from webiny theme\n if (hasThemeColor && theme?.styles?.colors) {\n this.__color = theme.styles.colors[this.__themeColor];\n }\n\n dom.setAttribute(FontColorNodeAttrName, this.__themeColor);\n dom.style.color = this.__color;\n return isUpdated;\n }\n\n getColorStyle(): { color: string; themeColor: ThemeColor } {\n return {\n color: this.__color,\n themeColor: this.__themeColor\n };\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.addColorValueToHTMLElement(element, config.theme);\n }\n}\n\nexport const $createFontColorNode = (\n text: string,\n color: string,\n themeColor?: ThemeColor,\n key?: NodeKey\n): FontColorNode => {\n return new FontColorNode(text, color, themeColor, key);\n};\n\nexport const $isFontColorNode = (node: LexicalNode): node is FontColorNode => {\n return node instanceof FontColorNode;\n};\n\nexport function $applyStylesToNode(node: FontColorNode, nodeStyleProvider: RangeSelection) {\n node.setFormat(nodeStyleProvider.format);\n node.setStyle(nodeStyleProvider.style);\n}\n"],"mappings":";;;;;;;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AK,EAAEC,UAAU,EAAEC,GAAG,CAAC;AAC1D,CAAC;AAEM,IAAMkD,gBAAgB,GAAA1D,OAAA,CAAA0D,gBAAA,GAAG,SAAnBA,gBAAgBA,CAAIf,IAAiB,EAA4B;EAC1E,OAAOA,IAAI,YAAYxC,aAAa;AACxC,CAAC;AAEM,SAASwD,kBAAkBA,CAAChB,IAAmB,EAAEiB,iBAAiC,EAAE;EACvFjB,IAAI,CAACM,SAAS,CAACW,iBAAiB,CAACV,MAAM,CAAC;EACxCP,IAAI,CAACY,QAAQ,CAACK,iBAAiB,CAAC3B,KAAK,CAAC;AAC1C","ignoreList":[]}
1
+ {"version":3,"names":["_lexical","require","ThemeColorValue","exports","value","name","_classCallCheck2","default","_createClass2","key","getValue","getName","updateFromTheme","theme","styles","colors","ADD_FONT_COLOR_COMMAND","createCommand","FontColorNodeAttrName","FontColorNode","_TextNode","text","color","_this","_callSuper2","__color","_inherits2","splitText","_get2","_this2","_len","arguments","length","splitOffsets","Array","_key","newNodes","_get3","_getPrototypeOf2","prototype","call","apply","concat","selection","$getSelection","fontColorNodes","map","node","fontColorNode","$createFontColorNode","getTextContent","$applyStylesToNode","newNode","replace","$isRangeSelection","anchor","focus","getKey","exportJSON","_objectSpread2","themeColor","type","version","addColorValueToHTMLElement","element","setAttribute","style","updateDOM","prevNode","dom","config","isUpdated","getColorStyle","createDOM","getType","clone","__text","__key","importJSON","serializedNode","setTextContent","setFormat","format","setDetail","detail","setMode","mode","setStyle","TextNode","$isFontColorNode","source","getFormat","getStyle"],"sources":["FontColorNode.ts"],"sourcesContent":["import {\n $getSelection,\n $isRangeSelection,\n createCommand,\n EditorConfig,\n LexicalNode,\n SerializedTextNode,\n Spread,\n TextNode\n} from \"lexical\";\nimport { EditorTheme } from \"@webiny/lexical-theme\";\n\nexport class ThemeColorValue {\n // Webiny theme color variable, like color1, color2, etc.\n private readonly name: string;\n // This can be a HEX value or a CSS variable.\n private value: string;\n\n constructor(value: string, name?: string) {\n this.value = value;\n this.name = name ?? \"custom\";\n }\n\n getValue() {\n return this.value;\n }\n\n getName() {\n return this.name;\n }\n\n updateFromTheme(theme: EditorTheme) {\n if (theme?.styles?.colors && this.name !== \"custom\") {\n this.value = theme.styles?.colors[this.name];\n }\n }\n}\n\nexport const ADD_FONT_COLOR_COMMAND = createCommand<FontColorPayload>(\"ADD_FONT_COLOR_COMMAND\");\n\nconst FontColorNodeAttrName = \"data-theme-font-color-name\";\n\nexport interface FontColorPayload {\n color: ThemeColorValue;\n}\n\nexport type SerializedFontColorNode = Spread<\n {\n themeColor: string;\n color: string;\n type: \"font-color-node\";\n version: 1;\n },\n SerializedTextNode\n>;\n\n/**\n * Main responsibility of this node is to apply custom or Webiny theme color to selected text.\n * Extends the original TextNode node to add additional transformation and support for webiny theme font color.\n */\nexport class FontColorNode extends TextNode {\n private readonly __color: ThemeColorValue;\n\n constructor(text: string, color: ThemeColorValue, key?: string) {\n super(text, key);\n this.__color = color;\n }\n\n static override getType(): string {\n return \"font-color-node\";\n }\n\n static override clone(node: FontColorNode): FontColorNode {\n return new FontColorNode(node.__text, node.__color, node.__key);\n }\n\n static override importJSON(serializedNode: SerializedFontColorNode): TextNode {\n const node = new FontColorNode(\n serializedNode.text,\n new ThemeColorValue(serializedNode.color, serializedNode.themeColor)\n );\n node.setTextContent(serializedNode.text);\n node.setFormat(serializedNode.format);\n node.setDetail(serializedNode.detail);\n node.setMode(serializedNode.mode);\n node.setStyle(serializedNode.style);\n return node;\n }\n\n override splitText(...splitOffsets: Array<number>): Array<FontColorNode> {\n const newNodes = super.splitText(...splitOffsets);\n\n const selection = $getSelection();\n\n // After splitting, we need to re-apply styling to the new TextNodes.\n const fontColorNodes = newNodes.map(node => {\n if (node instanceof FontColorNode) {\n return node;\n }\n\n const fontColorNode = $createFontColorNode(node.getTextContent(), this.__color);\n $applyStylesToNode(fontColorNode, this);\n\n const newNode = node.replace(fontColorNode);\n\n // Since we're replacing the existing node, we need to update the selection keys.\n // This is very important to not break the editor functionality!\n if ($isRangeSelection(selection)) {\n const anchor = selection.anchor;\n const focus = selection.focus;\n\n if (anchor.key === node.getKey()) {\n anchor.key = newNode.getKey();\n }\n\n if (focus.key === node.getKey()) {\n focus.key = newNode.getKey();\n }\n }\n\n return newNode;\n });\n\n return fontColorNodes as Array<FontColorNode>;\n }\n\n override exportJSON(): SerializedFontColorNode {\n return {\n ...super.exportJSON(),\n themeColor: this.__color.getName(),\n color: this.__color.getValue(),\n type: \"font-color-node\",\n version: 1\n };\n }\n\n private addColorValueToHTMLElement(element: HTMLElement, theme: EditorTheme): HTMLElement {\n // Update color from webiny theme\n this.__color.updateFromTheme(theme);\n element.setAttribute(FontColorNodeAttrName, this.__color.getName());\n element.style.color = this.__color.getValue();\n return element;\n }\n\n override updateDOM(prevNode: FontColorNode, dom: HTMLElement, config: EditorConfig): boolean {\n const isUpdated = super.updateDOM(prevNode, dom, config);\n this.__color.updateFromTheme(config.theme);\n\n dom.setAttribute(FontColorNodeAttrName, this.__color.getName());\n dom.style.color = this.__color.getValue();\n return isUpdated;\n }\n\n getColorStyle() {\n return {\n color: this.__color.getValue(),\n themeColor: this.__color.getName()\n };\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.addColorValueToHTMLElement(element, config.theme);\n }\n}\n\nexport const $createFontColorNode = (text: string, color: ThemeColorValue): FontColorNode => {\n return new FontColorNode(text, color);\n};\n\nexport const $isFontColorNode = (node: LexicalNode): node is FontColorNode => {\n return node instanceof FontColorNode;\n};\n\nexport function $applyStylesToNode(node: TextNode, source: TextNode) {\n node.setFormat(source.getFormat());\n node.setStyle(source.getStyle());\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASiB,IAGJC,eAAe,GAAAC,OAAA,CAAAD,eAAA;EACxB;;EAEA;;EAGA,SAAAA,gBAAYE,KAAa,EAAEC,IAAa,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAL,eAAA;IAC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ACnB,UAAU,CACvE,CAAC;MACDb,IAAI,CAACiC,cAAc,CAACD,cAAc,CAAC1D,IAAI,CAAC;MACxC0B,IAAI,CAACkC,SAAS,CAACF,cAAc,CAACG,MAAM,CAAC;MACrCnC,IAAI,CAACoC,SAAS,CAACJ,cAAc,CAACK,MAAM,CAAC;MACrCrC,IAAI,CAACsC,OAAO,CAACN,cAAc,CAACO,IAAI,CAAC;MACjCvC,IAAI,CAACwC,QAAQ,CAACR,cAAc,CAACb,KAAK,CAAC;MACnC,OAAOnB,IAAI;IACf;EAAC;AAAA,EA3B8ByC,iBAAQ;AA0GpC,IAAMvC,oBAAoB,GAAA9C,OAAA,CAAA8C,oBAAA,GAAG,SAAvBA,oBAAoBA,CAAI5B,IAAY,EAAEC,KAAsB,EAAoB;EACzF,OAAO,IAAIH,aAAa,CAACE,IAAI,EAAEC,KAAK,CAAC;AACzC,CAAC;AAEM,IAAMmE,gBAAgB,GAAAtF,OAAA,CAAAsF,gBAAA,GAAG,SAAnBA,gBAAgBA,CAAI1C,IAAiB,EAA4B;EAC1E,OAAOA,IAAI,YAAY5B,aAAa;AACxC,CAAC;AAEM,SAASgC,kBAAkBA,CAACJ,IAAc,EAAE2C,MAAgB,EAAE;EACjE3C,IAAI,CAACkC,SAAS,CAACS,MAAM,CAACC,SAAS,CAAC,CAAC,CAAC;EAClC5C,IAAI,CAACwC,QAAQ,CAACG,MAAM,CAACE,QAAQ,CAAC,CAAC,CAAC;AACpC","ignoreList":[]}
package/HeadingNode.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EditorConfig, LexicalNode, NodeKey, RangeSelection, Spread } from "lexical";
2
2
  import { HeadingNode as BaseHeadingNode, HeadingTagType, SerializedHeadingNode as BaseSerializedHeadingNode } from "@lexical/rich-text";
3
- import { WebinyTheme, ThemeEmotionMap } from "@webiny/lexical-theme";
3
+ import { WebinyTheme } from "@webiny/lexical-theme";
4
4
  import { ParagraphNode } from "./ParagraphNode";
5
5
  import { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from "./types";
6
6
  export declare type SerializeHeadingNode = Spread<{
@@ -10,11 +10,9 @@ export declare type SerializeHeadingNode = Spread<{
10
10
  export declare class HeadingNode extends BaseHeadingNode implements TextNodeThemeStyles, TypographyStylesNode {
11
11
  __styles: ThemeStyleValue[];
12
12
  constructor(tag: HeadingTagType, typographyStyleId?: string, key?: NodeKey);
13
- protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap): void;
14
- setTypography(typographyStyleId: string): this;
13
+ private setDefaultTypography;
15
14
  getTypographyStyleId(): string | undefined;
16
- clearTypographyStyle(): this;
17
- hasTypographyStyle(): boolean;
15
+ private hasTypographyStyle;
18
16
  getThemeStyles(): ThemeStyleValue[];
19
17
  setThemeStyles(styles: ThemeStyleValue[]): this;
20
18
  static getType(): string;
package/HeadingNode.js CHANGED
@@ -46,19 +46,6 @@ var HeadingNode = exports.HeadingNode = /*#__PURE__*/function (_BaseHeadingNode)
46
46
  });
47
47
  }
48
48
  }
49
- }, {
50
- key: "setTypography",
51
- value: function setTypography(typographyStyleId) {
52
- var self = (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "getWritable", this).call(this);
53
- if (!this.hasTypographyStyle()) {
54
- var themeStyle = {
55
- styleId: typographyStyleId,
56
- type: "typography"
57
- };
58
- self.__styles.push(themeStyle);
59
- }
60
- return self;
61
- }
62
49
  }, {
63
50
  key: "getTypographyStyleId",
64
51
  value: function getTypographyStyleId() {
@@ -67,15 +54,6 @@ var HeadingNode = exports.HeadingNode = /*#__PURE__*/function (_BaseHeadingNode)
67
54
  });
68
55
  return style?.styleId || undefined;
69
56
  }
70
- }, {
71
- key: "clearTypographyStyle",
72
- value: function clearTypographyStyle() {
73
- var self = (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "getWritable", this).call(this);
74
- self.__styles = self.__styles.filter(function (s) {
75
- return s.type !== "typography";
76
- });
77
- return self;
78
- }
79
57
  }, {
80
58
  key: "hasTypographyStyle",
81
59
  value: function hasTypographyStyle() {
@@ -1 +1 @@
1
- {"version":3,"names":["_lexical","require","_utils","_richText","_lexicalTheme","HeadingNode","exports","_BaseHeadingNode","tag","typographyStyleId","key","_this","_classCallCheck2","default","_callSuper2","_defineProperty2","__styles","push","styleId","type","_inherits2","_createClass2","value","setDefaultTypography","themeEmotionMap","typographyStyle","findTypographyStyleByHtmlTag","__tag","id","setTypography","self","_get2","_getPrototypeOf2","prototype","call","hasTypographyStyle","themeStyle","getTypographyStyleId","style","find","x","undefined","clearTypographyStyle","filter","s","getThemeStyles","setThemeStyles","styles","_toConsumableArray2","updateElementWithThemeClasses","element","theme","emotionMap","typoStyleId","themeClasses","className","addClassNamesToElement","createDOM","config","exportJSON","_objectSpread2","version","insertNewAfter","selection","restoreSelection","arguments","length","newElement","$createHeadingNode","getTag","direction","getDirection","setDirection","insertAfter","collapseAtStart","children","getChildren","forEach","child","append","replace","getType","clone","node","__key","importJSON","serializedNode","setFormat","format","setIndent","indent","BaseHeadingNode","$applyNodeReplacement","$isHeadingNode"],"sources":["HeadingNode.ts"],"sourcesContent":["import {\n EditorConfig,\n $applyNodeReplacement,\n LexicalNode,\n NodeKey,\n RangeSelection,\n Spread\n} from \"lexical\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport {\n HeadingNode as BaseHeadingNode,\n HeadingTagType,\n SerializedHeadingNode as BaseSerializedHeadingNode\n} from \"@lexical/rich-text\";\nimport { WebinyTheme, ThemeEmotionMap, findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { ParagraphNode } from \"~/ParagraphNode\";\nimport { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from \"~/types\";\n\nexport type SerializeHeadingNode = Spread<\n {\n styles: ThemeStyleValue[];\n type: \"heading-element\";\n },\n BaseSerializedHeadingNode\n>;\n\nexport class HeadingNode\n extends BaseHeadingNode\n implements TextNodeThemeStyles, TypographyStylesNode\n{\n __styles: ThemeStyleValue[] = [];\n\n constructor(tag: HeadingTagType, typographyStyleId?: string, key?: NodeKey) {\n super(tag, 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(this.__tag, 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 if (!this.hasTypographyStyle()) {\n const themeStyle = {\n styleId: typographyStyleId,\n type: \"typography\"\n } as ThemeStyleValue;\n self.__styles.push(themeStyle);\n }\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 const self = super.getLatest();\n return self.__styles;\n }\n\n setThemeStyles(styles: ThemeStyleValue[]) {\n const self = super.getWritable();\n self.__styles = [...styles];\n return self;\n }\n\n static override getType(): string {\n return \"heading-element\";\n }\n\n static override clone(node: HeadingNode): HeadingNode {\n return new HeadingNode(node.getTag(), 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 static override importJSON(serializedNode: SerializeHeadingNode): BaseHeadingNode {\n const node = $createHeadingNode(serializedNode.tag);\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 override exportJSON(): SerializeHeadingNode {\n return {\n ...super.exportJSON(),\n styles: this.__styles,\n type: \"heading-element\",\n version: 1\n };\n }\n\n // Mutation\n override insertNewAfter(\n selection?: RangeSelection,\n restoreSelection = true\n ): ParagraphNode | HeadingNode {\n // Next line for headings are always headings with the same tag\n const newElement = $createHeadingNode(this.getTag());\n const direction = this.getDirection();\n newElement.setDirection(direction);\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n\n override collapseAtStart(): true {\n const newElement = $createHeadingNode(this.getTag());\n const children = this.getChildren();\n children.forEach(child => newElement.append(child));\n this.replace(newElement);\n return true;\n }\n}\n\nexport function $createHeadingNode(tag: HeadingTagType, typographyStyleId?: string): HeadingNode {\n return $applyNodeReplacement(new HeadingNode(tag, typographyStyleId));\n}\n\nexport function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode {\n return node instanceof HeadingNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAH,OAAA;AAAmG,IAYtFI,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAAE,gBAAA;EAMpB,SAAAF,YAAYG,GAAmB,EAAEC,iBAA0B,EAAEC,GAAa,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAR,WAAA;IACxEM,KAAA,OAAAG,WAAA,CAAAD,OAAA,QAAAR,WAAA,GAAMG,GAAG,EAAEE,GAAG;IA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H,cAAc,CAACI,MAAM,CAAC;MACrCP,IAAI,CAACX,YAAY,CAACc,cAAc,CAAChB,SAAS,CAAC;MAC3Ca,IAAI,CAACrC,cAAc,CAACwC,cAAc,CAACvC,MAAM,CAAC;MAC1C,OAAOoC,IAAI;IACf;EAAC;AAAA,EA1GOQ,qBAAe;AA2IpB,SAASvB,kBAAkBA,CAAC5D,GAAmB,EAAEC,iBAA0B,EAAe;EAC7F,OAAO,IAAAmF,8BAAqB,EAAC,IAAIvF,WAAW,CAACG,GAAG,EAAEC,iBAAiB,CAAC,CAAC;AACzE;AAEO,SAASoF,cAAcA,CAACV,IAAoC,EAAuB;EACtF,OAAOA,IAAI,YAAY9E,WAAW;AACtC","ignoreList":[]}
1
+ {"version":3,"names":["_lexical","require","_utils","_richText","_lexicalTheme","HeadingNode","exports","_BaseHeadingNode","tag","typographyStyleId","key","_this","_classCallCheck2","default","_callSuper2","_defineProperty2","__styles","push","styleId","type","_inherits2","_createClass2","value","setDefaultTypography","themeEmotionMap","typographyStyle","findTypographyStyleByHtmlTag","__tag","id","getTypographyStyleId","style","find","x","undefined","hasTypographyStyle","getThemeStyles","self","_get2","_getPrototypeOf2","prototype","call","setThemeStyles","styles","_toConsumableArray2","updateElementWithThemeClasses","element","theme","emotionMap","typoStyleId","themeClasses","className","addClassNamesToElement","createDOM","config","exportJSON","_objectSpread2","version","insertNewAfter","selection","restoreSelection","arguments","length","newElement","$createHeadingNode","getTag","direction","getDirection","setDirection","insertAfter","collapseAtStart","children","getChildren","forEach","child","append","replace","getType","clone","node","__key","importJSON","serializedNode","setFormat","format","setIndent","indent","BaseHeadingNode","$applyNodeReplacement","$isHeadingNode"],"sources":["HeadingNode.ts"],"sourcesContent":["import {\n EditorConfig,\n $applyNodeReplacement,\n LexicalNode,\n NodeKey,\n RangeSelection,\n Spread\n} from \"lexical\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport {\n HeadingNode as BaseHeadingNode,\n HeadingTagType,\n SerializedHeadingNode as BaseSerializedHeadingNode\n} from \"@lexical/rich-text\";\nimport { WebinyTheme, ThemeEmotionMap, findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { ParagraphNode } from \"~/ParagraphNode\";\nimport { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from \"~/types\";\n\nexport type SerializeHeadingNode = Spread<\n {\n styles: ThemeStyleValue[];\n type: \"heading-element\";\n },\n BaseSerializedHeadingNode\n>;\n\nexport class HeadingNode\n extends BaseHeadingNode\n implements TextNodeThemeStyles, TypographyStylesNode\n{\n __styles: ThemeStyleValue[] = [];\n\n constructor(tag: HeadingTagType, typographyStyleId?: string, key?: NodeKey) {\n super(tag, key);\n\n if (typographyStyleId) {\n this.__styles.push({ styleId: typographyStyleId, type: \"typography\" });\n }\n }\n\n private setDefaultTypography(themeEmotionMap: ThemeEmotionMap) {\n const typographyStyle = findTypographyStyleByHtmlTag(this.__tag, themeEmotionMap);\n if (typographyStyle) {\n this.__styles.push({ styleId: typographyStyle.id, type: \"typography\" });\n }\n }\n\n getTypographyStyleId(): string | undefined {\n const style = this.__styles.find(x => x.type === \"typography\");\n return style?.styleId || undefined;\n }\n\n private hasTypographyStyle(): boolean {\n return !!this.getTypographyStyleId();\n }\n\n getThemeStyles(): ThemeStyleValue[] {\n const self = super.getLatest();\n return self.__styles;\n }\n\n setThemeStyles(styles: ThemeStyleValue[]) {\n const self = super.getWritable();\n self.__styles = [...styles];\n return self;\n }\n\n static override getType(): string {\n return \"heading-element\";\n }\n\n static override clone(node: HeadingNode): HeadingNode {\n return new HeadingNode(node.getTag(), 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 static override importJSON(serializedNode: SerializeHeadingNode): BaseHeadingNode {\n const node = $createHeadingNode(serializedNode.tag);\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 override exportJSON(): SerializeHeadingNode {\n return {\n ...super.exportJSON(),\n styles: this.__styles,\n type: \"heading-element\",\n version: 1\n };\n }\n\n // Mutation\n override insertNewAfter(\n selection?: RangeSelection,\n restoreSelection = true\n ): ParagraphNode | HeadingNode {\n // Next line for headings are always headings with the same tag\n const newElement = $createHeadingNode(this.getTag());\n const direction = this.getDirection();\n newElement.setDirection(direction);\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n\n override collapseAtStart(): true {\n const newElement = $createHeadingNode(this.getTag());\n const children = this.getChildren();\n children.forEach(child => newElement.append(child));\n this.replace(newElement);\n return true;\n }\n}\n\nexport function $createHeadingNode(tag: HeadingTagType, typographyStyleId?: string): HeadingNode {\n return $applyNodeReplacement(new HeadingNode(tag, typographyStyleId));\n}\n\nexport function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode {\n return node instanceof HeadingNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAH,OAAA;AAAmG,IAYtFI,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAAE,gBAAA;EAMpB,SAAAF,YAAYG,GAAmB,EAAEC,iBAA0B,EAAEC,GAAa,EAAE;IAAA,IAA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AACb,UAAU,CAAC;MACxB,OAAO,IAAI;IACf;EAAC;IAAApD,GAAA;IAAAY,KAAA,EA9ED,SAAAsD,QAAA,EAAkC;MAC9B,OAAO,iBAAiB;IAC5B;EAAC;IAAAlE,GAAA;IAAAY,KAAA,EAED,SAAAuD,MAAsBC,IAAiB,EAAe;MAClD,OAAO,IAAIzE,WAAW,CAACyE,IAAI,CAACd,MAAM,CAAC,CAAC,EAAEc,IAAI,CAACjD,oBAAoB,CAAC,CAAC,EAAEiD,IAAI,CAACC,KAAK,CAAC;IAClF;EAAC;IAAArE,GAAA;IAAAY,KAAA,EAmCD,SAAA0D,WAA2BC,cAAoC,EAAmB;MAC9E,IAAMH,IAAI,GAAGf,kBAAkB,CAACkB,cAAc,CAACzE,GAAG,CAAC;MACnDsE,IAAI,CAACI,SAAS,CAACD,cAAc,CAACE,MAAM,CAAC;MACrCL,IAAI,CAACM,SAAS,CAACH,cAAc,CAACI,MAAM,CAAC;MACrCP,IAAI,CAACX,YAAY,CAACc,cAAc,CAAChB,SAAS,CAAC;MAC3Ca,IAAI,CAACrC,cAAc,CAACwC,cAAc,CAACvC,MAAM,CAAC;MAC1C,OAAOoC,IAAI;IACf;EAAC;AAAA,EAxFOQ,qBAAe;AAyHpB,SAASvB,kBAAkBA,CAACvD,GAAmB,EAAEC,iBAA0B,EAAe;EAC7F,OAAO,IAAA8E,8BAAqB,EAAC,IAAIlF,WAAW,CAACG,GAAG,EAAEC,iBAAiB,CAAC,CAAC;AACzE;AAEO,SAAS+E,cAAcA,CAACV,IAAoC,EAAuB;EACtF,OAAOA,IAAI,YAAYzE,WAAW;AACtC","ignoreList":[]}
package/ImageNode.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard3","require","_lexical","ImageComponent","React","lazy","Promise","resolve","then","_interopRequireWildcard2","default","ImageNode","exports","_DecoratorNode","props","key","_this","_classCallCheck2","_callSuper2","__id","id","__src","src","__altText","altText","__maxWidth","maxWidth","__width","width","__height","height","__showCaption","showCaption","__caption","caption","createEditor","__captionsEnabled","captionsEnabled","undefined","_inherits2","_createClass2","value","exportDOM","element","document","createElement","setAttribute","toString","exportJSON","getAltText","toJSON","getSrc","type","version","setWidthAndHeight","writable","getWritable","setShowCaption","createDOM","config","span","theme","className","image","updateDOM","decorate","Suspense","fallback","nodeKey","getKey","resizable","getType","clone","node","__key","importJSON","serializedNode","$createImageNode","nestedEditor","editorState","parseEditorState","isEmpty","setEditorState","importDOM","DecoratorNode","$applyNodeReplacement","$isImageNode"],"sources":["ImageNode.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport React, { Suspense } from \"react\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedEditor,\n SerializedLexicalNode,\n Spread\n} from \"lexical\";\nimport { $applyNodeReplacement, createEditor, DecoratorNode } from \"lexical\";\n\nconst ImageComponent = React.lazy(\n () =>\n import(\n /* webpackChunkName: \"LexicalNodesComponentsImageNodeImageComponent\" */\n \"./components/ImageNode/ImageComponent\"\n )\n);\n\nexport type SerializedImageNode = Spread<\n {\n id: string;\n altText: string;\n caption: SerializedEditor;\n height?: number;\n maxWidth: number;\n showCaption: boolean;\n src: string;\n width?: number;\n },\n SerializedLexicalNode\n>;\n\nexport interface ImageNodeProps {\n id: string;\n src: string;\n altText: string;\n maxWidth: number;\n width?: \"inherit\" | number;\n height?: \"inherit\" | number;\n showCaption?: boolean;\n caption?: LexicalEditor;\n captionsEnabled?: boolean;\n}\n\nexport class ImageNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __src: string;\n __altText: string;\n __width: \"inherit\" | number;\n __height: \"inherit\" | number;\n __maxWidth: number;\n __showCaption: boolean;\n __caption: LexicalEditor;\n // Captions cannot yet be used within editor cells\n __captionsEnabled: boolean;\n\n static override getType(): string {\n return \"image\";\n }\n\n static override clone(node: ImageNode): ImageNode {\n return new ImageNode(\n {\n id: node.__id,\n src: node.__src,\n altText: node.__altText,\n maxWidth: node.__maxWidth,\n width: node.__width,\n height: node.__height,\n showCaption: node.__showCaption,\n caption: node.__caption,\n captionsEnabled: node.__captionsEnabled\n },\n node.__key\n );\n }\n\n static override importJSON(serializedNode: SerializedImageNode): ImageNode {\n const { id, altText, height, width, maxWidth, caption, src, showCaption } = serializedNode;\n const node = $createImageNode({\n id,\n altText,\n height,\n maxWidth,\n showCaption,\n src,\n width\n });\n const nestedEditor = node.__caption;\n const editorState = nestedEditor.parseEditorState(caption.editorState);\n if (!editorState.isEmpty()) {\n nestedEditor.setEditorState(editorState);\n }\n return node;\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement(\"img\");\n element.setAttribute(\"id\", this.__id);\n element.setAttribute(\"src\", this.__src);\n element.setAttribute(\"alt\", this.__altText);\n element.setAttribute(\"width\", this.__width.toString());\n element.setAttribute(\"height\", this.__height.toString());\n return { element };\n }\n\n /**\n * Control how an HTMLElement is represented in Lexical.\n * DOM data comes from clipboard or parsing HTML to nodes with the available lexical functions.\n * (@see @lexical/html package: https://github.com/facebook/lexical/blob/main/packages/lexical-html/README.md).\n */\n static importDOM(): DOMConversionMap | null {\n /**\n * By returning 'null' value, we are preventing image node to be created.\n * Example of how to implement and create the node:\n * https://github.com/facebook/lexical/blob/main/packages/lexical-playground/src/nodes/ImageNode.tsx#L94\n */\n return null;\n }\n\n constructor(props: ImageNodeProps, key?: NodeKey) {\n super(key);\n this.__id = props.id;\n this.__src = props.src;\n this.__altText = props.altText;\n this.__maxWidth = props.maxWidth;\n this.__width = props.width || \"inherit\";\n this.__height = props.height || \"inherit\";\n this.__showCaption = props.showCaption || false;\n this.__caption = props.caption || createEditor();\n this.__captionsEnabled = props.captionsEnabled || props.captionsEnabled === undefined;\n }\n\n override exportJSON(): SerializedImageNode {\n return {\n id: this.__id,\n altText: this.getAltText(),\n caption: this.__caption.toJSON(),\n height: this.__height === \"inherit\" ? 0 : this.__height,\n maxWidth: this.__maxWidth,\n showCaption: this.__showCaption,\n src: this.getSrc(),\n type: \"image\",\n version: 1,\n width: this.__width === \"inherit\" ? 0 : this.__width\n };\n }\n\n setWidthAndHeight(width: \"inherit\" | number, height: \"inherit\" | number): void {\n const writable = this.getWritable();\n writable.__width = width;\n writable.__height = height;\n }\n\n setShowCaption(showCaption: boolean): void {\n const writable = this.getWritable();\n writable.__showCaption = showCaption;\n }\n\n // View\n override createDOM(config: EditorConfig): HTMLElement {\n const span = document.createElement(\"span\");\n const theme = config.theme;\n const className = theme.image;\n if (className !== undefined) {\n span.className = className;\n }\n return span;\n }\n\n override updateDOM(): false {\n return false;\n }\n\n getSrc(): string {\n return this.__src;\n }\n\n getAltText(): string {\n return this.__altText;\n }\n\n override decorate(): JSX.Element {\n return (\n <Suspense fallback={null}>\n <ImageComponent\n id={this.__id}\n src={this.__src}\n altText={this.__altText}\n width={this.__width}\n height={this.__height}\n maxWidth={this.__maxWidth}\n nodeKey={this.getKey()}\n showCaption={this.__showCaption}\n caption={this.__caption}\n captionsEnabled={this.__captionsEnabled}\n resizable={true}\n />\n </Suspense>\n );\n }\n}\n\nexport function $createImageNode(props: ImageNodeProps, key?: string): ImageNode {\n return $applyNodeReplacement(new ImageNode(props, key));\n}\n\nexport function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode {\n return node instanceof ImageNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAAA,MAAA,GAAAC,wBAAA,CAAAC,OAAA;AAYA,IAAAC,QAAA,GAAAD,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,IAAME,cAAc,gBAAGC,cAAK,CAACC,IAAI,CAC7B;EAAA,OAAAC,OAAA,CAAAC,OAAA,GAAAC,IAAA;IAAA,WAAAC,wBAAA,CAAAC,OAAA,EAAAT,OAAA,EAEQ;EAAA;AAAA,CAGZ,CAAC;AAAC,IA4BWU,SAA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,GAAGI,gBAAgB,CAAC;QAC1BzD,EAAE,EAAFA,EAAE;QACFI,OAAO,EAAPA,OAAO;QACPM,MAAM,EAANA,MAAM;QACNJ,QAAQ,EAARA,QAAQ;QACRM,WAAW,EAAXA,WAAW;QACXV,GAAG,EAAHA,GAAG;QACHM,KAAK,EAALA;MACJ,CAAC,CAAC;MACF,IAAMkD,YAAY,GAAGL,IAAI,CAACxC,SAAS;MACnC,IAAM8C,WAAW,GAAGD,YAAY,CAACE,gBAAgB,CAAC9C,OAAO,CAAC6C,WAAW,CAAC;MACtE,IAAI,CAACA,WAAW,CAACE,OAAO,CAAC,CAAC,EAAE;QACxBH,YAAY,CAACI,cAAc,CAACH,WAAW,CAAC;MAC5C;MACA,OAAON,IAAI;IACf;EAAC;IAAA1D,GAAA;IAAA0B,KAAA,EAiBD,SAAA0C,UAAA,EAA4C;MACxC;AACR;AACA;AACA;AACA;MACQ,OAAO,IAAI;IACf;EAAC;AAAA,EA1E0BC,sBAAa;AA+JrC,SAASP,gBAAgBA,CAAC/D,KAAqB,EAAEC,GAAY,EAAa;EAC7E,OAAO,IAAAsE,8BAAqB,EAAC,IAAI1E,SAAS,CAACG,KAAK,EAAEC,GAAG,CAAC,CAAC;AAC3D;AAEO,SAASuE,YAAYA,CAACb,IAAoC,EAAqB;EAClF,OAAOA,IAAI,YAAY9D,SAAS;AACpC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard3","require","_lexical","ImageComponent","React","lazy","Promise","resolve","then","_interopRequireWildcard2","default","ImageNode","exports","_DecoratorNode","props","key","_this","_classCallCheck2","_callSuper2","__id","id","__src","src","__altText","altText","__maxWidth","maxWidth","__width","width","__height","height","__showCaption","showCaption","__caption","caption","createEditor","__captionsEnabled","captionsEnabled","undefined","_inherits2","_createClass2","value","exportDOM","element","document","createElement","setAttribute","toString","exportJSON","getAltText","toJSON","getSrc","type","version","setWidthAndHeight","writable","getWritable","setShowCaption","createDOM","config","span","theme","className","image","updateDOM","decorate","Suspense","fallback","nodeKey","getKey","resizable","getType","clone","node","__key","importJSON","serializedNode","$createImageNode","nestedEditor","editorState","parseEditorState","isEmpty","setEditorState","importDOM","DecoratorNode","$applyNodeReplacement","$isImageNode"],"sources":["ImageNode.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport React, { Suspense } from \"react\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedEditor,\n SerializedLexicalNode,\n Spread\n} from \"lexical\";\nimport { $applyNodeReplacement, createEditor, DecoratorNode } from \"lexical\";\n\nconst ImageComponent = React.lazy(\n () =>\n import(\n /* webpackChunkName: \"LexicalNodesComponentsImageNodeImageComponent\" */\n \"./components/ImageNode/ImageComponent\"\n )\n);\n\nexport type SerializedImageNode = Spread<\n {\n id: string;\n altText: string;\n caption: SerializedEditor;\n height?: number;\n maxWidth: number;\n showCaption: boolean;\n src: string;\n width?: number;\n },\n SerializedLexicalNode\n>;\n\nexport interface ImageNodeProps {\n id: string;\n src: string;\n altText: string;\n maxWidth: number;\n width?: \"inherit\" | number;\n height?: \"inherit\" | number;\n showCaption?: boolean;\n caption?: LexicalEditor;\n captionsEnabled?: boolean;\n}\n\nexport class ImageNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __src: string;\n __altText: string;\n __width: \"inherit\" | number;\n __height: \"inherit\" | number;\n __maxWidth: number;\n __showCaption: boolean;\n __caption: LexicalEditor;\n // Captions cannot yet be used within editor cells\n __captionsEnabled: boolean;\n\n static override getType(): string {\n return \"image\";\n }\n\n static override clone(node: ImageNode): ImageNode {\n return new ImageNode(\n {\n id: node.__id,\n src: node.__src,\n altText: node.__altText,\n maxWidth: node.__maxWidth,\n width: node.__width,\n height: node.__height,\n showCaption: node.__showCaption,\n caption: node.__caption,\n captionsEnabled: node.__captionsEnabled\n },\n node.__key\n );\n }\n\n static override importJSON(serializedNode: SerializedImageNode): ImageNode {\n const { id, altText, height, width, maxWidth, caption, src, showCaption } = serializedNode;\n const node = $createImageNode({\n id,\n altText,\n height,\n maxWidth,\n showCaption,\n src,\n width\n });\n const nestedEditor = node.__caption;\n const editorState = nestedEditor.parseEditorState(caption.editorState);\n if (!editorState.isEmpty()) {\n nestedEditor.setEditorState(editorState);\n }\n return node;\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement(\"img\");\n element.setAttribute(\"id\", this.__id);\n element.setAttribute(\"src\", this.__src);\n element.setAttribute(\"alt\", this.__altText);\n element.setAttribute(\"width\", this.__width.toString());\n element.setAttribute(\"height\", this.__height.toString());\n return { element };\n }\n\n /**\n * Control how an HTMLElement is represented in Lexical.\n * DOM data comes from clipboard or parsing HTML to nodes with the available lexical functions.\n * (@see @lexical/html package: https://github.com/facebook/lexical/blob/main/packages/lexical-html/README.md).\n */\n static override importDOM(): DOMConversionMap | null {\n /**\n * By returning 'null' value, we are preventing image node to be created.\n * Example of how to implement and create the node:\n * https://github.com/facebook/lexical/blob/main/packages/lexical-playground/src/nodes/ImageNode.tsx#L94\n */\n return null;\n }\n\n constructor(props: ImageNodeProps, key?: NodeKey) {\n super(key);\n this.__id = props.id;\n this.__src = props.src;\n this.__altText = props.altText;\n this.__maxWidth = props.maxWidth;\n this.__width = props.width || \"inherit\";\n this.__height = props.height || \"inherit\";\n this.__showCaption = props.showCaption || false;\n this.__caption = props.caption || createEditor();\n this.__captionsEnabled = props.captionsEnabled || props.captionsEnabled === undefined;\n }\n\n override exportJSON(): SerializedImageNode {\n return {\n id: this.__id,\n altText: this.getAltText(),\n caption: this.__caption.toJSON(),\n height: this.__height === \"inherit\" ? 0 : this.__height,\n maxWidth: this.__maxWidth,\n showCaption: this.__showCaption,\n src: this.getSrc(),\n type: \"image\",\n version: 1,\n width: this.__width === \"inherit\" ? 0 : this.__width\n };\n }\n\n setWidthAndHeight(width: \"inherit\" | number, height: \"inherit\" | number): void {\n const writable = this.getWritable();\n writable.__width = width;\n writable.__height = height;\n }\n\n setShowCaption(showCaption: boolean): void {\n const writable = this.getWritable();\n writable.__showCaption = showCaption;\n }\n\n // View\n override createDOM(config: EditorConfig): HTMLElement {\n const span = document.createElement(\"span\");\n const theme = config.theme;\n const className = theme.image;\n if (className !== undefined) {\n span.className = className;\n }\n return span;\n }\n\n override updateDOM(): false {\n return false;\n }\n\n getSrc(): string {\n return this.__src;\n }\n\n getAltText(): string {\n return this.__altText;\n }\n\n override decorate(): JSX.Element {\n return (\n <Suspense fallback={null}>\n <ImageComponent\n id={this.__id}\n src={this.__src}\n altText={this.__altText}\n width={this.__width}\n height={this.__height}\n maxWidth={this.__maxWidth}\n nodeKey={this.getKey()}\n showCaption={this.__showCaption}\n caption={this.__caption}\n captionsEnabled={this.__captionsEnabled}\n resizable={true}\n />\n </Suspense>\n );\n }\n}\n\nexport function $createImageNode(props: ImageNodeProps, key?: string): ImageNode {\n return $applyNodeReplacement(new ImageNode(props, key));\n}\n\nexport function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode {\n return node instanceof ImageNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,IAAAA,MAAA,GAAAC,wBAAA,CAAAC,OAAA;AAYA,IAAAC,QAAA,GAAAD,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,IAAME,cAAc,gBAAGC,cAAK,CAACC,IAAI,CAC7B;EAAA,OAAAC,OAAA,CAAAC,OAAA,GAAAC,IAAA;IAAA,WAAAC,wBAAA,CAAAC,OAAA,EAAAT,OAAA,EAEQ;EAAA;AAAA,CAGZ,CAAC;AAAC,IA4BWU,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAAAE,cAAA;EA4ElB,SAAAF,UAAYG,KAAqB,EAAEC,GAAa,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAP,OAAA,QAAAC,SAAA;IAC9CK,KAAA,OAAAE,WAAA,CAAAR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AALA;MACJ,CAAC,CAAC;MACF,IAAMkD,YAAY,GAAGL,IAAI,CAACxC,SAAS;MACnC,IAAM8C,WAAW,GAAGD,YAAY,CAACE,gBAAgB,CAAC9C,OAAO,CAAC6C,WAAW,CAAC;MACtE,IAAI,CAACA,WAAW,CAACE,OAAO,CAAC,CAAC,EAAE;QACxBH,YAAY,CAACI,cAAc,CAACH,WAAW,CAAC;MAC5C;MACA,OAAON,IAAI;IACf;EAAC;IAAA1D,GAAA;IAAA0B,KAAA,EAiBD,SAAA0C,UAAA,EAAqD;MACjD;AACR;AACA;AACA;AACA;MACQ,OAAO,IAAI;IACf;EAAC;AAAA,EA1E0BC,sBAAa;AA+JrC,SAASP,gBAAgBA,CAAC/D,KAAqB,EAAEC,GAAY,EAAa;EAC7E,OAAO,IAAAsE,8BAAqB,EAAC,IAAI1E,SAAS,CAACG,KAAK,EAAEC,GAAG,CAAC,CAAC;AAC3D;AAEO,SAASuE,YAAYA,CAACb,IAAoC,EAAqB;EAClF,OAAOA,IAAI,YAAY9D,SAAS;AACpC","ignoreList":[]}
package/LinkNode.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  */
9
- import type { DOMConversionMap, EditorConfig, GridSelection, LexicalCommand, LexicalNode, NodeKey, NodeSelection, RangeSelection, SerializedElementNode } from "lexical";
9
+ import type { DOMConversionMap, EditorConfig, RangeSelection, LexicalCommand, LexicalNode, NodeKey, SerializedElementNode } from "lexical";
10
10
  import { ElementNode, Spread } from "lexical";
11
11
  export declare type LinkAttributes = {
12
12
  rel?: null | string;
@@ -58,7 +58,7 @@ export declare class LinkNode extends ElementNode {
58
58
  canInsertTextAfter(): false;
59
59
  canBeEmpty(): false;
60
60
  isInline(): true;
61
- extractWithChild(_: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection): boolean;
61
+ extractWithChild(_: LexicalNode, selection: RangeSelection): boolean;
62
62
  }
63
63
  /**
64
64
  * Takes a URL and creates a LinkNode.
package/LinkNode.js CHANGED
@@ -355,7 +355,7 @@ var AutoLinkNode = exports.AutoLinkNode = /*#__PURE__*/function (_LinkNode) {
355
355
  var element = this.getParentOrThrow().insertNewAfter(selection, restoreSelection);
356
356
  if ((0, _lexical.$isElementNode)(element)) {
357
357
  var linkNode = $createAutoLinkNode(this.__url, {
358
- rel: this._rel,
358
+ rel: this.__rel,
359
359
  target: this.__target,
360
360
  title: this.__title
361
361
  });