@webiny/lexical-nodes 5.44.1-beta.0 β†’ 5.45.0-beta.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 +6 -6
  2. package/FontColorNode.js +102 -145
  3. package/FontColorNode.js.map +1 -1
  4. package/HeadingNode.d.ts +29 -17
  5. package/HeadingNode.js +184 -152
  6. package/HeadingNode.js.map +1 -1
  7. package/ImageNode.d.ts +1 -11
  8. package/ImageNode.js +119 -190
  9. package/ImageNode.js.map +1 -1
  10. package/LinkNode.d.ts +2 -2
  11. package/LinkNode.js +249 -346
  12. package/LinkNode.js.map +1 -1
  13. package/ListItemNode.d.ts +4 -3
  14. package/ListItemNode.js +275 -354
  15. package/ListItemNode.js.map +1 -1
  16. package/ListNode.d.ts +28 -14
  17. package/ListNode.js +170 -209
  18. package/ListNode.js.map +1 -1
  19. package/ParagraphNode.d.ts +28 -16
  20. package/ParagraphNode.js +143 -179
  21. package/ParagraphNode.js.map +1 -1
  22. package/QuoteNode.d.ts +26 -19
  23. package/QuoteNode.js +102 -188
  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 +74 -89
  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 +16 -20
  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 +4 -5
  43. package/types.js +1 -5
  44. package/types.js.map +1 -1
  45. package/utils/clearNodeFormating.d.ts +1 -1
  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 +8 -15
  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 +2 -2
  64. package/utils/listNode.js +37 -50
  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 -146
  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/QuoteNode.js CHANGED
