@webiny/lexical-editor 5.37.8 → 5.38.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/commands/image.d.ts +6 -0
- package/commands/{insertFiles.js → image.js} +3 -1
- package/commands/image.js.map +1 -0
- package/commands/index.d.ts +3 -0
- package/commands/index.js +40 -0
- package/commands/index.js.map +1 -0
- package/commands/list.d.ts +7 -0
- package/commands/list.js +15 -0
- package/commands/list.js.map +1 -0
- package/commands/quote.d.ts +5 -0
- package/commands/quote.js +11 -0
- package/commands/quote.js.map +1 -0
- package/components/Editor/HeadingEditor.js +3 -1
- package/components/Editor/ParagraphEditor.js +3 -1
- package/components/Editor/RichTextEditor.d.ts +2 -2
- package/components/Editor/RichTextEditor.js +19 -12
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +3 -1
- package/components/LexicalEditorConfig/components/Node.js +3 -1
- package/components/LexicalEditorConfig/components/Plugin.js +3 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.js +3 -1
- package/components/LexicalHtmlRenderer.d.ts +2 -2
- package/components/LexicalHtmlRenderer.js +24 -17
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.d.ts +2 -2
- package/components/Toolbar/StaticToolbar.js +7 -78
- package/components/Toolbar/StaticToolbar.js.map +1 -1
- package/components/Toolbar/Toolbar.d.ts +1 -1
- package/components/Toolbar/Toolbar.js +27 -80
- package/components/Toolbar/Toolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js +10 -20
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +17 -23
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js +10 -20
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.js +20 -37
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/FontSizeAction.js +11 -27
- package/components/ToolbarActions/FontSizeAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.js +6 -4
- package/components/ToolbarActions/ImageAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.js +10 -20
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js +18 -36
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js +18 -27
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js +15 -24
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.js +27 -21
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +53 -60
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js +11 -21
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js +3 -1
- package/context/RichTextEditorContext.d.ts +2 -6
- package/context/RichTextEditorContext.js +20 -36
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.js +3 -1
- package/context/TextAlignmentActionContextProps.js +3 -1
- package/context/TypographyActionContext.d.ts +1 -1
- package/context/TypographyActionContext.js +3 -1
- package/context/TypographyActionContext.js.map +1 -1
- package/hooks/index.d.ts +7 -0
- package/hooks/index.js +84 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useCurrentElement.d.ts +7 -0
- package/hooks/useCurrentElement.js +33 -0
- package/hooks/useCurrentElement.js.map +1 -0
- package/hooks/useCurrentSelection.d.ts +12 -0
- package/hooks/useCurrentSelection.js +72 -0
- package/hooks/useCurrentSelection.js.map +1 -0
- package/hooks/useFontColorPicker.js +3 -1
- package/hooks/useIsMounted.d.ts +1 -0
- package/hooks/useIsMounted.js +20 -0
- package/hooks/useIsMounted.js.map +1 -0
- package/hooks/useList.js +22 -21
- package/hooks/useList.js.map +1 -1
- package/hooks/useQuote.d.ts +1 -1
- package/hooks/useQuote.js +9 -7
- package/hooks/useQuote.js.map +1 -1
- package/hooks/useRichTextEditor.js +3 -1
- package/hooks/useTextAlignmentAction.js +3 -1
- package/hooks/useTypographyAction.js +3 -1
- package/index.d.ts +4 -8
- package/index.js +71 -48
- package/index.js.map +1 -1
- package/package.json +16 -20
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +3 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +3 -1
- package/plugins/CodeHighlightPlugin/index.js +3 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +11 -9
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +3 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js +8 -7
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.d.ts +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.js +11 -9
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.d.ts +9 -0
- package/plugins/LexicalUpdateStatePlugin/{LexicalUpdateStatePlugin.js → UpdateStatePlugin.js} +22 -14
- package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -1
- package/plugins/LexicalUpdateStatePlugin/index.js +7 -5
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
- package/plugins/LinkPlugin/LinkPlugin.js +68 -0
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
- package/plugins/ListPLugin/ListPlugin.js +6 -5
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +7 -7
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +6 -4
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -1
- package/types.d.ts +1 -60
- package/types.js +5 -3
- package/types.js.map +1 -1
- package/ui/ContentEditable.js +3 -1
- package/ui/Divider.js +3 -1
- package/ui/DropDown.js +3 -1
- package/ui/ImageResizer.js +3 -1
- package/ui/LinkPreview.js +3 -1
- package/ui/Placeholder.js +3 -1
- package/ui/TextInput.js +3 -1
- package/ui/ToolbarActionDialog.js +3 -1
- package/utils/canUseDOM.js +3 -1
- package/utils/files.d.ts +1 -1
- package/utils/files.js +3 -1
- package/utils/files.js.map +1 -1
- package/utils/generateInitialLexicalValue.js +3 -1
- package/utils/getDOMRangeRect.js +3 -1
- package/utils/getSelectedNode.js +3 -1
- package/utils/getTransparentImage.js +3 -1
- package/utils/insertImage.d.ts +2 -0
- package/utils/{nodes/insertImage.js → insertImage.js} +6 -5
- package/utils/insertImage.js.map +1 -0
- package/utils/isHTMLElement.js +3 -1
- package/utils/isUrlLinkReference.js +3 -1
- package/utils/isValidJSON.js +3 -1
- package/utils/isValidLexicalData.js +3 -1
- package/utils/point.js +3 -1
- package/utils/rect.js +3 -1
- package/utils/sanitizeUrl.js +3 -1
- package/utils/setFloatingElemPosition.js +3 -1
- package/commands/insertFiles.d.ts +0 -14
- package/commands/insertFiles.js.map +0 -1
- package/commands/webiny-list.d.ts +0 -7
- package/commands/webiny-list.js +0 -13
- package/commands/webiny-list.js.map +0 -1
- package/commands/webiny-quote.d.ts +0 -5
- package/commands/webiny-quote.js +0 -9
- package/commands/webiny-quote.js.map +0 -1
- package/components/ImageComponent.d.ts +0 -23
- package/components/ImageComponent.js +0 -252
- package/components/ImageComponent.js.map +0 -1
- package/nodes/FontColorNode.d.ts +0 -43
- package/nodes/FontColorNode.js +0 -123
- package/nodes/FontColorNode.js.map +0 -1
- package/nodes/HeadingNode.d.ts +0 -34
- package/nodes/HeadingNode.js +0 -191
- package/nodes/HeadingNode.js.map +0 -1
- package/nodes/ImageNode.d.ts +0 -50
- package/nodes/ImageNode.js +0 -206
- package/nodes/ImageNode.js.map +0 -1
- package/nodes/ListItemNode.d.ts +0 -46
- package/nodes/ListItemNode.js +0 -447
- package/nodes/ListItemNode.js.map +0 -1
- package/nodes/ListNode/formatList.d.ts +0 -19
- package/nodes/ListNode/formatList.js +0 -447
- package/nodes/ListNode/formatList.js.map +0 -1
- package/nodes/ListNode.d.ts +0 -42
- package/nodes/ListNode.js +0 -288
- package/nodes/ListNode.js.map +0 -1
- package/nodes/ParagraphNode.d.ts +0 -32
- package/nodes/ParagraphNode.js +0 -218
- package/nodes/ParagraphNode.js.map +0 -1
- package/nodes/QuoteNode.d.ts +0 -34
- package/nodes/QuoteNode.js +0 -225
- package/nodes/QuoteNode.js.map +0 -1
- package/nodes/TypographyElementNode.d.ts +0 -42
- package/nodes/TypographyElementNode.js +0 -151
- package/nodes/TypographyElementNode.js.map +0 -1
- package/nodes/imageNode.css +0 -43
- package/nodes/link-node.d.ts +0 -19
- package/nodes/link-node.js +0 -120
- package/nodes/link-node.js.map +0 -1
- package/nodes/types.d.ts +0 -15
- package/nodes/types.js +0 -5
- package/nodes/types.js.map +0 -1
- package/nodes/webinyNodes.d.ts +0 -7
- package/nodes/webinyNodes.js +0 -60
- package/nodes/webinyNodes.js.map +0 -1
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +0 -8
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +0 -1
- package/themes/webinyLexicalTheme.css +0 -423
- package/themes/webinyLexicalTheme.d.ts +0 -9
- package/themes/webinyLexicalTheme.js +0 -90
- package/themes/webinyLexicalTheme.js.map +0 -1
- package/utils/findTypographyStyleByHtmlTag.d.ts +0 -8
- package/utils/findTypographyStyleByHtmlTag.js +0 -16
- package/utils/findTypographyStyleByHtmlTag.js.map +0 -1
- package/utils/getLexicalTextSelectionState.d.ts +0 -5
- package/utils/getLexicalTextSelectionState.js +0 -167
- package/utils/getLexicalTextSelectionState.js.map +0 -1
- package/utils/nodes/clearNodeFormating.d.ts +0 -2
- package/utils/nodes/clearNodeFormating.js +0 -28
- package/utils/nodes/clearNodeFormating.js.map +0 -1
- package/utils/nodes/formatToHeading.d.ts +0 -3
- package/utils/nodes/formatToHeading.js +0 -25
- package/utils/nodes/formatToHeading.js.map +0 -1
- package/utils/nodes/formatToParagraph.d.ts +0 -2
- package/utils/nodes/formatToParagraph.js +0 -20
- package/utils/nodes/formatToParagraph.js.map +0 -1
- package/utils/nodes/formatToQuote.d.ts +0 -2
- package/utils/nodes/formatToQuote.js +0 -25
- package/utils/nodes/formatToQuote.js.map +0 -1
- package/utils/nodes/insertImage.d.ts +0 -2
- package/utils/nodes/insertImage.js.map +0 -1
- package/utils/nodes/listNode.d.ts +0 -11
- package/utils/nodes/listNode.js +0 -107
- package/utils/nodes/listNode.js.map +0 -1
- package/utils/styleObjectToString.d.ts +0 -2
- package/utils/styleObjectToString.js +0 -22
- package/utils/styleObjectToString.js.map +0 -1
- package/utils/toTypographyEmotionMap.d.ts +0 -3
- package/utils/toTypographyEmotionMap.js +0 -41
- package/utils/toTypographyEmotionMap.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["require","webinyEditorTheme","styles","undefined","emotionMap","characterLimit","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","hashtag","heading","h1","h2","h3","h4","h5","h6","link","list","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ul","ltr","mark","markOverlap","paragraph","quote","rtl","text","bold","italic","strikethrough","subscript","superscript","underline","underlineStrikethrough","fontColorText","image","indent","inlineImage","exports"],"sources":["webinyLexicalTheme.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\n\nimport \"./webinyLexicalTheme.css\";\nimport { ThemeEmotionMap } from \"~/types\";\n\nexport type WebinyTheme = {\n styles?: Record<string, any>;\n emotionMap?: ThemeEmotionMap;\n};\n\nexport type WebinyEditorTheme = WebinyTheme & EditorThemeClasses;\n\nexport const webinyEditorTheme: WebinyEditorTheme = {\n styles: undefined,\n emotionMap: undefined,\n characterLimit: \"WebinyLexical__characterLimit\",\n code: \"WebinyLexical__code\",\n codeHighlight: {\n atrule: \"WebinyLexical__tokenAttr\",\n attr: \"WebinyLexical__tokenAttr\",\n boolean: \"WebinyLexical__tokenProperty\",\n builtin: \"WebinyLexical__tokenSelector\",\n cdata: \"WebinyLexical__tokenComment\",\n char: \"WebinyLexical__tokenSelector\",\n class: \"WebinyLexical__tokenFunction\",\n \"class-name\": \"WebinyLexical__tokenFunction\",\n comment: \"WebinyLexical__tokenComment\",\n constant: \"WebinyLexical__tokenProperty\",\n deleted: \"WebinyLexical__tokenProperty\",\n doctype: \"WebinyLexical__tokenComment\",\n entity: \"WebinyLexical__tokenOperator\",\n function: \"WebinyLexical__tokenFunction\",\n important: \"WebinyLexical__tokenVariable\",\n inserted: \"WebinyLexical__tokenSelector\",\n keyword: \"WebinyLexical__tokenAttr\",\n namespace: \"WebinyLexical__tokenVariable\",\n number: \"WebinyLexical__tokenProperty\",\n operator: \"WebinyLexical__tokenOperator\",\n prolog: \"WebinyLexical__tokenComment\",\n property: \"WebinyLexical__tokenProperty\",\n punctuation: \"WebinyLexical__tokenPunctuation\",\n regex: \"WebinyLexical__tokenVariable\",\n selector: \"WebinyLexical__tokenSelector\",\n string: \"WebinyLexical__tokenSelector\",\n symbol: \"WebinyLexical__tokenProperty\",\n tag: \"WebinyLexical__tokenProperty\",\n url: \"WebinyLexical__tokenOperator\",\n variable: \"WebinyLexical__tokenVariable\"\n },\n embedBlock: {\n base: \"WebinyLexical__embedBlock\",\n focus: \"WebinyLexical__embedBlockFocus\"\n },\n hashtag: \"WebinyLexical__hashtag\",\n heading: {\n h1: \"WebinyLexical__h1\",\n h2: \"WebinyLexical__h2\",\n h3: \"WebinyLexical__h3\",\n h4: \"WebinyLexical__h4\",\n h5: \"WebinyLexical__h5\",\n h6: \"WebinyLexical__h6\"\n },\n link: \"WebinyLexical__link\",\n list: {\n listitem: \"WebinyLexical__listItem\",\n listitemChecked: \"WebinyLexical__listItemChecked\",\n listitemUnchecked: \"WebinyLexical__listItemUnchecked\",\n nested: {\n listitem: \"WebinyLexical__nestedListItem\"\n },\n olDepth: [\n \"WebinyLexical__ol1\",\n \"WebinyLexical__ol2\",\n \"WebinyLexical__ol3\",\n \"WebinyLexical__ol4\",\n \"WebinyLexical__ol5\"\n ],\n ul: \"WebinyLexical__ul\"\n },\n ltr: \"WebinyLexical__ltr\",\n mark: \"WebinyLexical__mark\",\n markOverlap: \"WebinyLexical__markOverlap\",\n paragraph: \"WebinyLexical__paragraph\",\n quote: \"WebinyLexical__quote\",\n rtl: \"WebinyLexical__rtl\",\n text: {\n bold: \"WebinyLexical__textBold\",\n code: \"WebinyLexical__textCode\",\n italic: \"WebinyLexical__textItalic\",\n strikethrough: \"WebinyLexical__textStrikethrough\",\n subscript: \"WebinyLexical__textSubscript\",\n superscript: \"WebinyLexical__textSuperscript\",\n underline: \"WebinyLexical__textUnderline\",\n underlineStrikethrough: \"WebinyLexical__textUnderlineStrikethrough\"\n },\n fontColorText: \"WebinyLexical__fontColorText\",\n image: \"editor-image\",\n indent: \"PlaygroundEditorTheme__indent\",\n inlineImage: \"inline-editor-image\"\n};\n"],"mappings":";;;;;;AAEAA,OAAA;AAUO,IAAMC,iBAAoC,GAAG;EAChDC,MAAM,EAAEC,SAAS;EACjBC,UAAU,EAAED,SAAS;EACrBE,cAAc,EAAE,+BAA+B;EAC/CC,IAAI,EAAE,qBAAqB;EAC3BC,aAAa,EAAE;IACXC,MAAM,EAAE,0BAA0B;IAClCC,IAAI,EAAE,0BAA0B;IAChCC,OAAO,EAAE,8BA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;IACDI,OAAO,EAAE,CACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,CACvB;IACDC,EAAE,EAAE;EACR,CAAC;EACDC,GAAG,EAAE,oBAAoB;EACzBC,IAAI,EAAE,qBAAqB;EAC3BC,WAAW,EAAE,4BAA4B;EACzCC,SAAS,EAAE,0BAA0B;EACrCC,KAAK,EAAE,sBAAsB;EAC7BC,GAAG,EAAE,oBAAoB;EACzBC,IAAI,EAAE;IACFC,IAAI,EAAE,yBAAyB;IAC/BzD,IAAI,EAAE,yBAAyB;IAC/B0D,MAAM,EAAE,2BAA2B;IACnCC,aAAa,EAAE,kCAAkC;IACjDC,SAAS,EAAE,8BAA8B;IACzCC,WAAW,EAAE,gCAAgC;IAC7CC,SAAS,EAAE,8BAA8B;IACzCC,sBAAsB,EAAE;EAC5B,CAAC;EACDC,aAAa,EAAE,8BAA8B;EAC7CC,KAAK,EAAE,cAAc;EACrBC,MAAM,EAAE,+BAA+B;EACvCC,WAAW,EAAE;AACjB,CAAC;AAACC,OAAA,CAAAzE,iBAAA,GAAAA,iBAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ThemeEmotionMap } from "../types";
|
|
2
|
-
export declare const findTypographyStyleByHtmlTag: (htmlTag: string, themeEmotionMap: ThemeEmotionMap) => {
|
|
3
|
-
id: string;
|
|
4
|
-
tag: import("../types").TypographyHTMLTag;
|
|
5
|
-
name: string;
|
|
6
|
-
styles: Record<string, any>;
|
|
7
|
-
className: string;
|
|
8
|
-
} | undefined;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.findTypographyStyleByHtmlTag = void 0;
|
|
7
|
-
var findTypographyStyleByHtmlTag = function findTypographyStyleByHtmlTag(htmlTag, themeEmotionMap) {
|
|
8
|
-
for (var styleId in themeEmotionMap) {
|
|
9
|
-
var style = themeEmotionMap[styleId];
|
|
10
|
-
if (style.tag === htmlTag) {
|
|
11
|
-
return style;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return undefined;
|
|
15
|
-
};
|
|
16
|
-
exports.findTypographyStyleByHtmlTag = findTypographyStyleByHtmlTag;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["findTypographyStyleByHtmlTag","htmlTag","themeEmotionMap","styleId","style","tag","undefined","exports"],"sources":["findTypographyStyleByHtmlTag.ts"],"sourcesContent":["import { ThemeEmotionMap } from \"~/types\";\n\nexport const findTypographyStyleByHtmlTag = (htmlTag: string, themeEmotionMap: ThemeEmotionMap) => {\n for (const styleId in themeEmotionMap) {\n const style = themeEmotionMap[styleId];\n if (style.tag === htmlTag) {\n return style;\n }\n }\n return undefined;\n};\n"],"mappings":";;;;;;AAEO,IAAMA,4BAA4B,GAAG,SAA/BA,4BAA4BA,CAAIC,OAAe,EAAEC,eAAgC,EAAK;EAC/F,KAAK,IAAMC,OAAO,IAAID,eAAe,EAAE;IACnC,IAAME,KAAK,GAAGF,eAAe,CAACC,OAAO,CAAC;IACtC,IAAIC,KAAK,CAACC,GAAG,KAAKJ,OAAO,EAAE;MACvB,OAAOG,KAAK;IAChB;EACJ;EACA,OAAOE,SAAS;AACpB,CAAC;AAACC,OAAA,CAAAP,4BAAA,GAAAA,4BAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { TextFormatting, TextBlockSelection, ToolbarState } from "../types";
|
|
2
|
-
import { ElementNode, LexicalEditor, LexicalNode, RangeSelection, TextNode } from "lexical";
|
|
3
|
-
export declare const getSelectionTextFormat: (selection: RangeSelection | undefined) => TextFormatting;
|
|
4
|
-
export declare const getToolbarState: (selection: RangeSelection, node: LexicalNode, parent: LexicalNode | null, element: LexicalNode | null, anchorNode: ElementNode | TextNode) => ToolbarState;
|
|
5
|
-
export declare const getLexicalTextSelectionState: (activeEditor: LexicalEditor, selection: RangeSelection) => TextBlockSelection | null;
|
|
@@ -1,167 +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.getToolbarState = exports.getSelectionTextFormat = exports.getLexicalTextSelectionState = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _lexical = require("lexical");
|
|
10
|
-
var _utils = require("@lexical/utils");
|
|
11
|
-
var _getSelectedNode = require("./getSelectedNode");
|
|
12
|
-
var _link = require("@lexical/link");
|
|
13
|
-
var _ListNode = require("../nodes/ListNode");
|
|
14
|
-
var _richText = require("@lexical/rich-text");
|
|
15
|
-
var _TypographyElementNode = require("../nodes/TypographyElementNode");
|
|
16
|
-
var _FontColorNode = require("../nodes/FontColorNode");
|
|
17
|
-
var _ParagraphNode = require("../nodes/ParagraphNode");
|
|
18
|
-
var _HeadingNode = require("../nodes/HeadingNode");
|
|
19
|
-
var _QuoteNode = require("../nodes/QuoteNode");
|
|
20
|
-
var _selection = require("@lexical/selection");
|
|
21
|
-
var _linkNode = require("../nodes/link-node");
|
|
22
|
-
var getSelectionTextFormat = function getSelectionTextFormat(selection) {
|
|
23
|
-
return !(0, _lexical.$isRangeSelection)(selection) ? {
|
|
24
|
-
italic: false,
|
|
25
|
-
bold: false,
|
|
26
|
-
underline: false,
|
|
27
|
-
code: false
|
|
28
|
-
} : {
|
|
29
|
-
bold: selection.hasFormat("bold"),
|
|
30
|
-
italic: selection.hasFormat("italic"),
|
|
31
|
-
underline: selection.hasFormat("underline"),
|
|
32
|
-
code: selection.hasFormat("code")
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
exports.getSelectionTextFormat = getSelectionTextFormat;
|
|
36
|
-
var getDefaultToolbarState = function getDefaultToolbarState() {
|
|
37
|
-
return {
|
|
38
|
-
bold: false,
|
|
39
|
-
italic: false,
|
|
40
|
-
underline: false,
|
|
41
|
-
code: false,
|
|
42
|
-
isRTL: false,
|
|
43
|
-
link: {
|
|
44
|
-
isSelected: false
|
|
45
|
-
},
|
|
46
|
-
list: {
|
|
47
|
-
isSelected: false
|
|
48
|
-
},
|
|
49
|
-
typography: {
|
|
50
|
-
isSelected: false
|
|
51
|
-
},
|
|
52
|
-
fontColor: {
|
|
53
|
-
isSelected: false
|
|
54
|
-
},
|
|
55
|
-
quote: {
|
|
56
|
-
isSelected: false
|
|
57
|
-
},
|
|
58
|
-
paragraph: {
|
|
59
|
-
isSelected: false
|
|
60
|
-
},
|
|
61
|
-
heading: {
|
|
62
|
-
isSelected: false
|
|
63
|
-
},
|
|
64
|
-
textType: undefined
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
var getToolbarState = function getToolbarState(selection, node, parent, element, anchorNode) {
|
|
68
|
-
var textFormat = getSelectionTextFormat(selection);
|
|
69
|
-
var state = getDefaultToolbarState();
|
|
70
|
-
state = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
|
|
71
|
-
bold: textFormat.bold,
|
|
72
|
-
italic: textFormat.italic,
|
|
73
|
-
underline: textFormat.underline,
|
|
74
|
-
code: textFormat.code
|
|
75
|
-
});
|
|
76
|
-
state.isRTL = (0, _selection.$isParentElementRTL)(selection);
|
|
77
|
-
|
|
78
|
-
// link
|
|
79
|
-
state.link.isSelected = (0, _link.$isLinkNode)(parent) || (0, _link.$isLinkNode)(node) ||
|
|
80
|
-
// custom link node
|
|
81
|
-
(0, _linkNode.$isLinkNode)(parent) || (0, _linkNode.$isLinkNode)(node);
|
|
82
|
-
if (state.link.isSelected) {
|
|
83
|
-
state.textType = "link";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// font color
|
|
87
|
-
if ((0, _FontColorNode.$isFontColorNode)(node)) {
|
|
88
|
-
state.fontColor.isSelected = true;
|
|
89
|
-
}
|
|
90
|
-
if ((0, _ListNode.$isListNode)(element)) {
|
|
91
|
-
var parentList = (0, _utils.$getNearestNodeOfType)(anchorNode, _ListNode.ListNode);
|
|
92
|
-
var type = parentList ? parentList.getListType() : element.getListType();
|
|
93
|
-
state.list.isSelected = true;
|
|
94
|
-
state.textType = type;
|
|
95
|
-
}
|
|
96
|
-
if ((0, _richText.$isHeadingNode)(element)) {
|
|
97
|
-
state.textType = "heading";
|
|
98
|
-
}
|
|
99
|
-
if ((0, _HeadingNode.$isHeadingNode)(element)) {
|
|
100
|
-
state.textType = "heading";
|
|
101
|
-
state.heading.isSelected = true;
|
|
102
|
-
}
|
|
103
|
-
if ((0, _lexical.$isParagraphNode)(element)) {
|
|
104
|
-
state.textType = "paragraph";
|
|
105
|
-
}
|
|
106
|
-
if ((0, _ParagraphNode.$isParagraphNode)(element)) {
|
|
107
|
-
state.textType = "paragraph";
|
|
108
|
-
state.paragraph.isSelected = true;
|
|
109
|
-
}
|
|
110
|
-
if ((0, _TypographyElementNode.$isTypographyElementNode)(element)) {
|
|
111
|
-
state.typography.isSelected = true;
|
|
112
|
-
var value = element === null || element === void 0 ? void 0 : element.getTypographyValue();
|
|
113
|
-
if (value.tag.includes("h")) {
|
|
114
|
-
state.textType = "heading";
|
|
115
|
-
}
|
|
116
|
-
if (value.tag.includes("p")) {
|
|
117
|
-
state.textType = "paragraph";
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if ((0, _TypographyElementNode.$isTypographyElementNode)(element)) {
|
|
121
|
-
state.fontColor.isSelected = true;
|
|
122
|
-
}
|
|
123
|
-
if ((0, _QuoteNode.$isQuoteNode)(element)) {
|
|
124
|
-
state.textType = "quoteblock";
|
|
125
|
-
state.quote.isSelected = true;
|
|
126
|
-
}
|
|
127
|
-
return state;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/*
|
|
131
|
-
* @desc Get selection data and provide processed toolbar state and data about the text, element and parent nodes.
|
|
132
|
-
*/
|
|
133
|
-
exports.getToolbarState = getToolbarState;
|
|
134
|
-
var getLexicalTextSelectionState = function getLexicalTextSelectionState(activeEditor, selection) {
|
|
135
|
-
if ((0, _lexical.$isRangeSelection)(selection)) {
|
|
136
|
-
var anchorNode = selection.anchor.getNode();
|
|
137
|
-
var element = anchorNode.getKey() === "root" ? anchorNode : (0, _utils.$findMatchingParent)(anchorNode, function (e) {
|
|
138
|
-
var parent = e.getParent();
|
|
139
|
-
return parent !== null && (0, _lexical.$isRootOrShadowRoot)(parent);
|
|
140
|
-
});
|
|
141
|
-
if (element === null) {
|
|
142
|
-
element = anchorNode.getTopLevelElementOrThrow();
|
|
143
|
-
}
|
|
144
|
-
var elementKey = element.getKey();
|
|
145
|
-
var elementDOM = activeEditor.getElementByKey(elementKey);
|
|
146
|
-
|
|
147
|
-
// Update links
|
|
148
|
-
var node = (0, _getSelectedNode.getSelectedNode)(selection);
|
|
149
|
-
var parent = node.getParent();
|
|
150
|
-
var isElementDom = elementDOM !== null;
|
|
151
|
-
var selectedText = selection.getTextContent();
|
|
152
|
-
return {
|
|
153
|
-
// node/element data from selection
|
|
154
|
-
elementKey: elementKey,
|
|
155
|
-
element: element,
|
|
156
|
-
parent: parent,
|
|
157
|
-
node: node,
|
|
158
|
-
anchorNode: anchorNode,
|
|
159
|
-
selection: selection,
|
|
160
|
-
isElementDom: isElementDom,
|
|
161
|
-
selectedText: selectedText,
|
|
162
|
-
state: getToolbarState(selection, node, parent, element, anchorNode)
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
};
|
|
167
|
-
exports.getLexicalTextSelectionState = getLexicalTextSelectionState;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_utils","_getSelectedNode","_link","_ListNode","_richText","_TypographyElementNode","_FontColorNode","_ParagraphNode","_HeadingNode","_QuoteNode","_selection","_linkNode","getSelectionTextFormat","selection","$isRangeSelection","italic","bold","underline","code","hasFormat","exports","getDefaultToolbarState","isRTL","link","isSelected","list","typography","fontColor","quote","paragraph","heading","textType","undefined","getToolbarState","node","parent","element","anchorNode","textFormat","state","_objectSpread2","default","$isParentElementRTL","$isBaseLinkNode","$isLinkNode","$isFontColorNode","$isListNode","parentList","$getNearestNodeOfType","ListNode","type","getListType","$isBaseHeadingNode","$isHeadingNode","$isBaseParagraphNode","$isParagraphNode","$isTypographyElementNode","value","getTypographyValue","tag","includes","$isQuoteNode","getLexicalTextSelectionState","activeEditor","anchor","getNode","getKey","$findMatchingParent","e","getParent","$isRootOrShadowRoot","getTopLevelElementOrThrow","elementKey","elementDOM","getElementByKey","getSelectedNode","isElementDom","selectedText","getTextContent"],"sources":["getLexicalTextSelectionState.ts"],"sourcesContent":["import { TextFormatting, TextBlockSelection, ToolbarState, TypographyValue } from \"~/types\";\nimport {\n $isParagraphNode as $isBaseParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n ElementNode,\n LexicalEditor,\n LexicalNode,\n RangeSelection,\n TextNode\n} from \"lexical\";\nimport { $findMatchingParent, $getNearestNodeOfType } from \"@lexical/utils\";\nimport { getSelectedNode } from \"~/utils/getSelectedNode\";\nimport { $isLinkNode as $isBaseLinkNode } from \"@lexical/link\";\nimport { $isListNode, ListNode } from \"~/nodes/ListNode\";\nimport { $isHeadingNode as $isBaseHeadingNode } from \"@lexical/rich-text\";\nimport { $isTypographyElementNode } from \"~/nodes/TypographyElementNode\";\nimport { $isFontColorNode } from \"~/nodes/FontColorNode\";\nimport { $isParagraphNode } from \"~/nodes/ParagraphNode\";\nimport { $isHeadingNode } from \"~/nodes/HeadingNode\";\nimport { $isQuoteNode } from \"~/nodes/QuoteNode\";\nimport { $isParentElementRTL } from \"@lexical/selection\";\nimport { $isLinkNode } from \"~/nodes/link-node\";\n\nexport const getSelectionTextFormat = (selection: RangeSelection | undefined): TextFormatting => {\n return !$isRangeSelection(selection)\n ? {\n italic: false,\n bold: false,\n underline: false,\n code: false\n }\n : {\n bold: selection.hasFormat(\"bold\"),\n italic: selection.hasFormat(\"italic\"),\n underline: selection.hasFormat(\"underline\"),\n code: selection.hasFormat(\"code\")\n };\n};\n\nconst getDefaultToolbarState = (): ToolbarState => {\n return {\n bold: false,\n italic: false,\n underline: false,\n code: false,\n isRTL: false,\n link: { isSelected: false },\n list: { isSelected: false },\n typography: { isSelected: false },\n fontColor: { isSelected: false },\n quote: { isSelected: false },\n paragraph: { isSelected: false },\n heading: { isSelected: false },\n textType: undefined\n };\n};\n\nexport const getToolbarState = (\n selection: RangeSelection,\n node: LexicalNode,\n parent: LexicalNode | null,\n element: LexicalNode | null,\n anchorNode: ElementNode | TextNode\n): ToolbarState => {\n const textFormat = getSelectionTextFormat(selection);\n let state: ToolbarState = getDefaultToolbarState();\n state = {\n ...state,\n bold: textFormat.bold,\n italic: textFormat.italic,\n underline: textFormat.underline,\n code: textFormat.code\n };\n\n state.isRTL = $isParentElementRTL(selection);\n\n // link\n state.link.isSelected =\n $isBaseLinkNode(parent) ||\n $isBaseLinkNode(node) ||\n // custom link node\n $isLinkNode(parent) ||\n $isLinkNode(node);\n if (state.link.isSelected) {\n state.textType = \"link\";\n }\n\n // font color\n if ($isFontColorNode(node)) {\n state.fontColor.isSelected = true;\n }\n\n if ($isListNode(element)) {\n const parentList = $getNearestNodeOfType<ListNode>(anchorNode, ListNode);\n const type = parentList ? parentList.getListType() : element.getListType();\n state.list.isSelected = true;\n state.textType = type;\n }\n\n if ($isBaseHeadingNode(element)) {\n state.textType = \"heading\";\n }\n\n if ($isHeadingNode(element)) {\n state.textType = \"heading\";\n state.heading.isSelected = true;\n }\n\n if ($isBaseParagraphNode(element)) {\n state.textType = \"paragraph\";\n }\n\n if ($isParagraphNode(element)) {\n state.textType = \"paragraph\";\n state.paragraph.isSelected = true;\n }\n\n if ($isTypographyElementNode(element)) {\n state.typography.isSelected = true;\n const value = element?.getTypographyValue() as TypographyValue;\n if (value.tag.includes(\"h\")) {\n state.textType = \"heading\";\n }\n if (value.tag.includes(\"p\")) {\n state.textType = \"paragraph\";\n }\n }\n\n if ($isTypographyElementNode(element)) {\n state.fontColor.isSelected = true;\n }\n\n if ($isQuoteNode(element)) {\n state.textType = \"quoteblock\";\n state.quote.isSelected = true;\n }\n\n return state;\n};\n\n/*\n * @desc Get selection data and provide processed toolbar state and data about the text, element and parent nodes.\n */\nexport const getLexicalTextSelectionState = (\n activeEditor: LexicalEditor,\n selection: RangeSelection\n): TextBlockSelection | null => {\n if ($isRangeSelection(selection)) {\n const anchorNode = selection.anchor.getNode();\n let element =\n anchorNode.getKey() === \"root\"\n ? anchorNode\n : $findMatchingParent(anchorNode, e => {\n const parent = e.getParent();\n return parent !== null && $isRootOrShadowRoot(parent);\n });\n\n if (element === null) {\n element = anchorNode.getTopLevelElementOrThrow();\n }\n\n const elementKey = element.getKey();\n const elementDOM = activeEditor.getElementByKey(elementKey);\n\n // Update links\n const node = getSelectedNode(selection);\n const parent = node.getParent();\n const isElementDom = elementDOM !== null;\n const selectedText = selection.getTextContent();\n\n return {\n // node/element data from selection\n elementKey,\n element,\n parent,\n node,\n anchorNode,\n selection,\n isElementDom,\n selectedText,\n state: getToolbarState(selection, node, parent, element, anchorNode)\n };\n }\n return null;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAUA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,cAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAZ,OAAA;AAEO,IAAMa,sBAAsB,GAAG,SAAzBA,sBA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AAEC,UAAU;IACvE,CAAC;EACL;EACA,OAAO,IAAI;AACf,CAAC;AAACjB,OAAA,CAAA0C,4BAAA,GAAAA,4BAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.clearNodeFormatting = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var _selection = require("@lexical/selection");
|
|
9
|
-
var _utils = require("@lexical/utils");
|
|
10
|
-
var _LexicalDecoratorBlockNode = require("@lexical/react/LexicalDecoratorBlockNode");
|
|
11
|
-
var clearNodeFormatting = function clearNodeFormatting(activeEditor, selection) {
|
|
12
|
-
activeEditor.update(function () {
|
|
13
|
-
if ((0, _lexical.$isRangeSelection)(selection)) {
|
|
14
|
-
(0, _selection.$selectAll)(selection);
|
|
15
|
-
selection.getNodes().forEach(function (node) {
|
|
16
|
-
if ((0, _lexical.$isTextNode)(node)) {
|
|
17
|
-
node.setFormat(0);
|
|
18
|
-
node.setStyle("");
|
|
19
|
-
(0, _utils.$getNearestBlockElementAncestorOrThrow)(node).setFormat("");
|
|
20
|
-
}
|
|
21
|
-
if ((0, _LexicalDecoratorBlockNode.$isDecoratorBlockNode)(node)) {
|
|
22
|
-
node.setFormat("");
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
exports.clearNodeFormatting = clearNodeFormatting;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_selection","_utils","_LexicalDecoratorBlockNode","clearNodeFormatting","activeEditor","selection","update","$isRangeSelection","$selectAll","getNodes","forEach","node","$isTextNode","setFormat","setStyle","$getNearestBlockElementAncestorOrThrow","$isDecoratorBlockNode","exports"],"sources":["clearNodeFormating.ts"],"sourcesContent":["import {\n $isRangeSelection,\n $isTextNode,\n GridSelection,\n LexicalEditor,\n NodeSelection,\n RangeSelection\n} from \"lexical\";\nimport { $selectAll } from \"@lexical/selection\";\nimport { $getNearestBlockElementAncestorOrThrow } from \"@lexical/utils\";\nimport { $isDecoratorBlockNode } from \"@lexical/react/LexicalDecoratorBlockNode\";\n\nexport const clearNodeFormatting = (\n activeEditor: LexicalEditor,\n selection: RangeSelection | NodeSelection | GridSelection | null\n) => {\n activeEditor.update(() => {\n if ($isRangeSelection(selection)) {\n $selectAll(selection);\n selection.getNodes().forEach(node => {\n if ($isTextNode(node)) {\n node.setFormat(0);\n node.setStyle(\"\");\n $getNearestBlockElementAncestorOrThrow(node).setFormat(\"\");\n }\n if ($isDecoratorBlockNode(node)) {\n node.setFormat(\"\");\n }\n });\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AAEO,IAAMI,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAC5BC,YAA2B,EAC3BC,SAAgE,EAC/D;EACDD,YAAY,CAACE,MAAM,CAAC,YAAM;IACtB,IAAI,IAAAC,0BAAiB,EAACF,SAAS,CAAC,EAAE;MAC9B,IAAAG,qBAAU,EAACH,SAAS,CAAC;MACrBA,SAAS,CAACI,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,UAAAC,IAAI,EAAI;QACjC,IAAI,IAAAC,oBAAW,EAACD,IAAI,CAAC,EAAE;UACnBA,IAAI,CAACE,SAAS,CAAC,CAAC,CAAC;UACjBF,IAAI,CAACG,QAAQ,CAAC,EAAE,CAAC;UACjB,IAAAC,6CAAsC,EAACJ,IAAI,CAAC,CAACE,SAAS,CAAC,EAAE,CAAC;QAC9D;QACA,IAAI,IAAAG,gDAAqB,EAACL,IAAI,CAAC,EAAE;UAC7BA,IAAI,CAACE,SAAS,CAAC,EAAE,CAAC;QACtB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAd,mBAAA,GAAAA,mBAAA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatToHeading = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var _selection = require("@lexical/selection");
|
|
9
|
-
var _HeadingNode = require("../../nodes/HeadingNode");
|
|
10
|
-
/*
|
|
11
|
-
* Will change the selected HTML tag to specified heading or h1-h6.
|
|
12
|
-
* For example if the selection is p with content inside after formatting the root tag
|
|
13
|
-
* will be h1 with heading 1 theme style and the same content inside.
|
|
14
|
-
* */
|
|
15
|
-
var formatToHeading = function formatToHeading(editor, tag, typographyStyleId) {
|
|
16
|
-
editor.update(function () {
|
|
17
|
-
var selection = (0, _lexical.$getSelection)();
|
|
18
|
-
if ((0, _lexical.$isRangeSelection)(selection) || (0, _lexical.DEPRECATED_$isGridSelection)(selection)) {
|
|
19
|
-
(0, _selection.$setBlocksType)(selection, function () {
|
|
20
|
-
return (0, _HeadingNode.$createHeadingNode)(tag, typographyStyleId);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
exports.formatToHeading = formatToHeading;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_selection","_HeadingNode","formatToHeading","editor","tag","typographyStyleId","update","selection","$getSelection","$isRangeSelection","DEPRECATED_$isGridSelection","$setBlocksType","$createHeadingNode","exports"],"sources":["formatToHeading.ts"],"sourcesContent":["import {\n $getSelection,\n $isRangeSelection,\n DEPRECATED_$isGridSelection,\n LexicalEditor\n} from \"lexical\";\nimport { $setBlocksType } from \"@lexical/selection\";\nimport { $createHeadingNode } from \"~/nodes/HeadingNode\";\nimport { HeadingTagType } from \"@lexical/rich-text\";\n\n/*\n * Will change the selected HTML tag to specified heading or h1-h6.\n * For example if the selection is p with content inside after formatting the root tag\n * will be h1 with heading 1 theme style and the same content inside.\n * */\nexport const formatToHeading = (\n editor: LexicalEditor,\n tag: HeadingTagType,\n typographyStyleId?: string\n) => {\n editor.update(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {\n $setBlocksType(selection, () => $createHeadingNode(tag, typographyStyleId));\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAGA;AACA;AACA;AACA;AACA;AACO,IAAMG,eAAe,GAAG,SAAlBA,eAAeA,CACxBC,MAAqB,EACrBC,GAAmB,EACnBC,iBAA0B,EACzB;EACDF,MAAM,CAACG,MAAM,CAAC,YAAM;IAChB,IAAMC,SAAS,GAAG,IAAAC,sBAAa,EAAC,CAAC;IACjC,IAAI,IAAAC,0BAAiB,EAACF,SAAS,CAAC,IAAI,IAAAG,oCAA2B,EAACH,SAAS,CAAC,EAAE;MACxE,IAAAI,yBAAc,EAACJ,SAAS,EAAE;QAAA,OAAM,IAAAK,+BAAkB,EAACR,GAAG,EAAEC,iBAAiB,CAAC;MAAA,EAAC;IAC/E;EACJ,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAX,eAAA,GAAAA,eAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatToParagraph = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var _ParagraphNode = require("../../nodes/ParagraphNode");
|
|
9
|
-
var _selection = require("@lexical/selection");
|
|
10
|
-
var formatToParagraph = function formatToParagraph(editor, typographyStyleId) {
|
|
11
|
-
editor.update(function () {
|
|
12
|
-
var selection = (0, _lexical.$getSelection)();
|
|
13
|
-
if ((0, _lexical.$isRangeSelection)(selection) || (0, _lexical.DEPRECATED_$isGridSelection)(selection)) {
|
|
14
|
-
(0, _selection.$setBlocksType)(selection, function () {
|
|
15
|
-
return (0, _ParagraphNode.$createParagraphNode)(typographyStyleId);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
exports.formatToParagraph = formatToParagraph;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_ParagraphNode","_selection","formatToParagraph","editor","typographyStyleId","update","selection","$getSelection","$isRangeSelection","DEPRECATED_$isGridSelection","$setBlocksType","$createParagraphNode","exports"],"sources":["formatToParagraph.ts"],"sourcesContent":["import {\n $getSelection,\n $isRangeSelection,\n DEPRECATED_$isGridSelection,\n LexicalEditor\n} from \"lexical\";\nimport { $createParagraphNode } from \"~/nodes/ParagraphNode\";\nimport { $setBlocksType } from \"@lexical/selection\";\n\nexport const formatToParagraph = (editor: LexicalEditor, typographyStyleId?: string) => {\n editor.update(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {\n $setBlocksType(selection, () => $createParagraphNode(typographyStyleId));\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEO,IAAMG,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,MAAqB,EAAEC,iBAA0B,EAAK;EACpFD,MAAM,CAACE,MAAM,CAAC,YAAM;IAChB,IAAMC,SAAS,GAAG,IAAAC,sBAAa,EAAC,CAAC;IACjC,IAAI,IAAAC,0BAAiB,EAACF,SAAS,CAAC,IAAI,IAAAG,oCAA2B,EAACH,SAAS,CAAC,EAAE;MACxE,IAAAI,yBAAc,EAACJ,SAAS,EAAE;QAAA,OAAM,IAAAK,mCAAoB,EAACP,iBAAiB,CAAC;MAAA,EAAC;IAC5E;EACJ,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAV,iBAAA,GAAAA,iBAAA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatToQuote = void 0;
|
|
7
|
-
var _lexical = require("lexical");
|
|
8
|
-
var _selection = require("@lexical/selection");
|
|
9
|
-
var _QuoteNode = require("../../nodes/QuoteNode");
|
|
10
|
-
/*
|
|
11
|
-
* Will change the selected root HTML tag to specified quoteblock tag.
|
|
12
|
-
* For example if the selection is paragraph <p> with content inside after formatting the root tag
|
|
13
|
-
* will be quoteblock with same content inside.
|
|
14
|
-
* */
|
|
15
|
-
var formatToQuote = function formatToQuote(editor, themeStyleId) {
|
|
16
|
-
editor.update(function () {
|
|
17
|
-
var selection = (0, _lexical.$getSelection)();
|
|
18
|
-
if ((0, _lexical.$isRangeSelection)(selection) || (0, _lexical.DEPRECATED_$isGridSelection)(selection)) {
|
|
19
|
-
(0, _selection.$setBlocksType)(selection, function () {
|
|
20
|
-
return (0, _QuoteNode.$createQuoteNode)(themeStyleId);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
exports.formatToQuote = formatToQuote;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_selection","_QuoteNode","formatToQuote","editor","themeStyleId","update","selection","$getSelection","$isRangeSelection","DEPRECATED_$isGridSelection","$setBlocksType","$createQuoteNode","exports"],"sources":["formatToQuote.ts"],"sourcesContent":["import {\n $getSelection,\n $isRangeSelection,\n DEPRECATED_$isGridSelection,\n LexicalEditor\n} from \"lexical\";\nimport { $setBlocksType } from \"@lexical/selection\";\nimport { $createQuoteNode } from \"~/nodes/QuoteNode\";\n\n/*\n * Will change the selected root HTML tag to specified quoteblock tag.\n * For example if the selection is paragraph <p> with content inside after formatting the root tag\n * will be quoteblock with same content inside.\n * */\nexport const formatToQuote = (editor: LexicalEditor, themeStyleId?: string) => {\n editor.update(() => {\n const selection = $getSelection();\n if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {\n $setBlocksType(selection, () => $createQuoteNode(themeStyleId));\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMG,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,MAAqB,EAAEC,YAAqB,EAAK;EAC3ED,MAAM,CAACE,MAAM,CAAC,YAAM;IAChB,IAAMC,SAAS,GAAG,IAAAC,sBAAa,EAAC,CAAC;IACjC,IAAI,IAAAC,0BAAiB,EAACF,SAAS,CAAC,IAAI,IAAAG,oCAA2B,EAACH,SAAS,CAAC,EAAE;MACxE,IAAAI,yBAAc,EAACJ,SAAS,EAAE;QAAA,OAAM,IAAAK,2BAAgB,EAACP,YAAY,CAAC;MAAA,EAAC;IACnE;EACJ,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAV,aAAA,GAAAA,aAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_ParagraphNode","_ImageNode","_utils","insertImage","payload","imageNode","$createImageNode","$insertNodes","$isRootOrShadowRoot","getParentOrThrow","$wrapNodeInElement","$createParagraphNode","selectEnd","exports"],"sources":["insertImage.ts"],"sourcesContent":["import { $insertNodes, $isRootOrShadowRoot } from \"lexical\";\nimport { $createParagraphNode } from \"~/nodes/ParagraphNode\";\nimport { $createImageNode } from \"~/nodes/ImageNode\";\nimport { $wrapNodeInElement } from \"@lexical/utils\";\nimport { InsertImagePayload } from \"~/plugins/ImagesPlugin/ImagesPlugin\";\n\n/*\n * Insert image into editor.\n */\nexport const insertImage = (payload: InsertImagePayload): boolean => {\n const imageNode = $createImageNode(payload);\n $insertNodes([imageNode]);\n if ($isRootOrShadowRoot(imageNode.getParentOrThrow())) {\n $wrapNodeInElement(imageNode, $createParagraphNode).selectEnd();\n }\n return true;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACO,IAAMI,WAAW,GAAG,SAAdA,WAAWA,CAAIC,OAA2B,EAAc;EACjE,IAAMC,SAAS,GAAG,IAAAC,2BAAgB,EAACF,OAAO,CAAC;EAC3C,IAAAG,qBAAY,EAAC,CAACF,SAAS,CAAC,CAAC;EACzB,IAAI,IAAAG,4BAAmB,EAACH,SAAS,CAACI,gBAAgB,CAAC,CAAC,CAAC,EAAE;IACnD,IAAAC,yBAAkB,EAACL,SAAS,EAAEM,mCAAoB,CAAC,CAACC,SAAS,CAAC,CAAC;EACnE;EACA,OAAO,IAAI;AACf,CAAC;AAACC,OAAA,CAAAV,WAAA,GAAAA,WAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { LexicalNode } from "lexical";
|
|
2
|
-
import { ListNode } from "../../nodes/ListNode";
|
|
3
|
-
import { ListItemNode } from "../../nodes/ListItemNode";
|
|
4
|
-
export declare function $getListDepth(listNode: ListNode): number;
|
|
5
|
-
export declare function $getTopListNode(listItem: LexicalNode): ListNode;
|
|
6
|
-
export declare function $getAllListItems(node: ListNode): Array<ListItemNode>;
|
|
7
|
-
export declare function isNestedListNode(node: LexicalNode | null | undefined): boolean;
|
|
8
|
-
export declare function findNearestListItemNode(node: LexicalNode): ListItemNode | null;
|
|
9
|
-
export declare function getUniqueListItemNodes(nodeList: Array<LexicalNode>): Array<ListItemNode>;
|
|
10
|
-
export declare function $removeHighestEmptyListParent(sublist: ListItemNode | ListNode): void;
|
|
11
|
-
export declare function wrapInListItem(node: LexicalNode): ListItemNode;
|
package/utils/nodes/listNode.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.$getAllListItems = $getAllListItems;
|
|
7
|
-
exports.$getListDepth = $getListDepth;
|
|
8
|
-
exports.$getTopListNode = $getTopListNode;
|
|
9
|
-
exports.$removeHighestEmptyListParent = $removeHighestEmptyListParent;
|
|
10
|
-
exports.findNearestListItemNode = findNearestListItemNode;
|
|
11
|
-
exports.getUniqueListItemNodes = getUniqueListItemNodes;
|
|
12
|
-
exports.isNestedListNode = isNestedListNode;
|
|
13
|
-
exports.wrapInListItem = wrapInListItem;
|
|
14
|
-
var _ListNode = require("../../nodes/ListNode");
|
|
15
|
-
var _ListItemNode = require("../../nodes/ListItemNode");
|
|
16
|
-
function $getListDepth(listNode) {
|
|
17
|
-
var depth = 1;
|
|
18
|
-
var parent = listNode.getParent();
|
|
19
|
-
while (parent !== null) {
|
|
20
|
-
if ((0, _ListItemNode.$isListItemNode)(parent)) {
|
|
21
|
-
var parentList = parent.getParent();
|
|
22
|
-
if ((0, _ListNode.$isListNode)(parentList)) {
|
|
23
|
-
depth++;
|
|
24
|
-
parent = (parentList === null || parentList === void 0 ? void 0 : parentList.getParent()) || null;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
console.log("A WebinyListItemNode must have a WebinyListNode for a parent.");
|
|
28
|
-
}
|
|
29
|
-
return depth;
|
|
30
|
-
}
|
|
31
|
-
return depth;
|
|
32
|
-
}
|
|
33
|
-
function $getTopListNode(listItem) {
|
|
34
|
-
var list = listItem.getParent();
|
|
35
|
-
if (!(0, _ListNode.$isListNode)(list)) {
|
|
36
|
-
console.log("A WebinyListItemNode must have a ListNode for a parent.");
|
|
37
|
-
return listItem;
|
|
38
|
-
}
|
|
39
|
-
var parent = list;
|
|
40
|
-
while (parent !== null) {
|
|
41
|
-
parent = parent.getParent();
|
|
42
|
-
if ((0, _ListNode.$isListNode)(parent)) {
|
|
43
|
-
list = parent;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return list;
|
|
47
|
-
}
|
|
48
|
-
function $getAllListItems(node) {
|
|
49
|
-
var listItemNodes = [];
|
|
50
|
-
var listChildren = node.getChildren().filter(_ListItemNode.$isListItemNode);
|
|
51
|
-
for (var i = 0; i < listChildren.length; i++) {
|
|
52
|
-
var listItemNode = listChildren[i];
|
|
53
|
-
var firstChild = listItemNode === null || listItemNode === void 0 ? void 0 : listItemNode.getFirstChild();
|
|
54
|
-
if ((0, _ListNode.$isListNode)(firstChild)) {
|
|
55
|
-
listItemNodes = listItemNodes.concat($getAllListItems(firstChild));
|
|
56
|
-
} else {
|
|
57
|
-
listItemNodes.push(listItemNode);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return listItemNodes;
|
|
61
|
-
}
|
|
62
|
-
function isNestedListNode(node) {
|
|
63
|
-
return (0, _ListItemNode.$isListItemNode)(node) && (0, _ListNode.$isListNode)(node === null || node === void 0 ? void 0 : node.getFirstChild());
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// TODO: rewrite with $findMatchingParent or *nodeOfType
|
|
67
|
-
function findNearestListItemNode(node) {
|
|
68
|
-
var currentNode = node;
|
|
69
|
-
while (currentNode !== null) {
|
|
70
|
-
if ((0, _ListItemNode.$isListItemNode)(currentNode)) {
|
|
71
|
-
return currentNode;
|
|
72
|
-
}
|
|
73
|
-
currentNode = currentNode.getParent();
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
function getUniqueListItemNodes(nodeList) {
|
|
78
|
-
var keys = new Set();
|
|
79
|
-
for (var i = 0; i < nodeList.length; i++) {
|
|
80
|
-
var node = nodeList[i];
|
|
81
|
-
if ((0, _ListItemNode.$isListItemNode)(node)) {
|
|
82
|
-
keys.add(node);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return Array.from(keys);
|
|
86
|
-
}
|
|
87
|
-
function $removeHighestEmptyListParent(sublist) {
|
|
88
|
-
// Nodes may be repeatedly indented, to create deeply nested lists that each
|
|
89
|
-
// contain just one bullet.
|
|
90
|
-
// Our goal is to remove these (empty) deeply nested lists. The easiest
|
|
91
|
-
// way to do that is crawl back up the tree until we find a node that has siblings
|
|
92
|
-
// (e.g. is actually part of the list contents) and delete that, or delete
|
|
93
|
-
// the root of the list (if no list nodes have siblings.)
|
|
94
|
-
var emptyListPtr = sublist;
|
|
95
|
-
while (emptyListPtr.getNextSibling() == null && emptyListPtr.getPreviousSibling() == null) {
|
|
96
|
-
var parent = emptyListPtr.getParent();
|
|
97
|
-
if (parent == null || !((0, _ListItemNode.$isListItemNode)(emptyListPtr) || (0, _ListNode.$isListNode)(emptyListPtr))) {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
emptyListPtr = parent;
|
|
101
|
-
}
|
|
102
|
-
emptyListPtr.remove();
|
|
103
|
-
}
|
|
104
|
-
function wrapInListItem(node) {
|
|
105
|
-
var listItemWrapper = (0, _ListItemNode.$createListItemNode)();
|
|
106
|
-
return listItemWrapper.append(node);
|
|
107
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_ListNode","require","_ListItemNode","$getListDepth","listNode","depth","parent","getParent","$isListItemNode","parentList","$isListNode","console","log","$getTopListNode","listItem","list","$getAllListItems","node","listItemNodes","listChildren","getChildren","filter","i","length","listItemNode","firstChild","getFirstChild","concat","push","isNestedListNode","findNearestListItemNode","currentNode","getUniqueListItemNodes","nodeList","keys","Set","add","Array","from","$removeHighestEmptyListParent","sublist","emptyListPtr","getNextSibling","getPreviousSibling","remove","wrapInListItem","listItemWrapper","$createListItemNode","append"],"sources":["listNode.ts"],"sourcesContent":["import type { LexicalNode } from \"lexical\";\n\nimport { $isListNode, ListNode } from \"~/nodes/ListNode\";\nimport { $createListItemNode, $isListItemNode, ListItemNode } from \"~/nodes/ListItemNode\";\n\nexport function $getListDepth(listNode: ListNode): number {\n let depth = 1;\n let parent = listNode.getParent();\n\n while (parent !== null) {\n if ($isListItemNode(parent)) {\n const parentList = parent.getParent();\n\n if ($isListNode(parentList)) {\n depth++;\n parent = parentList?.getParent() || null;\n continue;\n }\n console.log(\"A WebinyListItemNode must have a WebinyListNode for a parent.\");\n }\n\n return depth;\n }\n\n return depth;\n}\n\nexport function $getTopListNode(listItem: LexicalNode): ListNode {\n let list = listItem.getParent<ListNode>();\n\n if (!$isListNode(list)) {\n console.log(\"A WebinyListItemNode must have a ListNode for a parent.\");\n return listItem as ListNode;\n }\n\n let parent: ListNode | null = list;\n\n while (parent !== null) {\n parent = parent.getParent();\n\n if ($isListNode(parent)) {\n list = parent;\n }\n }\n\n return list;\n}\n\nexport function $getAllListItems(node: ListNode): Array<ListItemNode> {\n let listItemNodes: Array<ListItemNode> = [];\n const listChildren: Array<ListItemNode> = node.getChildren().filter($isListItemNode);\n\n for (let i = 0; i < listChildren.length; i++) {\n const listItemNode = listChildren[i];\n const firstChild = listItemNode?.getFirstChild();\n\n if ($isListNode(firstChild)) {\n listItemNodes = listItemNodes.concat($getAllListItems(firstChild));\n } else {\n listItemNodes.push(listItemNode);\n }\n }\n\n return listItemNodes;\n}\n\nexport function isNestedListNode(node: LexicalNode | null | undefined): boolean {\n return $isListItemNode(node) && $isListNode(node?.getFirstChild());\n}\n\n// TODO: rewrite with $findMatchingParent or *nodeOfType\nexport function findNearestListItemNode(node: LexicalNode): ListItemNode | null {\n let currentNode: LexicalNode | null = node;\n\n while (currentNode !== null) {\n if ($isListItemNode(currentNode)) {\n return currentNode;\n }\n currentNode = currentNode.getParent();\n }\n\n return null;\n}\n\nexport function getUniqueListItemNodes(nodeList: Array<LexicalNode>): Array<ListItemNode> {\n const keys = new Set<ListItemNode>();\n\n for (let i = 0; i < nodeList.length; i++) {\n const node = nodeList[i];\n\n if ($isListItemNode(node)) {\n keys.add(node);\n }\n }\n\n return Array.from(keys);\n}\n\nexport function $removeHighestEmptyListParent(sublist: ListItemNode | ListNode) {\n // Nodes may be repeatedly indented, to create deeply nested lists that each\n // contain just one bullet.\n // Our goal is to remove these (empty) deeply nested lists. The easiest\n // way to do that is crawl back up the tree until we find a node that has siblings\n // (e.g. is actually part of the list contents) and delete that, or delete\n // the root of the list (if no list nodes have siblings.)\n let emptyListPtr = sublist;\n\n while (emptyListPtr.getNextSibling() == null && emptyListPtr.getPreviousSibling() == null) {\n const parent = emptyListPtr.getParent<ListItemNode | ListNode>();\n\n if (parent == null || !($isListItemNode(emptyListPtr) || $isListNode(emptyListPtr))) {\n break;\n }\n\n emptyListPtr = parent;\n }\n\n emptyListPtr.remove();\n}\n\nexport function wrapInListItem(node: LexicalNode): ListItemNode {\n const listItemWrapper = $createListItemNode();\n return listItemWrapper.append(node);\n}\n"],"mappings":";;;;;;;;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEO,SAASE,aAAaA,CAACC,QAAkB,EAAU;EACtD,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,MAAM,GAAGF,QAAQ,CAACG,SAAS,CAAC,CAAC;EAEjC,OAAOD,MAAM,KAAK,IAAI,EAAE;IACpB,IAAI,IAAAE,6BAAe,EAACF,MAAM,CAAC,EAAE;MACzB,IAAMG,UAAU,GAAGH,MAAM,CAACC,SAAS,CAAC,CAAC;MAErC,IAAI,IAAAG,qBAAW,EAACD,UAAU,CAAC,EAAE;QACzBJ,KAAK,EAAE;QACPC,MAAM,GAAG,CAAAG,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEF,SAAS,CAAC,CAAC,KAAI,IAAI;QACxC;MACJ;MACAI,OAAO,CAACC,GAAG,CAAC,+DAA+D,CAAC;IAChF;IAEA,OAAOP,KAAK;EAChB;EAEA,OAAOA,KAAK;AAChB;AAEO,SAASQ,eAAeA,CAACC,QAAqB,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5B,IAAiB,EAAgB;EAC5D,IAAM6B,eAAe,GAAG,IAAAC,iCAAmB,EAAC,CAAC;EAC7C,OAAOD,eAAe,CAACE,MAAM,CAAC/B,IAAI,CAAC;AACvC"}
|
|
@@ -1,22 +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.styleObjectToString = void 0;
|
|
8
|
-
var _reactStyleObjectToCss = _interopRequireDefault(require("react-style-object-to-css"));
|
|
9
|
-
// @ts-ignore - There are no types "@types/react-style-object-to-css" for this lib.
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
* Converts CSS style objects to string
|
|
13
|
-
* Example:
|
|
14
|
-
* { fontSize: '10px' } => "font-size: 10px"
|
|
15
|
-
* */
|
|
16
|
-
var styleObjectToString = function styleObjectToString(styleObject) {
|
|
17
|
-
if (!styleObject) {
|
|
18
|
-
return styleObject;
|
|
19
|
-
}
|
|
20
|
-
return (0, _reactStyleObjectToCss.default)(styleObject);
|
|
21
|
-
};
|
|
22
|
-
exports.styleObjectToString = styleObjectToString;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactStyleObjectToCss","_interopRequireDefault","require","styleObjectToString","styleObject","reactToCSS","exports"],"sources":["styleObjectToString.ts"],"sourcesContent":["// @ts-ignore - There are no types \"@types/react-style-object-to-css\" for this lib.\nimport reactToCSS from \"react-style-object-to-css\";\nimport { CSSObject } from \"@emotion/react\";\n\n/*\n * Converts CSS style objects to string\n * Example:\n * { fontSize: '10px' } => \"font-size: 10px\"\n * */\nexport const styleObjectToString = (styleObject: CSSObject): string => {\n if (!styleObject) {\n return styleObject;\n }\n return reactToCSS(styleObject);\n};\n"],"mappings":";;;;;;;AACA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AADA;;AAIA;AACA;AACA;AACA;AACA;AACO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,WAAsB,EAAa;EACnE,IAAI,CAACA,WAAW,EAAE;IACd,OAAOA,WAAW;EACtB;EACA,OAAO,IAAAC,8BAAU,EAACD,WAAW,CAAC;AAClC,CAAC;AAACE,OAAA,CAAAH,mBAAA,GAAAA,mBAAA"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ThemeEmotionMap } from "../types";
|
|
2
|
-
import { WebinyTheme } from "../themes/webinyLexicalTheme";
|
|
3
|
-
export declare const toTypographyEmotionMap: (css: (cssStyle: Record<string, any>) => string, theme: WebinyTheme, themeStylesTransformer?: any) => ThemeEmotionMap | {};
|
|
@@ -1,41 +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.toTypographyEmotionMap = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
/*
|
|
10
|
-
* Creates a map of style key ID's and typography style objects that include 'className' property which contains the
|
|
11
|
-
* CSS class name generated by the Emotion from typography styles object.
|
|
12
|
-
*/
|
|
13
|
-
var toTypographyEmotionMap = function toTypographyEmotionMap(css, theme, themeStylesTransformer) {
|
|
14
|
-
var _theme$styles;
|
|
15
|
-
var map = {};
|
|
16
|
-
var typographyStyles = (_theme$styles = theme.styles) === null || _theme$styles === void 0 ? void 0 : _theme$styles.typography;
|
|
17
|
-
if (!typographyStyles) {
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
for (var key in typographyStyles) {
|
|
21
|
-
var typographyTypeData = typographyStyles[key];
|
|
22
|
-
if (typographyTypeData) {
|
|
23
|
-
typographyTypeData.forEach(function (styleItem) {
|
|
24
|
-
// 'lx' (abbreviation of lexical) variable will lead to generate shorter class names.
|
|
25
|
-
// for example: instead of default 'css-181qz4b-453f345f'
|
|
26
|
-
// the last segment will always end with 'lx' or 'css-181qz4b-lx'
|
|
27
|
-
|
|
28
|
-
var transformedStyles = styleItem.styles;
|
|
29
|
-
if (themeStylesTransformer) {
|
|
30
|
-
transformedStyles = themeStylesTransformer(styleItem.styles);
|
|
31
|
-
}
|
|
32
|
-
var lx = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, styleItem), {}, {
|
|
33
|
-
className: [/*#__PURE__*/css(transformedStyles, "label:lx;")].filter(Boolean).join(" ")
|
|
34
|
-
});
|
|
35
|
-
map[styleItem.id] = lx;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return map;
|
|
40
|
-
};
|
|
41
|
-
exports.toTypographyEmotionMap = toTypographyEmotionMap;
|