@webiny/lexical-editor 5.35.2 → 5.36.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.
- package/components/Editor/HeadingEditor.js +1 -1
- package/components/Editor/HeadingEditor.js.map +1 -1
- package/components/Editor/RichTextEditor.js +1 -1
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js +0 -2
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +30 -3
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/hooks/useQuote.d.ts +2 -0
- package/hooks/{useWebinyQuote.js → useQuote.js} +2 -2
- package/hooks/useQuote.js.map +1 -0
- package/nodes/HeadingNode.d.ts +34 -0
- package/nodes/HeadingNode.js +192 -0
- package/nodes/HeadingNode.js.map +1 -0
- package/nodes/ParagraphNode.d.ts +32 -0
- package/nodes/ParagraphNode.js +218 -0
- package/nodes/ParagraphNode.js.map +1 -0
- package/nodes/QuoteNode.d.ts +34 -0
- package/nodes/QuoteNode.js +225 -0
- package/nodes/QuoteNode.js.map +1 -0
- package/nodes/TypographyElementNode.js +2 -1
- package/nodes/TypographyElementNode.js.map +1 -1
- package/nodes/list-node/WebinyListItemNode.js +2 -1
- package/nodes/list-node/WebinyListItemNode.js.map +1 -1
- package/nodes/list-node/formatList.js +3 -2
- package/nodes/list-node/formatList.js.map +1 -1
- package/nodes/types.d.ts +15 -0
- package/nodes/types.js +5 -0
- package/nodes/types.js.map +1 -0
- package/nodes/webinyNodes.js +29 -5
- package/nodes/webinyNodes.js.map +1 -1
- package/package.json +17 -17
- package/plugins/FontColorPlugin/FontColorPlugin.js +2 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +9 -5
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts +1 -1
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +7 -7
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -1
- package/themes/webinyLexicalTheme.css +18 -9
- package/types.d.ts +2 -3
- package/types.js.map +1 -1
- package/ui/DropDown.js +52 -19
- package/ui/DropDown.js.map +1 -1
- package/utils/findTypographyStyleByHtmlTag.d.ts +8 -0
- package/utils/findTypographyStyleByHtmlTag.js +16 -0
- package/utils/findTypographyStyleByHtmlTag.js.map +1 -0
- package/utils/generateInitialLexicalValue.js +2 -1
- package/utils/generateInitialLexicalValue.js.map +1 -1
- package/utils/getLexicalTextSelectionState.js +19 -3
- package/utils/getLexicalTextSelectionState.js.map +1 -1
- package/utils/nodes/formatToHeading.d.ts +3 -0
- package/utils/nodes/formatToHeading.js +25 -0
- package/utils/nodes/formatToHeading.js.map +1 -0
- package/utils/nodes/formatToParagraph.d.ts +1 -1
- package/utils/nodes/formatToParagraph.js +4 -3
- package/utils/nodes/formatToParagraph.js.map +1 -1
- package/utils/nodes/formatToQuote.js +8 -3
- package/utils/nodes/formatToQuote.js.map +1 -1
- package/hooks/useWebinyQuote.d.ts +0 -2
- package/hooks/useWebinyQuote.js.map +0 -1
- package/nodes/WebinyQuoteNode.d.ts +0 -29
- package/nodes/WebinyQuoteNode.js +0 -148
- package/nodes/WebinyQuoteNode.js.map +0 -1
package/nodes/WebinyQuoteNode.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.$createWebinyQuoteNode = $createWebinyQuoteNode;
|
|
8
|
-
exports.$isWebinyQuoteNode = $isWebinyQuoteNode;
|
|
9
|
-
exports.WebinyQuoteNode = void 0;
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
14
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
var _lexical = require("lexical");
|
|
20
|
-
var _styleObjectToString = require("../utils/styleObjectToString");
|
|
21
|
-
var _utils = require("@lexical/utils");
|
|
22
|
-
function convertBlockquoteElement() {
|
|
23
|
-
var node = $createWebinyQuoteNode();
|
|
24
|
-
return {
|
|
25
|
-
node: node
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
var QuoteNodeAttrName = "data-quote-style-id";
|
|
29
|
-
var WebinyQuoteNode = /*#__PURE__*/function (_ElementNode) {
|
|
30
|
-
(0, _inherits2.default)(WebinyQuoteNode, _ElementNode);
|
|
31
|
-
var _super = (0, _createSuper2.default)(WebinyQuoteNode);
|
|
32
|
-
function WebinyQuoteNode(themeStyleId, key) {
|
|
33
|
-
var _this;
|
|
34
|
-
(0, _classCallCheck2.default)(this, WebinyQuoteNode);
|
|
35
|
-
_this = _super.call(this, key);
|
|
36
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__themeStyleId", void 0);
|
|
37
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getStyleId", function () {
|
|
38
|
-
return _this.__themeStyleId;
|
|
39
|
-
});
|
|
40
|
-
_this.__themeStyleId = themeStyleId || "";
|
|
41
|
-
return _this;
|
|
42
|
-
}
|
|
43
|
-
(0, _createClass2.default)(WebinyQuoteNode, [{
|
|
44
|
-
key: "getTag",
|
|
45
|
-
value: function getTag() {
|
|
46
|
-
return "quoteblock";
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
key: "addThemeStylesToHTMLElement",
|
|
50
|
-
value: function addThemeStylesToHTMLElement(element, theme) {
|
|
51
|
-
var styles = {};
|
|
52
|
-
var typographyValue = theme !== null && theme !== void 0 && theme.emotionMap ? theme.emotionMap[this.__themeStyleId] : undefined;
|
|
53
|
-
if (this.__themeStyleId && typographyValue) {
|
|
54
|
-
styles = typographyValue.styles;
|
|
55
|
-
(0, _utils.addClassNamesToElement)(element, typographyValue === null || typographyValue === void 0 ? void 0 : typographyValue.className);
|
|
56
|
-
}
|
|
57
|
-
element.setAttribute(QuoteNodeAttrName, this.__themeStyleId || "");
|
|
58
|
-
element.style.cssText = (0, _styleObjectToString.styleObjectToString)(styles);
|
|
59
|
-
return element;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// View
|
|
63
|
-
}, {
|
|
64
|
-
key: "createDOM",
|
|
65
|
-
value: function createDOM(config) {
|
|
66
|
-
var element = document.createElement("blockquote");
|
|
67
|
-
(0, _utils.addClassNamesToElement)(element, config.theme.quote);
|
|
68
|
-
this.addThemeStylesToHTMLElement(element, config.theme);
|
|
69
|
-
return element;
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "updateDOM",
|
|
73
|
-
value: function updateDOM() {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "exportJSON",
|
|
78
|
-
value: function exportJSON() {
|
|
79
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(WebinyQuoteNode.prototype), "exportJSON", this).call(this)), {}, {
|
|
80
|
-
tag: "quoteblock",
|
|
81
|
-
type: "webiny-quote",
|
|
82
|
-
styleId: this.__themeStyleId,
|
|
83
|
-
version: 1
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Mutation
|
|
88
|
-
}, {
|
|
89
|
-
key: "insertNewAfter",
|
|
90
|
-
value: function insertNewAfter() {
|
|
91
|
-
var newBlock = (0, _lexical.$createParagraphNode)();
|
|
92
|
-
var direction = this.getDirection();
|
|
93
|
-
newBlock.setDirection(direction);
|
|
94
|
-
this.insertAfter(newBlock);
|
|
95
|
-
return newBlock;
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "collapseAtStart",
|
|
99
|
-
value: function collapseAtStart() {
|
|
100
|
-
var paragraph = (0, _lexical.$createParagraphNode)();
|
|
101
|
-
var children = this.getChildren();
|
|
102
|
-
children.forEach(function (child) {
|
|
103
|
-
return paragraph.append(child);
|
|
104
|
-
});
|
|
105
|
-
this.replace(paragraph);
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
}], [{
|
|
109
|
-
key: "getType",
|
|
110
|
-
value: function getType() {
|
|
111
|
-
return "webiny-quote";
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "clone",
|
|
115
|
-
value: function clone(node) {
|
|
116
|
-
return new WebinyQuoteNode(node.__themeStyleId, node.__key);
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "importDOM",
|
|
120
|
-
value: function importDOM() {
|
|
121
|
-
return {
|
|
122
|
-
blockquote: function blockquote() {
|
|
123
|
-
return {
|
|
124
|
-
conversion: convertBlockquoteElement,
|
|
125
|
-
priority: 0
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "importJSON",
|
|
132
|
-
value: function importJSON(serializedNode) {
|
|
133
|
-
var node = $createWebinyQuoteNode(serializedNode.styleId);
|
|
134
|
-
node.setFormat(serializedNode.format);
|
|
135
|
-
node.setIndent(serializedNode.indent);
|
|
136
|
-
node.setDirection(serializedNode.direction);
|
|
137
|
-
return node;
|
|
138
|
-
}
|
|
139
|
-
}]);
|
|
140
|
-
return WebinyQuoteNode;
|
|
141
|
-
}(_lexical.ElementNode);
|
|
142
|
-
exports.WebinyQuoteNode = WebinyQuoteNode;
|
|
143
|
-
function $createWebinyQuoteNode(themeStyleId, key) {
|
|
144
|
-
return new WebinyQuoteNode(themeStyleId, key);
|
|
145
|
-
}
|
|
146
|
-
function $isWebinyQuoteNode(node) {
|
|
147
|
-
return node instanceof WebinyQuoteNode;
|
|
148
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["convertBlockquoteElement","node","$createWebinyQuoteNode","QuoteNodeAttrName","WebinyQuoteNode","themeStyleId","key","__themeStyleId","element","theme","styles","typographyValue","emotionMap","undefined","addClassNamesToElement","className","setAttribute","style","cssText","styleObjectToString","config","document","createElement","quote","addThemeStylesToHTMLElement","tag","type","styleId","version","newBlock","$createParagraphNode","direction","getDirection","setDirection","insertAfter","paragraph","children","getChildren","forEach","child","append","replace","__key","blockquote","conversion","priority","serializedNode","setFormat","format","setIndent","indent","ElementNode","$isWebinyQuoteNode"],"sources":["WebinyQuoteNode.ts"],"sourcesContent":["import {\n $createParagraphNode,\n DOMConversionMap,\n EditorConfig,\n ElementNode,\n LexicalNode,\n NodeKey,\n ParagraphNode,\n SerializedElementNode,\n Spread\n} from \"lexical\";\nimport { WebinyEditorTheme } from \"~/themes/webinyLexicalTheme\";\nimport { styleObjectToString } from \"~/utils/styleObjectToString\";\nimport { QuoteBlockHtmlTag, WebinyThemeNode } from \"~/types\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport { CSSObject } from \"@emotion/react\";\n\nfunction convertBlockquoteElement() {\n const node = $createWebinyQuoteNode();\n return {\n node\n };\n}\n\nconst QuoteNodeAttrName = \"data-quote-style-id\";\n\nexport type SerializedWebinyQuoteNode = Spread<\n {\n tag: QuoteBlockHtmlTag;\n styleId: string;\n type: \"webiny-quote\";\n version: 1;\n },\n SerializedElementNode\n>;\n\nexport class WebinyQuoteNode extends ElementNode implements WebinyThemeNode {\n __themeStyleId: string;\n\n constructor(themeStyleId?: string, key?: NodeKey) {\n super(key);\n this.__themeStyleId = themeStyleId || \"\";\n }\n\n getStyleId = (): string => {\n return this.__themeStyleId;\n };\n\n static override getType(): string {\n return \"webiny-quote\";\n }\n\n getTag(): QuoteBlockHtmlTag {\n return \"quoteblock\";\n }\n\n static override clone(node: WebinyQuoteNode): WebinyQuoteNode {\n return new WebinyQuoteNode(node.__themeStyleId, node.__key);\n }\n\n addThemeStylesToHTMLElement(element: HTMLElement, theme: WebinyEditorTheme): HTMLElement {\n let styles: CSSObject = {};\n const typographyValue = theme?.emotionMap\n ? theme.emotionMap[this.__themeStyleId]\n : undefined;\n if (this.__themeStyleId && typographyValue) {\n styles = typographyValue.styles;\n addClassNamesToElement(element, typographyValue?.className);\n }\n\n element.setAttribute(QuoteNodeAttrName, this.__themeStyleId || \"\");\n element.style.cssText = styleObjectToString(styles);\n return element;\n }\n\n // View\n override createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement(\"blockquote\");\n addClassNamesToElement(element, config.theme.quote);\n this.addThemeStylesToHTMLElement(element, config.theme);\n return element;\n }\n override updateDOM(): boolean {\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n blockquote: () => ({\n conversion: convertBlockquoteElement,\n priority: 0\n })\n };\n }\n\n static override importJSON(serializedNode: SerializedWebinyQuoteNode): WebinyQuoteNode {\n const node = $createWebinyQuoteNode(serializedNode.styleId);\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n override exportJSON(): SerializedWebinyQuoteNode {\n return {\n ...super.exportJSON(),\n tag: \"quoteblock\",\n type: \"webiny-quote\",\n styleId: this.__themeStyleId,\n version: 1\n };\n }\n\n // Mutation\n\n override insertNewAfter(): ParagraphNode {\n const newBlock = $createParagraphNode();\n const direction = this.getDirection();\n newBlock.setDirection(direction);\n this.insertAfter(newBlock);\n return newBlock;\n }\n\n override collapseAtStart(): true {\n const paragraph = $createParagraphNode();\n const children = this.getChildren();\n children.forEach(child => paragraph.append(child));\n this.replace(paragraph);\n return true;\n }\n}\n\nexport function $createWebinyQuoteNode(themeStyleId?: string, key?: NodeKey): WebinyQuoteNode {\n return new WebinyQuoteNode(themeStyleId, key);\n}\n\nexport function $isWebinyQuoteNode(node: LexicalNode | null | undefined): node is WebinyQuoteNode {\n return node instanceof WebinyQuoteNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAYA;AAEA;AAGA,SAASA,wBAAwB,GAAG;EAChC,IAAMC,IAAI,GAAGC,sBAAsB,EAAE;EACrC,OAAO;IACHD,IAAI,EAAJA;EACJ,CAAC;AACL;AAEA,IAAME,iBAAiB,GAAG,qBAAqB;AAAC,IAYnCC,eAAe;EAAA;EAAA;EAGxB,yBAAYC,YAAqB,EAAEC,GAAa,EAAE;IAAA;IAAA;IAC9C,0BAAMA,GAAG;IAAE;IAAA,yFAIF,YAAc;MACvB,OAAO,MAAKC,cAAc;IAC9B,CAAC;IALG,MAAKA,cAAc,GAAGF,YAAY,IAAI,EAAE;IAAC;EAC7C;EAAC;IAAA;IAAA,OAUD,kBAA4B;MACxB,OAAO,YAAY;IACvB;EAAC;IAAA;IAAA,OAMD,qCAA4BG,OAAoB,EAAEC,KAAwB,EAAe;MACrF,IAAIC,MAAiB,GAAG,CAAC,CAAC;MAC1B,IAAMC,eAAe,GAAGF,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEG,UAAU,GACnCH,KAAK,CAACG,UAAU,CAAC,IAAI,CAACL,cAAc,CAAC,GACrCM,SAAS;MACf,IAAI,IAAI,CAACN,cAAc,IAAII,eAAe,EAAE;QACxCD,MAAM,GAAGC,eAAe,CAACD,MAAM;QAC/B,IAAAI,6BAA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