@@ -1,201 +1,115 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.$createQuoteNode = $createQuoteNode;
8
- exports.$isQuoteNode = $isQuoteNode;
9
- exports.QuoteNode = 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 _superPropGet2 = _interopRequireDefault(require("@babel/runtime/helpers/superPropGet"));
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
- var _lexicalTheme = require("@webiny/lexical-theme");
19
- var _utils = require("@lexical/utils");
20
- var _richText = require("@lexical/rich-text");
21
- var QuoteNode = exports.QuoteNode = /*#__PURE__*/function (_BaseQuoteNode) {
22
- function QuoteNode(themeStyleId, key) {
23
- var _this;
24
- (0, _classCallCheck2.default)(this, QuoteNode);
25
- _this = (0, _callSuper2.default)(this, QuoteNode, [key]);
26
- (0, _defineProperty2.default)(_this, "__styles", []);
27
- _this.__themeStyleId = themeStyleId || "";
28
- if (themeStyleId) {
29
- _this.__styles.push({
30
- styleId: themeStyleId,
31
- type: "typography"
32
- });
33
- }
34
- return _this;
1
+ import { $applyNodeReplacement, addClassNamesToElement } from "lexical";
2
+ import { Theme } from "@webiny/lexical-theme";
3
+ import { QuoteNode as BaseQuoteNode } from "@lexical/rich-text";
4
+ import { getStyleId } from "./utils/getStyleId.js";
5
+ export class QuoteNode extends BaseQuoteNode {
6
+ constructor(options = {}) {
7
+ super(options.key);
8
+ this.__styleId = options?.styleId;
9
+ this.__className = options?.className;
35
10
  }
36
- (0, _inherits2.default)(QuoteNode, _BaseQuoteNode);
37
- return (0, _createClass2.default)(QuoteNode, [{
38
- key: "getStyleId",
39
- value: function getStyleId() {
40
- return this.__themeStyleId;
41
- }
42
-
43
- /*
44
- * Find the first occurrence of the quoteblock in the theme styles and set as default.
45
- */
46
- }, {
47
- key: "setDefaultTypography",
48
- value: function setDefaultTypography(themeEmotionMap) {
49
- var typographyStyle = (0, _lexicalTheme.findTypographyStyleByHtmlTag)("quoteblock", themeEmotionMap);
50
- if (typographyStyle) {
51
- this.__styles.push({
52
- styleId: typographyStyle.id,
53
- type: "typography"
54
- });
55
- }
56
- }
57
- }, {
58
- key: "typographyStyleExist",
59
- value: function typographyStyleExist(themeEmotionMap) {
60
- var styleId = this.getTypographyStyleId();
61
- if (!styleId) {
62
- return false;
63
- }
64
- var style = themeEmotionMap[styleId];
65
- return !!style;
66
- }
67
- }, {
68
- key: "getTypographyStyleId",
69
- value: function getTypographyStyleId() {
70
- var style = this.__styles.find(function (x) {
71
- return x.type === "typography";
72
- });
73
- return style?.styleId || undefined;
74
- }
75
- }, {
76
- key: "hasTypographyStyle",
77
- value: function hasTypographyStyle() {
78
- return !!this.getTypographyStyleId();
79
- }
80
- }, {
81
- key: "getThemeStyles",
82
- value: function getThemeStyles() {
83
- var self = (0, _superPropGet2.default)(QuoteNode, "getLatest", this, 3)([]);
84
- return self.__styles;
85
- }
86
- }, {
87
- key: "setThemeStyles",
88
- value: function setThemeStyles(styles) {
89
- var self = (0, _superPropGet2.default)(QuoteNode, "getWritable", this, 3)([]);
90
- self.__styles = (0, _toConsumableArray2.default)(styles);
91
- return self;
92
- }
93
- }, {
94
- key: "addThemeStylesToHTMLElement",
95
- value: function addThemeStylesToHTMLElement(element, theme) {
96
- var themeEmotionMap = theme?.emotionMap;
97
- if (!themeEmotionMap) {
98
- return element;
99
- }
100
-
101
- // style exist and is in active use
102
- if (this.hasTypographyStyle() && this.typographyStyleExist(themeEmotionMap)) {
103
- var styleId = this.getTypographyStyleId();
104
- if (styleId) {
105
- var typographyValue = themeEmotionMap[styleId];
106
- (0, _utils.addClassNamesToElement)(element, typographyValue?.className);
107
- return element;
108
- }
109
- }
110
- return element;
11
+ getStyleId() {
12
+ return this.__styleId;
13
+ }
14
+ setStyleId(styleId) {
15
+ this.__styleId = styleId;
16
+ }
17
+ setClassName(className) {
18
+ this.__className = className;
19
+ }
20
+ getClassName() {
21
+ return this.__className;
22
+ }
23
+ setDefaultTypography(theme) {
24
+ // For some time in v5 we had `quoteblock` as tag name :facepalm: We must not break it.
25
+ const typographyStyle = theme.getTypographyByTag(["blockquote", "quoteblock"]);
26
+ if (typographyStyle) {
27
+ this.__styleId = typographyStyle.id;
28
+ this.__className = typographyStyle.className;
111
29
  }
112
- }, {
113
- key: "createDOM",
114
- value: function createDOM(config) {
115
- var element = (0, _superPropGet2.default)(QuoteNode, "createDOM", this, 3)([config]);
116
- var wTheme = config.theme;
117
- var emotionThemeMap = wTheme?.emotionMap;
118
- if (!emotionThemeMap) {
119
- return element;
120
- }
121
-
122
- // if styleId is not set or user removed the style from theme, set default style
123
- if (!this.hasTypographyStyle() || !this.typographyStyleExist(emotionThemeMap)) {
124
- this.setDefaultTypography(emotionThemeMap);
30
+ }
31
+ static getType() {
32
+ return "wby-quote";
33
+ }
34
+ static clone(node) {
35
+ return new QuoteNode({
36
+ styleId: node.getStyleId(),
37
+ className: node.getClassName(),
38
+ key: node.getKey()
39
+ });
40
+ }
41
+ createDOM(config) {
42
+ const element = super.createDOM(config);
43
+ return this.updateElementWithThemeClasses(element, Theme.from(config.theme));
44
+ }
45
+ exportDOM(editor) {
46
+ const base = super.exportDOM(editor);
47
+ const element = base.element;
48
+ if (element && this.__className) {
49
+ element.classList.add(this.__className);
50
+ }
51
+ return {
52
+ ...base,
53
+ element
54
+ };
55
+ }
56
+ static importDomConversionMap() {
57
+ return {
58
+ conversion: convertBlockquoteElement,
59
+ priority: 0
60
+ };
61
+ }
62
+ static importDOM() {
63
+ return {
64
+ blockquote: () => {
65
+ return this.importDomConversionMap();
125
66
  }
126
- this.addThemeStylesToHTMLElement(element, config.theme);
127
- return element;
128
- }
129
- }, {
130
- key: "exportJSON",
131
- value: function exportJSON() {
132
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _superPropGet2.default)(QuoteNode, "exportJSON", this, 3)([])), {}, {
133
- type: "webiny-quote",
134
- styles: this.__styles,
135
- styleId: this.getTypographyStyleId()
136
- });
137
- }
138
- }], [{
139
- key: "getType",
140
- value: function getType() {
141
- return "webiny-quote";
142
- }
143
- }, {
144
- key: "clone",
145
- value: function clone(node) {
146
- return new QuoteNode(node.getTypographyStyleId(), node.__key);
147
- }
148
- }, {
149
- key: "importDomConversionMap",
150
- value: function importDomConversionMap() {
151
- return {
152
- conversion: convertBlockquoteElement,
153
- priority: 0
154
- };
67
+ };
68
+ }
69
+ static importJSON(serializedNode) {
70
+ const node = $createQuoteNode();
71
+ node.setFormat(serializedNode.format);
72
+ node.setIndent(serializedNode.indent);
73
+ node.setDirection(serializedNode.direction);
74
+ const styleId = getStyleId({
75
+ styleId: serializedNode.styleId,
76
+ styles: serializedNode.styles
77
+ });
78
+ node.setStyleId(styleId);
79
+ node.setClassName(serializedNode.className);
80
+ return node;
81
+ }
82
+ exportJSON() {
83
+ return {
84
+ ...super.exportJSON(),
85
+ type: "wby-quote",
86
+ className: this.__className,
87
+ styleId: this.__styleId
88
+ };
89
+ }
90
+ updateElementWithThemeClasses(element, theme) {
91
+ if (!this.__styleId || !this.__className) {
92
+ this.setDefaultTypography(theme);
155
93
  }
156
- }, {
157
- key: "importDOM",
158
- value: function importDOM() {
159
- var _this2 = this;
160
- return {
161
- blockquote: function blockquote() {
162
- return _this2.importDomConversionMap();
163
- }
164
- };
94
+ if (this.__className) {
95
+ addClassNamesToElement(element, this.__className);
165
96
  }
166
- }, {
167
- key: "importJSON",
168
- value: function importJSON(serializedNode) {
169
- var node = $createQuoteNode();
170
- node.setFormat(serializedNode.format);
171
- node.setIndent(serializedNode.indent);
172
- node.setDirection(serializedNode.direction);
173
- if (!!serializedNode?.styles?.length) {
174
- node.setThemeStyles(serializedNode.styles);
175
- return node;
176
- }
177
- // for old nodes data migrate the style id into the list
178
- if (!!serializedNode?.styleId) {
179
- var styles = [{
180
- styleId: serializedNode.styleId,
181
- type: "typography"
182
- }];
183
- node.setThemeStyles(styles);
184
- }
185
- return node;
186
- }
187
- }]);
188
- }(_richText.QuoteNode);
97
+ return element;
98
+ }
99
+ }
189
100
  function convertBlockquoteElement() {
190
- var node = $createQuoteNode();
101
+ const node = $createQuoteNode();
191
102
  return {
192
- node: node
103
+ node
193
104
  };
194
105
  }
195
- function $createQuoteNode(themeStyleId, key) {
196
- return new QuoteNode(themeStyleId, key);
106
+ export function $createQuoteNode(styleId, key) {
107
+ return $applyNodeReplacement(new QuoteNode({
108
+ styleId,
109
+ key
110
+ }));
197
111
  }
198
- function $isQuoteNode(node) {
112
+ export function $isQuoteNode(node) {
199
113
  return node instanceof QuoteNode;
200
114
  }
201
115
 
package/QuoteNode.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_lexicalTheme","require","_utils","_richText","QuoteNode","exports","_BaseQuoteNode","themeStyleId","key","_this","_classCallCheck2","default","_callSuper2","_defineProperty2","__themeStyleId","__styles","push","styleId","type","_inherits2","_createClass2","value","getStyleId","setDefaultTypography","themeEmotionMap","typographyStyle","findTypographyStyleByHtmlTag","id","typographyStyleExist","getTypographyStyleId","style","find","x","undefined","hasTypographyStyle","getThemeStyles","self","_superPropGet2","setThemeStyles","styles","_toConsumableArray2","addThemeStylesToHTMLElement","element","theme","emotionMap","typographyValue","addClassNamesToElement","className","createDOM","config","wTheme","emotionThemeMap","exportJSON","_objectSpread2","getType","clone","node","__key","importDomConversionMap","conversion","convertBlockquoteElement","priority","importDOM","_this2","blockquote","importJSON","serializedNode","$createQuoteNode","setFormat","format","setIndent","indent","setDirection","direction","length","BaseQuoteNode","$isQuoteNode"],"sources":["QuoteNode.ts"],"sourcesContent":["import {\n DOMConversion,\n DOMConversionMap,\n EditorConfig,\n LexicalNode,\n NodeKey,\n Spread\n} from \"lexical\";\nimport { EditorTheme, ThemeEmotionMap, findTypographyStyleByHtmlTag } from \"@webiny/lexical-theme\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport {\n QuoteNode as BaseQuoteNode,\n SerializedQuoteNode as BaseSerializedQuoteNode\n} from \"@lexical/rich-text\";\nimport { TextNodeThemeStyles, ThemeStyleValue, TypographyStylesNode } from \"~/types\";\n\nexport type SerializedQuoteNode = Spread<\n {\n styleId?: string;\n styles: ThemeStyleValue[];\n type: \"webiny-quote\";\n },\n BaseSerializedQuoteNode\n>;\n\nexport class QuoteNode extends BaseQuoteNode implements TextNodeThemeStyles, TypographyStylesNode {\n private __themeStyleId: string;\n private __styles: ThemeStyleValue[] = [];\n\n constructor(themeStyleId?: string, key?: NodeKey) {\n super(key);\n this.__themeStyleId = themeStyleId || \"\";\n\n if (themeStyleId) {\n this.__styles.push({ styleId: themeStyleId, type: \"typography\" });\n }\n }\n\n getStyleId(): string {\n return this.__themeStyleId;\n }\n\n /*\n * Find the first occurrence of the quoteblock in the theme styles and set as default.\n */\n protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap) {\n const typographyStyle = findTypographyStyleByHtmlTag(\"quoteblock\", themeEmotionMap);\n if (typographyStyle) {\n this.__styles.push({ styleId: typographyStyle.id, type: \"typography\" });\n }\n }\n\n protected typographyStyleExist(themeEmotionMap: ThemeEmotionMap): boolean {\n const styleId = this.getTypographyStyleId();\n if (!styleId) {\n return false;\n }\n const style = themeEmotionMap[styleId];\n return !!style;\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 \"webiny-quote\";\n }\n\n static override clone(node: QuoteNode): QuoteNode {\n return new QuoteNode(node.getTypographyStyleId(), node.__key);\n }\n\n addThemeStylesToHTMLElement(element: HTMLElement, theme: EditorTheme): HTMLElement {\n const themeEmotionMap = theme?.emotionMap;\n\n if (!themeEmotionMap) {\n return element;\n }\n\n // style exist and is in active use\n if (this.hasTypographyStyle() && this.typographyStyleExist(themeEmotionMap)) {\n const styleId = this.getTypographyStyleId();\n if (styleId) {\n const typographyValue = themeEmotionMap[styleId];\n addClassNamesToElement(element, typographyValue?.className);\n return element;\n }\n }\n\n return element;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n const wTheme = config.theme as EditorTheme;\n const emotionThemeMap = wTheme?.emotionMap;\n\n if (!emotionThemeMap) {\n return element;\n }\n\n // if styleId is not set or user removed the style from theme, set default style\n if (!this.hasTypographyStyle() || !this.typographyStyleExist(emotionThemeMap)) {\n this.setDefaultTypography(emotionThemeMap);\n }\n\n this.addThemeStylesToHTMLElement(element, config.theme as EditorTheme);\n return element;\n }\n\n static importDomConversionMap(): DOMConversion<HTMLElement> | null {\n return {\n conversion: convertBlockquoteElement,\n priority: 0\n };\n }\n\n static override importDOM(): DOMConversionMap | null {\n return {\n blockquote: () => {\n return this.importDomConversionMap();\n }\n };\n }\n\n static override importJSON(serializedNode: SerializedQuoteNode): QuoteNode {\n const node = $createQuoteNode();\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n if (!!serializedNode?.styles?.length) {\n node.setThemeStyles(serializedNode.styles);\n return node;\n }\n // for old nodes data migrate the style id into the list\n if (!!serializedNode?.styleId) {\n const styles = [\n { styleId: serializedNode.styleId, type: \"typography\" }\n ] as ThemeStyleValue[];\n node.setThemeStyles(styles);\n }\n return node;\n }\n\n override exportJSON(): SerializedQuoteNode {\n return {\n ...super.exportJSON(),\n type: \"webiny-quote\",\n styles: this.__styles,\n styleId: this.getTypographyStyleId()\n };\n }\n}\n\nfunction convertBlockquoteElement() {\n const node = $createQuoteNode();\n return {\n node\n };\n}\n\nexport function $createQuoteNode(themeStyleId?: string, key?: NodeKey): QuoteNode {\n return new QuoteNode(themeStyleId, key);\n}\n\nexport function $isQuoteNode(node: LexicalNode | null | undefined): node is QuoteNode {\n return node instanceof QuoteNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAG4B,IAYfG,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAAAE,cAAA;EAIlB,SAAAF,UAAYG,YAAqB,EAAEC,GAAa,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAP,SAAA;IAC9CK,KAAA,OAAAG,WAAA,CAAAD,OAAA,QAAAP,SAAA,GAAMI,GAAG;IAAE,IAAAK,gBAAA,CAAAF,OAAA,EAAAF,KAAA,cAHuB,EAAE;IAIpCA,KAAA,CAAKK,cAAc,GAAGP,YAAY,IAAI,EAAE;IAExC,IAAIA,YAAY,EAAE;MACdE,KAAA,CAAKM,QAAQ,CAACC,IAAI,CAAC;QAAEC,OAAO,EAAEV,YAAY;QAAEW,IAAI,EAAE;MAAa,CAAC,CAAC;IACrE;IAAC,OAAAT,KAAA;EACL;EAAC,IAAAU,UAAA,CAAAR,OAAA,EAAAP,SAAA,EAAAE,cAAA;EAAA,WAAAc,aAAA,CAAAT,OAAA,EAAAP,SAAA;IAAAI,GAAA;IAAAa,KAAA,EAED,SAAAC,UAAUA,CAAA,EAAW;MACjB,OAAO,IAAI,CAACR,cAAc;IAC9B;;IAEA;AACJ;AACA;EAFI;IAAAN,GAAA;IAAAa,KAAA,EAGA,SAAUE,oBAAoBA,CAACC,eAAgC,EAAE;MAC7D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AAc,EAAE3B,MAAM,EAAEmC,MAAM,EAAE;QAClClB,IAAI,CAAClB,cAAc,CAAC4B,cAAc,CAAC3B,MAAM,CAAC;QAC1C,OAAOiB,IAAI;MACf;MACA;MACA,IAAI,CAAC,CAACU,cAAc,EAAEjD,OAAO,EAAE;QAC3B,IAAMsB,MAAM,GAAG,CACX;UAAEtB,OAAO,EAAEiD,cAAc,CAACjD,OAAO;UAAEC,IAAI,EAAE;QAAa,CAAC,CACrC;QACtBsC,IAAI,CAAClB,cAAc,CAACC,MAAM,CAAC;MAC/B;MACA,OAAOiB,IAAI;IACf;EAAC;AAAA,EAtI0BmB,mBAAa;AAkJ5C,SAASf,wBAAwBA,CAAA,EAAG;EAChC,IAAMJ,IAAI,GAAGW,gBAAgB,CAAC,CAAC;EAC/B,OAAO;IACHX,IAAI,EAAJA;EACJ,CAAC;AACL;AAEO,SAASW,gBAAgBA,CAAC5D,YAAqB,EAAEC,GAAa,EAAa;EAC9E,OAAO,IAAIJ,SAAS,CAACG,YAAY,EAAEC,GAAG,CAAC;AAC3C;AAEO,SAASoE,YAAYA,CAACpB,IAAoC,EAAqB;EAClF,OAAOA,IAAI,YAAYpD,SAAS;AACpC","ignoreList":[]}
1
+ {"version":3,"names":["$applyNodeReplacement","addClassNamesToElement","Theme","QuoteNode","BaseQuoteNode","getStyleId","constructor","options","key","__styleId","styleId","__className","className","setStyleId","setClassName","getClassName","setDefaultTypography","theme","typographyStyle","getTypographyByTag","id","getType","clone","node","getKey","createDOM","config","element","updateElementWithThemeClasses","from","exportDOM","editor","base","classList","add","importDomConversionMap","conversion","convertBlockquoteElement","priority","importDOM","blockquote","importJSON","serializedNode","$createQuoteNode","setFormat","format","setIndent","indent","setDirection","direction","styles","exportJSON","type","$isQuoteNode"],"sources":["QuoteNode.ts"],"sourcesContent":["import type {\n DOMConversion,\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread\n} from \"lexical\";\nimport { $applyNodeReplacement, addClassNamesToElement } from \"lexical\";\nimport { Theme } from \"@webiny/lexical-theme\";\nimport type { SerializedQuoteNode as BaseSerializedQuoteNode } from \"@lexical/rich-text\";\nimport { QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport type { ThemeStyleValue, TypographyStylesNode } from \"~/types.js\";\nimport { getStyleId } from \"~/utils/getStyleId.js\";\n\nexport type SerializedQuoteNode = Spread<\n {\n styleId?: string;\n styles?: ThemeStyleValue[];\n className?: string;\n type: \"wby-quote\";\n },\n BaseSerializedQuoteNode\n>;\n\ninterface QuoteNodeOptions {\n className?: string;\n styleId?: string;\n key?: NodeKey;\n}\n\nexport class QuoteNode extends BaseQuoteNode implements TypographyStylesNode {\n private __styleId: string | undefined;\n private __className: string | undefined;\n\n constructor(options: QuoteNodeOptions = {}) {\n super(options.key);\n this.__styleId = options?.styleId;\n this.__className = options?.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 private setDefaultTypography(theme: Theme) {\n // For some time in v5 we had `quoteblock` as tag name :facepalm: We must not break it.\n const typographyStyle = theme.getTypographyByTag([\"blockquote\", \"quoteblock\"]);\n\n if (typographyStyle) {\n this.__styleId = typographyStyle.id;\n this.__className = typographyStyle.className;\n }\n }\n\n static override getType(): string {\n return \"wby-quote\";\n }\n\n static override clone(node: QuoteNode): QuoteNode {\n return new QuoteNode({\n styleId: node.getStyleId(),\n className: node.getClassName(),\n key: node.getKey()\n });\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 static importDomConversionMap(): DOMConversion<HTMLElement> | null {\n return {\n conversion: convertBlockquoteElement,\n priority: 0\n };\n }\n\n static override importDOM(): DOMConversionMap | null {\n return {\n blockquote: () => {\n return this.importDomConversionMap();\n }\n };\n }\n\n static override importJSON(serializedNode: SerializedQuoteNode): QuoteNode {\n const node = $createQuoteNode();\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\n return node;\n }\n\n override exportJSON(): SerializedQuoteNode {\n return {\n ...super.exportJSON(),\n type: \"wby-quote\",\n className: this.__className,\n styleId: this.__styleId\n };\n }\n\n protected updateElementWithThemeClasses(element: HTMLElement, theme: Theme): HTMLElement {\n if (!this.__styleId || !this.__className) {\n this.setDefaultTypography(theme);\n }\n\n if (this.__className) {\n addClassNamesToElement(element, this.__className);\n }\n\n return element;\n }\n}\n\nfunction convertBlockquoteElement() {\n const node = $createQuoteNode();\n return {\n node\n };\n}\n\nexport function $createQuoteNode(styleId?: string, key?: NodeKey): QuoteNode {\n return $applyNodeReplacement(new QuoteNode({ styleId, key }));\n}\n\nexport function $isQuoteNode(node: LexicalNode | null | undefined): node is QuoteNode {\n return node instanceof QuoteNode;\n}\n"],"mappings":"AAUA,SAASA,qBAAqB,EAAEC,sBAAsB,QAAQ,SAAS;AACvE,SAASC,KAAK,QAAQ,uBAAuB;AAE7C,SAASC,SAAS,IAAIC,aAAa,QAAQ,oBAAoB;AAE/D,SAASC,UAAU;AAkBnB,OAAO,MAAMF,SAAS,SAASC,aAAa,CAAiC;EAIzEE,WAAWA,CAACC,OAAyB,GAAG,CAAC,CAAC,EAAE;IACxC,KAAK,CAACA,OAAO,CAACC,GAAG,CAAC;IAClB,IAAI,CAACC,SAAS,GAAGF,OAAO,EAAEG,OAAO;IACjC,IAAI,CAACC,WAAW,G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ACrF,IAAI,CAAC,IAAI,CAACR,SAAS,IAAI,CAAC,IAAI,CAACE,WAAW,EAAE;MACtC,IAAI,CAACK,oBAAoB,CAACC,KAAK,CAAC;IACpC;IAEA,IAAI,IAAI,CAACN,WAAW,EAAE;MAClBV,sBAAsB,CAAC0B,OAAO,EAAE,IAAI,CAAChB,WAAW,CAAC;IACrD;IAEA,OAAOgB,OAAO;EAClB;AACJ;AAEA,SAASU,wBAAwBA,CAAA,EAAG;EAChC,MAAMd,IAAI,GAAGoB,gBAAgB,CAAC,CAAC;EAC/B,OAAO;IACHpB;EACJ,CAAC;AACL;AAEA,OAAO,SAASoB,gBAAgBA,CAACjC,OAAgB,EAAEF,GAAa,EAAa;EACzE,OAAOR,qBAAqB,CAAC,IAAIG,SAAS,CAAC;IAAEO,OAAO;IAAEF;EAAI,CAAC,CAAC,CAAC;AACjE;AAEA,OAAO,SAAS6C,YAAYA,CAAC9B,IAAoC,EAAqB;EAClF,OAAOA,IAAI,YAAYpB,SAAS;AACpC","ignoreList":[]}
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # @webiny/lexical-nodes
2
2
 
3
- [![](https://img.shields.io/npm/dw/@webiny/lexical-nodes.svg)](https://www.npmjs.com/package/@webiny/llexical-lexical-nodes)
4
- [![](https://img.shields.io/npm/v/@webiny/lexical-nodes.svg)](https://www.npmjs.com/package/@webiny/lexical-nodes)
5
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -1,18 +1,13 @@
1
- /// <reference types="react" />
2
- import type { LexicalEditor, NodeKey } from "lexical";
3
- import "./ImageComponent.css";
1
+ import type { NodeKey } from "lexical";
4
2
  interface ImageComponentProps {
5
3
  id: string;
6
4
  altText: string;
7
- caption: LexicalEditor;
8
5
  height: "inherit" | number;
9
6
  maxWidth: number;
10
7
  nodeKey: NodeKey;
11
8
  resizable: boolean;
12
- showCaption: boolean;
13
9
  src: string;
14
10
  width: "inherit" | number;
15
- captionsEnabled: boolean;
16
11
  }
17
- export default function ImageComponent({ id, src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled }: ImageComponentProps): JSX.Element;
12
+ export default function ImageComponent({ id, src, altText, nodeKey, width, height, maxWidth, resizable }: ImageComponentProps): JSX.Element;
18
13
  export {};