@payloadcms/richtext-lexical 3.0.0-beta.95 → 3.0.0-beta.97
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/dist/exports/client/Field-MPDY6IHA.js +2 -0
- package/dist/exports/client/Field-MPDY6IHA.js.map +7 -0
- package/dist/exports/client/{RelationshipComponent-EZORSGUZ.js → RelationshipComponent-CPYVT3XN.js} +2 -2
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-TD7O23AB.js → chunk-BR57XNHD.js} +2 -2
- package/dist/exports/client/{chunk-TD7O23AB.js.map → chunk-BR57XNHD.js.map} +1 -1
- package/dist/exports/client/{chunk-UJDWBQ2K.js → chunk-EPEFKP5H.js} +2 -2
- package/dist/exports/client/{chunk-UJDWBQ2K.js.map → chunk-EPEFKP5H.js.map} +1 -1
- package/dist/exports/client/chunk-GK7ZKYHL.js +2 -0
- package/dist/exports/client/chunk-GK7ZKYHL.js.map +7 -0
- package/dist/exports/client/{chunk-OLSILJA6.js → chunk-MFAXC4ZA.js} +2 -2
- package/dist/exports/client/{chunk-OLSILJA6.js.map → chunk-MFAXC4ZA.js.map} +2 -2
- package/dist/exports/client/{chunk-V2LKLT2F.js → chunk-PECDZEZY.js} +3 -3
- package/dist/exports/client/{chunk-V2LKLT2F.js.map → chunk-PECDZEZY.js.map} +3 -3
- package/dist/exports/client/{chunk-YL453UOS.js → chunk-XIBMVIFW.js} +2 -2
- package/dist/exports/client/{chunk-YL453UOS.js.map → chunk-XIBMVIFW.js.map} +1 -1
- package/dist/exports/client/{component-2YLEVOFH.js → component-3EGTURAI.js} +2 -2
- package/dist/exports/client/{component-2YLEVOFH.js.map → component-3EGTURAI.js.map} +1 -1
- package/dist/exports/client/{component-7RAP75FW.js → component-BRCRMQID.js} +2 -2
- package/dist/exports/client/{component-7RAP75FW.js.map → component-BRCRMQID.js.map} +1 -1
- package/dist/exports/client/{component-LLWMZU6K.js → component-GAX6BHKZ.js} +2 -2
- package/dist/exports/client/{componentInline-YSHGRL2J.js → componentInline-RETIC4OV.js} +2 -2
- package/dist/exports/client/index.d.ts +2 -2
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +5 -5
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +27 -25
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/html/converter/index.d.ts +5 -5
- package/dist/features/converters/html/converter/index.d.ts.map +1 -1
- package/dist/features/converters/html/converter/index.js.map +1 -1
- package/dist/features/converters/html/converter/types.d.ts +1 -1
- package/dist/features/converters/html/converter/types.d.ts.map +1 -1
- package/dist/features/converters/html/converter/types.js.map +1 -1
- package/dist/features/converters/html/field/index.d.ts.map +1 -1
- package/dist/features/converters/html/field/index.js +3 -1
- package/dist/features/converters/html/field/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/utils/debounce.js +4 -4
- package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
- package/dist/features/experimental_table/client/utils/useDebounce.js.map +1 -1
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +3 -1
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/link/client/index.js +1 -1
- package/dist/features/link/client/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js +3 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +2 -2
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +2 -0
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts +2 -2
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +10 -4
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts +2 -2
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +6 -6
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/typesClient.d.ts +6 -6
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts +9 -8
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/server/feature.server.d.ts.map +1 -1
- package/dist/features/upload/server/feature.server.js +5 -1
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/field/Field.js +1 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.js +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +5 -5
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.js +1 -1
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.js +1 -1
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/loader.d.ts +2 -1
- package/dist/lexical/config/server/loader.d.ts.map +1 -1
- package/dist/lexical/config/server/loader.js +2 -0
- package/dist/lexical/config/server/loader.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +2 -1
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts +3 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +5 -3
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js +3 -1
- package/dist/lexical/plugins/handles/utils/doesLineHeightAffectElement.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/getNodeCloseToPoint.js.map +1 -1
- package/dist/lexical/utils/nodeFormat.d.ts +2 -2
- package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
- package/dist/lexical/utils/nodeFormat.js.map +1 -1
- package/dist/lexical/utils/rect.d.ts.map +1 -1
- package/dist/lexical/utils/rect.js.map +1 -1
- package/dist/lexical/utils/url.d.ts.map +1 -1
- package/dist/lexical/utils/url.js +18 -6
- package/dist/lexical/utils/url.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/createServerFeature.d.ts +1 -0
- package/dist/utilities/createServerFeature.d.ts.map +1 -1
- package/dist/utilities/createServerFeature.js +2 -0
- package/dist/utilities/createServerFeature.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/validateNodes.d.ts +2 -2
- package/dist/validate/validateNodes.d.ts.map +1 -1
- package/dist/validate/validateNodes.js +2 -2
- package/dist/validate/validateNodes.js.map +1 -1
- package/package.json +8 -6
- package/dist/exports/client/Field-SUWHJ4HF.js +0 -2
- package/dist/exports/client/Field-SUWHJ4HF.js.map +0 -7
- package/dist/exports/client/chunk-YSI2QILQ.js +0 -2
- package/dist/exports/client/chunk-YSI2QILQ.js.map +0 -7
- /package/dist/exports/client/{RelationshipComponent-EZORSGUZ.js.map → RelationshipComponent-CPYVT3XN.js.map} +0 -0
- /package/dist/exports/client/{component-LLWMZU6K.js.map → component-GAX6BHKZ.js.map} +0 -0
- /package/dist/exports/client/{componentInline-YSHGRL2J.js.map → componentInline-RETIC4OV.js.map} +0 -0
|
@@ -32,8 +32,8 @@ export declare const NON_BREAKING_SPACE = "\u00A0";
|
|
|
32
32
|
export declare const DOUBLE_LINE_BREAK = "\n\n";
|
|
33
33
|
export declare const RTL_REGEX: RegExp;
|
|
34
34
|
export declare const LTR_REGEX: RegExp;
|
|
35
|
-
export declare const TEXT_TYPE_TO_FORMAT: Record<
|
|
36
|
-
export declare const DETAIL_TYPE_TO_DETAIL: Record<
|
|
35
|
+
export declare const TEXT_TYPE_TO_FORMAT: Record<string | TextFormatType, number>;
|
|
36
|
+
export declare const DETAIL_TYPE_TO_DETAIL: Record<string | TextDetailType, number>;
|
|
37
37
|
export declare const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<ElementFormatType, ''>, number>;
|
|
38
38
|
export declare const ELEMENT_FORMAT_TO_TYPE: Record<number, ElementFormatType>;
|
|
39
39
|
export declare const TEXT_MODE_TO_TYPE: Record<TextModeType, 0 | 1 | 2>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeFormat.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/nodeFormat.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC9E,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,YAAY,CAAA;AAG3D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Bb,CAAA;AAEV,eAAO,MAAM,iBAAiB,QAQL,CAAA;AAGzB,eAAO,MAAM,kBAAkB,WAAW,CAAA;AAE1C,eAAO,MAAM,iBAAiB,SAAS,CAAA;AAYvC,eAAO,MAAM,SAAS,QAA8C,CAAA;AAEpE,eAAO,MAAM,SAAS,QAA8C,CAAA;AAEpE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"nodeFormat.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/nodeFormat.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC9E,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,YAAY,CAAA;AAG3D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Bb,CAAA;AAEV,eAAO,MAAM,iBAAiB,QAQL,CAAA;AAGzB,eAAO,MAAM,kBAAkB,WAAW,CAAA;AAE1C,eAAO,MAAM,iBAAiB,SAAS,CAAA;AAYvC,eAAO,MAAM,SAAS,QAA8C,CAAA;AAEpE,eAAO,MAAM,SAAS,QAA8C,CAAA;AAEpE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,GAAG,cAAc,EAAE,MAAM,CASvE,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,GAAG,cAAc,EAAE,MAAM,CAGzE,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,EAAE,MAAM,CAOjF,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAOpE,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAI7D,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAI1D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeFormat.js","names":["NodeFormat","DOM_ELEMENT_TYPE","DOM_TEXT_TYPE","NO_DIRTY_NODES","HAS_DIRTY_NODES","FULL_RECONCILE","IS_NORMAL","IS_TOKEN","IS_SEGMENTED","IS_INERT","IS_BOLD","IS_ITALIC","IS_STRIKETHROUGH","IS_UNDERLINE","IS_CODE","IS_SUBSCRIPT","IS_SUPERSCRIPT","IS_HIGHLIGHT","IS_DIRECTIONLESS","IS_UNMERGEABLE","IS_ALIGN_LEFT","IS_ALIGN_CENTER","IS_ALIGN_RIGHT","IS_ALIGN_JUSTIFY","IS_ALIGN_START","IS_ALIGN_END","IS_ALL_FORMATTING","NON_BREAKING_SPACE","DOUBLE_LINE_BREAK","RTL","LTR","RTL_REGEX","RegExp","LTR_REGEX","TEXT_TYPE_TO_FORMAT","bold","code","highlight","italic","strikethrough","subscript","superscript","underline","DETAIL_TYPE_TO_DETAIL","directionless","unmergeable","ELEMENT_TYPE_TO_FORMAT","center","end","justify","left","right","start","ELEMENT_FORMAT_TO_TYPE","TEXT_MODE_TO_TYPE","normal","segmented","token","TEXT_TYPE_TO_MODE"],"sources":["../../../src/lexical/utils/nodeFormat.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-objects */\n/* eslint-disable regexp/no-obscure-range */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n/* eslint-disable regexp/no-misleading-unicode-character */\n//This copy-and-pasted from lexical here: https://github.com/facebook/lexical/blob/c2ceee223f46543d12c574e62155e619f9a18a5d/packages/lexical/src/LexicalConstants.ts\n\nimport type { ElementFormatType, TextFormatType, TextModeType } from 'lexical'\nexport type TextDetailType = 'directionless' | 'unmergable'\n\n// DOM\nexport const NodeFormat = {\n DOM_ELEMENT_TYPE: 1,\n DOM_TEXT_TYPE: 3,\n // Reconciling\n NO_DIRTY_NODES: 0,\n HAS_DIRTY_NODES: 1,\n FULL_RECONCILE: 2,\n // Text node modes\n IS_NORMAL: 0,\n IS_TOKEN: 1,\n IS_SEGMENTED: 2,\n IS_INERT: 3,\n // Text node formatting\n IS_BOLD: 1,\n IS_ITALIC: 1 << 1,\n IS_STRIKETHROUGH: 1 << 2,\n IS_UNDERLINE: 1 << 3,\n IS_CODE: 1 << 4,\n IS_SUBSCRIPT: 1 << 5,\n IS_SUPERSCRIPT: 1 << 6,\n IS_HIGHLIGHT: 1 << 7,\n // Text node details\n IS_DIRECTIONLESS: 1,\n IS_UNMERGEABLE: 1 << 1,\n // Element node formatting\n IS_ALIGN_LEFT: 1,\n IS_ALIGN_CENTER: 2,\n IS_ALIGN_RIGHT: 3,\n IS_ALIGN_JUSTIFY: 4,\n IS_ALIGN_START: 5,\n IS_ALIGN_END: 6,\n} as const\n\nexport const IS_ALL_FORMATTING =\n NodeFormat.IS_BOLD |\n NodeFormat.IS_ITALIC |\n NodeFormat.IS_STRIKETHROUGH |\n NodeFormat.IS_UNDERLINE |\n NodeFormat.IS_CODE |\n NodeFormat.IS_SUBSCRIPT |\n NodeFormat.IS_SUPERSCRIPT |\n NodeFormat.IS_HIGHLIGHT\n\n// Reconciliation\nexport const NON_BREAKING_SPACE = '\\u00A0'\n\nexport const DOUBLE_LINE_BREAK = '\\n\\n'\n\n// For FF, we need to use a non-breaking space, or it gets composition\n// in a stuck state.\n\nconst RTL = '\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC'\nconst LTR =\n 'A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6' +\n '\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF\\u200E\\u2C00-\\uFB1C' +\n '\\uFE00-\\uFE6F\\uFEFD-\\uFFFF'\n\n// eslint-disable-next-line no-misleading-character-class\nexport const RTL_REGEX = new RegExp('^[^' + LTR + ']*[' + RTL + ']')\n// eslint-disable-next-line no-misleading-character-class\nexport const LTR_REGEX = new RegExp('^[^' + RTL + ']*[' + LTR + ']')\n\nexport const TEXT_TYPE_TO_FORMAT: Record<
|
|
1
|
+
{"version":3,"file":"nodeFormat.js","names":["NodeFormat","DOM_ELEMENT_TYPE","DOM_TEXT_TYPE","NO_DIRTY_NODES","HAS_DIRTY_NODES","FULL_RECONCILE","IS_NORMAL","IS_TOKEN","IS_SEGMENTED","IS_INERT","IS_BOLD","IS_ITALIC","IS_STRIKETHROUGH","IS_UNDERLINE","IS_CODE","IS_SUBSCRIPT","IS_SUPERSCRIPT","IS_HIGHLIGHT","IS_DIRECTIONLESS","IS_UNMERGEABLE","IS_ALIGN_LEFT","IS_ALIGN_CENTER","IS_ALIGN_RIGHT","IS_ALIGN_JUSTIFY","IS_ALIGN_START","IS_ALIGN_END","IS_ALL_FORMATTING","NON_BREAKING_SPACE","DOUBLE_LINE_BREAK","RTL","LTR","RTL_REGEX","RegExp","LTR_REGEX","TEXT_TYPE_TO_FORMAT","bold","code","highlight","italic","strikethrough","subscript","superscript","underline","DETAIL_TYPE_TO_DETAIL","directionless","unmergeable","ELEMENT_TYPE_TO_FORMAT","center","end","justify","left","right","start","ELEMENT_FORMAT_TO_TYPE","TEXT_MODE_TO_TYPE","normal","segmented","token","TEXT_TYPE_TO_MODE"],"sources":["../../../src/lexical/utils/nodeFormat.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-objects */\n/* eslint-disable regexp/no-obscure-range */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n/* eslint-disable regexp/no-misleading-unicode-character */\n//This copy-and-pasted from lexical here: https://github.com/facebook/lexical/blob/c2ceee223f46543d12c574e62155e619f9a18a5d/packages/lexical/src/LexicalConstants.ts\n\nimport type { ElementFormatType, TextFormatType, TextModeType } from 'lexical'\nexport type TextDetailType = 'directionless' | 'unmergable'\n\n// DOM\nexport const NodeFormat = {\n DOM_ELEMENT_TYPE: 1,\n DOM_TEXT_TYPE: 3,\n // Reconciling\n NO_DIRTY_NODES: 0,\n HAS_DIRTY_NODES: 1,\n FULL_RECONCILE: 2,\n // Text node modes\n IS_NORMAL: 0,\n IS_TOKEN: 1,\n IS_SEGMENTED: 2,\n IS_INERT: 3,\n // Text node formatting\n IS_BOLD: 1,\n IS_ITALIC: 1 << 1,\n IS_STRIKETHROUGH: 1 << 2,\n IS_UNDERLINE: 1 << 3,\n IS_CODE: 1 << 4,\n IS_SUBSCRIPT: 1 << 5,\n IS_SUPERSCRIPT: 1 << 6,\n IS_HIGHLIGHT: 1 << 7,\n // Text node details\n IS_DIRECTIONLESS: 1,\n IS_UNMERGEABLE: 1 << 1,\n // Element node formatting\n IS_ALIGN_LEFT: 1,\n IS_ALIGN_CENTER: 2,\n IS_ALIGN_RIGHT: 3,\n IS_ALIGN_JUSTIFY: 4,\n IS_ALIGN_START: 5,\n IS_ALIGN_END: 6,\n} as const\n\nexport const IS_ALL_FORMATTING =\n NodeFormat.IS_BOLD |\n NodeFormat.IS_ITALIC |\n NodeFormat.IS_STRIKETHROUGH |\n NodeFormat.IS_UNDERLINE |\n NodeFormat.IS_CODE |\n NodeFormat.IS_SUBSCRIPT |\n NodeFormat.IS_SUPERSCRIPT |\n NodeFormat.IS_HIGHLIGHT\n\n// Reconciliation\nexport const NON_BREAKING_SPACE = '\\u00A0'\n\nexport const DOUBLE_LINE_BREAK = '\\n\\n'\n\n// For FF, we need to use a non-breaking space, or it gets composition\n// in a stuck state.\n\nconst RTL = '\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC'\nconst LTR =\n 'A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6' +\n '\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF\\u200E\\u2C00-\\uFB1C' +\n '\\uFE00-\\uFE6F\\uFEFD-\\uFFFF'\n\n// eslint-disable-next-line no-misleading-character-class\nexport const RTL_REGEX = new RegExp('^[^' + LTR + ']*[' + RTL + ']')\n// eslint-disable-next-line no-misleading-character-class\nexport const LTR_REGEX = new RegExp('^[^' + RTL + ']*[' + LTR + ']')\n\nexport const TEXT_TYPE_TO_FORMAT: Record<string | TextFormatType, number> = {\n bold: NodeFormat.IS_BOLD,\n code: NodeFormat.IS_CODE,\n highlight: NodeFormat.IS_HIGHLIGHT,\n italic: NodeFormat.IS_ITALIC,\n strikethrough: NodeFormat.IS_STRIKETHROUGH,\n subscript: NodeFormat.IS_SUBSCRIPT,\n superscript: NodeFormat.IS_SUPERSCRIPT,\n underline: NodeFormat.IS_UNDERLINE,\n}\n\nexport const DETAIL_TYPE_TO_DETAIL: Record<string | TextDetailType, number> = {\n directionless: NodeFormat.IS_DIRECTIONLESS,\n unmergeable: NodeFormat.IS_UNMERGEABLE,\n}\n\nexport const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<ElementFormatType, ''>, number> = {\n center: NodeFormat.IS_ALIGN_CENTER,\n end: NodeFormat.IS_ALIGN_END,\n justify: NodeFormat.IS_ALIGN_JUSTIFY,\n left: NodeFormat.IS_ALIGN_LEFT,\n right: NodeFormat.IS_ALIGN_RIGHT,\n start: NodeFormat.IS_ALIGN_START,\n}\n\nexport const ELEMENT_FORMAT_TO_TYPE: Record<number, ElementFormatType> = {\n [NodeFormat.IS_ALIGN_CENTER]: 'center',\n [NodeFormat.IS_ALIGN_END]: 'end',\n [NodeFormat.IS_ALIGN_JUSTIFY]: 'justify',\n [NodeFormat.IS_ALIGN_LEFT]: 'left',\n [NodeFormat.IS_ALIGN_RIGHT]: 'right',\n [NodeFormat.IS_ALIGN_START]: 'start',\n}\n\nexport const TEXT_MODE_TO_TYPE: Record<TextModeType, 0 | 1 | 2> = {\n normal: NodeFormat.IS_NORMAL,\n segmented: NodeFormat.IS_SEGMENTED,\n token: NodeFormat.IS_TOKEN,\n}\n\nexport const TEXT_TYPE_TO_MODE: Record<number, TextModeType> = {\n [NodeFormat.IS_NORMAL]: 'normal',\n [NodeFormat.IS_SEGMENTED]: 'segmented',\n [NodeFormat.IS_TOKEN]: 'token',\n}\n"],"mappings":"AAAA,gDACA,6CACA,uEACA,4DACA;AAKA;AACA,OAAO,MAAMA,UAAA,GAAa;EACxBC,gBAAA,EAAkB;EAClBC,aAAA,EAAe;EACf;EACAC,cAAA,EAAgB;EAChBC,eAAA,EAAiB;EACjBC,cAAA,EAAgB;EAChB;EACAC,SAAA,EAAW;EACXC,QAAA,EAAU;EACVC,YAAA,EAAc;EACdC,QAAA,EAAU;EACV;EACAC,OAAA,EAAS;EACTC,SAAA,EAAW,KAAK;EAChBC,gBAAA,EAAkB,KAAK;EACvBC,YAAA,EAAc,KAAK;EACnBC,OAAA,EAAS,KAAK;EACdC,YAAA,EAAc,KAAK;EACnBC,cAAA,EAAgB,KAAK;EACrBC,YAAA,EAAc,KAAK;EACnB;EACAC,gBAAA,EAAkB;EAClBC,cAAA,EAAgB,KAAK;EACrB;EACAC,aAAA,EAAe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C,MAAA,EAAQ/C,UAAA,CAAWqB,eAAe;EAClC2B,GAAA,EAAKhD,UAAA,CAAWyB,YAAY;EAC5BwB,OAAA,EAASjD,UAAA,CAAWuB,gBAAgB;EACpC2B,IAAA,EAAMlD,UAAA,CAAWoB,aAAa;EAC9B+B,KAAA,EAAOnD,UAAA,CAAWsB,cAAc;EAChC8B,KAAA,EAAOpD,UAAA,CAAWwB;AACpB;AAEA,OAAO,MAAM6B,sBAAA,GAA4D;EACvE,CAACrD,UAAA,CAAWqB,eAAe,GAAG;EAC9B,CAACrB,UAAA,CAAWyB,YAAY,GAAG;EAC3B,CAACzB,UAAA,CAAWuB,gBAAgB,GAAG;EAC/B,CAACvB,UAAA,CAAWoB,aAAa,GAAG;EAC5B,CAACpB,UAAA,CAAWsB,cAAc,GAAG;EAC7B,CAACtB,UAAA,CAAWwB,cAAc,GAAG;AAC/B;AAEA,OAAO,MAAM8B,iBAAA,GAAqD;EAChEC,MAAA,EAAQvD,UAAA,CAAWM,SAAS;EAC5BkD,SAAA,EAAWxD,UAAA,CAAWQ,YAAY;EAClCiD,KAAA,EAAOzD,UAAA,CAAWO;AACpB;AAEA,OAAO,MAAMmD,iBAAA,GAAkD;EAC7D,CAAC1D,UAAA,CAAWM,SAAS,GAAG;EACxB,CAACN,UAAA,CAAWQ,YAAY,GAAG;EAC3B,CAACR,UAAA,CAAWO,QAAQ,GAAG;AACzB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/rect.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"rect.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/rect.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,YAAY,CAAA;AAEhD,UAAU,mBAAmB;IAC3B,MAAM,EAAE;QACN,cAAc,EAAE,OAAO,CAAA;QACvB,YAAY,EAAE,OAAO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A;QACtB,WAAW,EAAE,OAAO,CAAA;KACrB;IA2CM,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,GAAG,OAAO;IAMnD,eAAe,CAAC,EACrB,MAAoB,EACpB,IAAgB,EAChB,KAAkB,EAClB,GAAc,GACf;;;;;KAAA,GAAG,IAAI;IAID,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAU1C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rect.js","names":["isPoint","Rect","_bottom","_left","_right","_top","constructor","left","top","right","bottom","physicTop","physicBottom","physicLeft","physicRight","fromDOM","dom","height","width","getBoundingClientRect","fromLWTH","fromDOMRect","domRect","fromLTRB","fromPoints","startPoint","endPoint","x","y","contains","target","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","reason","distanceFromPoint","point","containsResult","distance","dx","dy","Math","sqrt","equals","generateNewRect","intersectsWith","rect","h1","x1","y1","w1","h2","x2","y2","w2","maxX","maxY","minX","minY","abs"],"sources":["../../../src/lexical/utils/rect.ts"],"sourcesContent":["'use client'\nimport { type Point, isPoint } from './point.js'\n\ninterface ContainsPointReturn {\n reason: {\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n }\n result: boolean\n}\n\nexport class Rect {\n private readonly _bottom: number\n\n private readonly _left: number\n\n private readonly _right: number\n\n private readonly _top: number\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top]\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left]\n\n this._top = physicTop\n this._right = physicRight\n this._left = physicLeft\n this._bottom = physicBottom\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { height, left, top, width } = dom.getBoundingClientRect()\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromDOMRect(domRect: DOMRect): Rect {\n const { height, left, top, width } = domRect\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height)\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { x: left, y: top } = startPoint\n const { x: right, y: bottom } = endPoint\n return Rect.fromLTRB(left, top, right, bottom)\n }\n\n public contains({ x, y }: Point): ContainsPointReturn\n\n public contains({ bottom, left, right, top }: Rect): boolean\n\n public contains(target: Point | Rect): ContainsPointReturn | boolean {\n if (isPoint(target)) {\n const { x, y } = target\n\n const isOnTopSide = y < this._top\n const isOnBottomSide = y > this._bottom\n const isOnLeftSide = x < this._left\n const isOnRightSide = x > this._right\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide,\n },\n result,\n }\n }\n const { bottom, left, right, top } = target\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n )\n }\n\n public distanceFromPoint(point: Point): {\n distance: number\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n } {\n const containsResult = this.contains(point)\n if (containsResult.result) {\n return {\n distance: 0,\n isOnBottomSide: containsResult.reason.isOnBottomSide,\n isOnLeftSide: containsResult.reason.isOnLeftSide,\n isOnRightSide: containsResult.reason.isOnRightSide,\n isOnTopSide: containsResult.reason.isOnTopSide,\n }\n }\n\n let dx = 0 // Horizontal distance to the closest edge\n let dy = 0 // Vertical distance to the closest edge\n\n // If the point is to the left of the rectangle\n if (point.x < this._left) {\n dx = this._left - point.x\n }\n // If the point is to the right of the rectangle\n else if (point.x > this._right) {\n dx = point.x - this._right\n }\n\n // If the point is above the rectangle\n if (point.y < this._top) {\n dy = this._top - point.y\n }\n // If the point is below the rectangle\n else if (point.y > this._bottom) {\n dy = point.y - this._bottom\n }\n\n // Use the Pythagorean theorem to calculate the distance\n return {\n distance: Math.sqrt(dx * dx + dy * dy),\n isOnBottomSide: point.y > this._bottom,\n isOnLeftSide: point.x < this._left,\n isOnRightSide: point.x > this._right,\n isOnTopSide: point.y < this._top,\n }\n }\n\n public equals({ bottom, left, right, top }: Rect): boolean {\n return (\n top === this._top && bottom === this._bottom && left === this._left && right === this._right\n )\n }\n\n public generateNewRect({\n bottom = this.bottom,\n left = this.left,\n right = this.right,\n top = this.top,\n }): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { height: h1, left: x1, top: y1, width: w1 } = rect\n const { height: h2, left: x2, top: y2, width: w2 } = this\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2\n const minX = x1 <= x2 ? x1 : x2\n const minY = y1 <= y2 ? y1 : y2\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2\n }\n\n get bottom(): number {\n return this._bottom\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top)\n }\n\n get left(): number {\n return this._left\n }\n\n get right(): number {\n return this._right\n }\n\n get top(): number {\n return this._top\n }\n\n get width(): number {\n return Math.abs(this._left - this._right)\n }\n}\n"],"mappings":"AAAA;;AACA,SAAqBA,OAAO,QAAQ;AAYpC,OAAO,MAAMC,IAAA;EACMC,OAAA;EAEAC,KAAA;EAEAC,MAAA;EAEAC,IAAA;EAEjBC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MAAME,IAAA,GAAOP,EAAA,GAAKF,EAAA,IAAMM,EAAA,GAAKF,EAAA,GAAKF,EAAA,GAAKF,EAAA,GAAKM,EAAA,GAAKF,EAAA;IACjD,MAAMM,IAAA,GAAOT,EAAA,IAAMI,EAAA,GAAKJ,EAAA,GAAKI,EAAA;IAC7B,MAAMM,IAAA,GAAOT,EAAA,IAAMI,EAAA,GAAKJ,EAAA,GAAKI,EAAA;IAC7B,OAAOE,IAAA,GAAOE,IAAA,IAAQP,EAAA,GAAKI,EAAA,IAAME,IAAA,GAAOE,IAAA,IAAQX,EAAA,GAAKI,EAAA;EACvD;EAEA,IAAI3C,OAAA,EAAiB;IACnB,OAAO,IAAI,CAACR,OAAO;EACrB;EAEA,IAAIe,OAAA,EAAiB;IACnB,OAAO0B,IAAA,CAAKkB,GAAG,CAAC,IAAI,CAAC3D,OAAO,GAAG,IAAI,CAACG,IAAI;EAC1C;EAEA,IAAIE,KAAA,EAAe;IACjB,OAAO,IAAI,CAACJ,KAAK;EACnB;EAEA,IAAIM,MAAA,EAAgB;IAClB,OAAO,IAAI,CAACL,MAAM;EACpB;EAEA,IAAII,IAAA,EAAc;IAChB,OAAO,IAAI,CAACH,IAAI;EAClB;EAEA,IAAIa,MAAA,EAAgB;IAClB,OAAOyB,IAAA,CAAKkB,GAAG,CAAC,IAAI,CAAC1D,KAAK,GAAG,IAAI,CAACC,MAAM;EAC1C;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"rect.js","names":["isPoint","Rect","_bottom","_left","_right","_top","constructor","left","top","right","bottom","physicTop","physicBottom","physicLeft","physicRight","fromDOM","dom","height","width","getBoundingClientRect","fromLWTH","fromDOMRect","domRect","fromLTRB","fromPoints","startPoint","endPoint","x","y","contains","target","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","reason","distanceFromPoint","point","containsResult","distance","dx","dy","Math","sqrt","equals","generateNewRect","intersectsWith","rect","h1","x1","y1","w1","h2","x2","y2","w2","maxX","maxY","minX","minY","abs"],"sources":["../../../src/lexical/utils/rect.ts"],"sourcesContent":["'use client'\nimport { isPoint, type Point } from './point.js'\n\ninterface ContainsPointReturn {\n reason: {\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n }\n result: boolean\n}\n\nexport class Rect {\n private readonly _bottom: number\n\n private readonly _left: number\n\n private readonly _right: number\n\n private readonly _top: number\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top]\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left]\n\n this._top = physicTop\n this._right = physicRight\n this._left = physicLeft\n this._bottom = physicBottom\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { height, left, top, width } = dom.getBoundingClientRect()\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromDOMRect(domRect: DOMRect): Rect {\n const { height, left, top, width } = domRect\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height)\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { x: left, y: top } = startPoint\n const { x: right, y: bottom } = endPoint\n return Rect.fromLTRB(left, top, right, bottom)\n }\n\n public contains({ x, y }: Point): ContainsPointReturn\n\n public contains({ bottom, left, right, top }: Rect): boolean\n\n public contains(target: Point | Rect): boolean | ContainsPointReturn {\n if (isPoint(target)) {\n const { x, y } = target\n\n const isOnTopSide = y < this._top\n const isOnBottomSide = y > this._bottom\n const isOnLeftSide = x < this._left\n const isOnRightSide = x > this._right\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide,\n },\n result,\n }\n }\n const { bottom, left, right, top } = target\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n )\n }\n\n public distanceFromPoint(point: Point): {\n distance: number\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n } {\n const containsResult = this.contains(point)\n if (containsResult.result) {\n return {\n distance: 0,\n isOnBottomSide: containsResult.reason.isOnBottomSide,\n isOnLeftSide: containsResult.reason.isOnLeftSide,\n isOnRightSide: containsResult.reason.isOnRightSide,\n isOnTopSide: containsResult.reason.isOnTopSide,\n }\n }\n\n let dx = 0 // Horizontal distance to the closest edge\n let dy = 0 // Vertical distance to the closest edge\n\n // If the point is to the left of the rectangle\n if (point.x < this._left) {\n dx = this._left - point.x\n }\n // If the point is to the right of the rectangle\n else if (point.x > this._right) {\n dx = point.x - this._right\n }\n\n // If the point is above the rectangle\n if (point.y < this._top) {\n dy = this._top - point.y\n }\n // If the point is below the rectangle\n else if (point.y > this._bottom) {\n dy = point.y - this._bottom\n }\n\n // Use the Pythagorean theorem to calculate the distance\n return {\n distance: Math.sqrt(dx * dx + dy * dy),\n isOnBottomSide: point.y > this._bottom,\n isOnLeftSide: point.x < this._left,\n isOnRightSide: point.x > this._right,\n isOnTopSide: point.y < this._top,\n }\n }\n\n public equals({ bottom, left, right, top }: Rect): boolean {\n return (\n top === this._top && bottom === this._bottom && left === this._left && right === this._right\n )\n }\n\n public generateNewRect({\n bottom = this.bottom,\n left = this.left,\n right = this.right,\n top = this.top,\n }): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { height: h1, left: x1, top: y1, width: w1 } = rect\n const { height: h2, left: x2, top: y2, width: w2 } = this\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2\n const minX = x1 <= x2 ? x1 : x2\n const minY = y1 <= y2 ? y1 : y2\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2\n }\n\n get bottom(): number {\n return this._bottom\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top)\n }\n\n get left(): number {\n return this._left\n }\n\n get right(): number {\n return this._right\n }\n\n get top(): number {\n return this._top\n }\n\n get width(): number {\n return Math.abs(this._left - this._right)\n }\n}\n"],"mappings":"AAAA;;AACA,SAASA,OAAO,QAAoB;AAYpC,OAAO,MAAMC,IAAA;EACMC,OAAA;EAEAC,KAAA;EAEAC,MAAA;EAEAC,IAAA;EAEjBC,YAAYC,IAAY,EAAEC,GAAW,EAAEC,KAAa,EAAEC,MAAc,EAAE;IACpE,MAAM,CAACC,SAAA,EAAWC,YAAA,CAAa,GAAGJ,GAAA,IAAOE,MAAA,GAAS,CAACF,GAAA,EAAKE,MAAA,CAAO,GAAG,CAACA,MAAA,EAAQF,GAAA,CAAI;IAE/E,MAAM,CAACK,UAAA,EAAYC,WAAA,CAAY,GAAGP,IAAA,IAAQE,KAAA,GAAQ,CAACF,IAAA,EAAME,KAAA,CAAM,GAAG,CAACA,KAAA,EAAOF,IAAA,CAAK;IAE/E,IAAI,CAACF,IAAI,GAAGM,SAAA;IACZ,IAAI,CAACP,MAAM,GAAGU,WAAA;IACd,IAAI,CAACX,KAAK,GAAGU,UAAA;IACb,IAAI,CAACX,OAAO,GAAGU,YAAA;EACjB;EAEA,OAAOG,QAAQC,GAAgB,EAAQ;IACrC,MAAM;MAAEC,MAAM;MAAEV,IAAI;MAAEC,GAAG;MAAEU;IAAK,CAAE,GAAGF,GAAA,CAAIG,qBAAqB;IAC9D,OAAOlB,IAAA,CAAKmB,QAAQ,CAACb,IAAA,EAAMW,KAAA,EAAOV,GAAA,EAAKS,MAAA;EACzC;EAEA,OAAOI,YAAYC,OAAgB,EAAQ;IACzC,MAAM;MAAEL,MAAM;MAAEV,IAAI;MAAEC,GAAG;MAAEU;IAAK,CAAE,GAAGI,OAAA;IACrC,OAAOrB,IAAA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F","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAe/C;AAcD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMvD;AAID,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CA+BhD"}
|
|
@@ -3,7 +3,9 @@ export function sanitizeUrl(url) {
|
|
|
3
3
|
/** A pattern that matches safe data URLs. */
|
|
4
4
|
const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z\d+/]+=*$/i;
|
|
5
5
|
url = String(url).trim();
|
|
6
|
-
if (url.match(SAFE_URL_PATTERN) != null || url.match(DATA_URL_PATTERN) != null)
|
|
6
|
+
if (url.match(SAFE_URL_PATTERN) != null || url.match(DATA_URL_PATTERN) != null) {
|
|
7
|
+
return url;
|
|
8
|
+
}
|
|
7
9
|
return 'https://';
|
|
8
10
|
}
|
|
9
11
|
// Source: https://stackoverflow.com/a/8234912/2013580
|
|
@@ -20,7 +22,9 @@ const relativeOrAnchorRegExp = /^[\w\-./]*(?:#\w[\w-]*)?$/;
|
|
|
20
22
|
* @param url
|
|
21
23
|
*/
|
|
22
24
|
export function validateUrlMinimal(url) {
|
|
23
|
-
if (!url)
|
|
25
|
+
if (!url) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
24
28
|
return !url.includes(' ');
|
|
25
29
|
}
|
|
26
30
|
// Do not keep validateUrl function too loose. This is run when pasting in text, to determine if links are in that text and if it should create AutoLinkNodes.
|
|
@@ -28,12 +32,20 @@ export function validateUrlMinimal(url) {
|
|
|
28
32
|
export function validateUrl(url) {
|
|
29
33
|
// TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.
|
|
30
34
|
// Maybe show a dialog where they user can type the URL before inserting it.
|
|
31
|
-
if (!url)
|
|
32
|
-
|
|
35
|
+
if (!url) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (url === 'https://') {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
33
41
|
// This makes sure URLs starting with www. instead of https are valid too
|
|
34
|
-
if (absoluteRegExp.test(url))
|
|
42
|
+
if (absoluteRegExp.test(url)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
35
45
|
// Check relative or anchor links
|
|
36
|
-
if (relativeOrAnchorRegExp.test(url))
|
|
46
|
+
if (relativeOrAnchorRegExp.test(url)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
37
49
|
// While this doesn't allow URLs starting with www (which is why we use the regex above), it does properly handle tel: URLs
|
|
38
50
|
try {
|
|
39
51
|
new URL(url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","names":["sanitizeUrl","url","SAFE_URL_PATTERN","DATA_URL_PATTERN","String","trim","match","absoluteRegExp","relativeOrAnchorRegExp","validateUrlMinimal","includes","validateUrl","test","URL"],"sources":["../../../src/lexical/utils/url.ts"],"sourcesContent":["export function sanitizeUrl(url: string): string {\n /** A pattern that matches safe URLs. */\n const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi\n\n /** A pattern that matches safe data URLs. */\n const DATA_URL_PATTERN =\n /^data:(?:image\\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\\/(?:mpeg|mp4|ogg|webm)|audio\\/(?:mp3|oga|ogg|opus));base64,[a-z\\d+/]+=*$/i\n\n url = String(url).trim()\n\n if (url.match(SAFE_URL_PATTERN) != null || url.match(DATA_URL_PATTERN) != null) return url\n\n return 'https://'\n}\n\n// Source: https://stackoverflow.com/a/8234912/2013580\nconst absoluteRegExp =\n /(?:[A-Za-z]{3,9}:(?:\\/\\/)?(?:[-;:&=+$,\\w]+@)?[A-Za-z\\d.-]+|(?:www.|[-;:&=+$,\\w]+@)[A-Za-z\\d.-]+)(?:\\/[+~%/.\\w-]*)?\\??[-+=&;%@.\\w]*#?\\w*/\n\n/**\n * This regex checks for relative URLs starting with / or anchor links starting with # in a string. Tested for the following use cases:\n * - /privacy-policy\n * - /privacy-policy#primary-terms\n * - #primary-terms\n * */\nconst relativeOrAnchorRegExp = /^[\\w\\-./]*(?:#\\w[\\w-]*)?$/\n\n/**\n * Prevents unreasonable URLs from being inserted into the editor.\n * @param url\n */\nexport function validateUrlMinimal(url: string): boolean {\n if (!url) return false\n\n return !url.includes(' ')\n}\n\n// Do not keep validateUrl function too loose. This is run when pasting in text, to determine if links are in that text and if it should create AutoLinkNodes.\n// This is why we do not allow stuff like anchors here, as we don't want copied anchors to be turned into AutoLinkNodes.\nexport function validateUrl(url: string): boolean {\n // TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.\n // Maybe show a dialog where they user can type the URL before inserting it.\n\n if (!url) return false\n\n if (url === 'https://') return true\n\n // This makes sure URLs starting with www. instead of https are valid too\n if (absoluteRegExp.test(url)) return true\n\n // Check relative or anchor links\n if (relativeOrAnchorRegExp.test(url)) return true\n\n // While this doesn't allow URLs starting with www (which is why we use the regex above), it does properly handle tel: URLs\n try {\n new URL(url)\n return true\n } catch {\n /* empty */\n }\n\n return false\n}\n"],"mappings":"AAAA,OAAO,SAASA,YAAYC,GAAW;EACrC,yCACA,MAAMC,gBAAA,GAAmB;EAEzB;EACA,MAAMC,gBAAA,GACJ;EAEFF,GAAA,GAAMG,MAAA,CAAOH,GAAA,EAAKI,IAAI;EAEtB,IAAIJ,GAAA,CAAIK,KAAK,CAACJ,gBAAA,KAAqB,QAAQD,GAAA,CAAIK,KAAK,CAACH,gBAAA,KAAqB,MAAM,OAAOF,GAAA;
|
|
1
|
+
{"version":3,"file":"url.js","names":["sanitizeUrl","url","SAFE_URL_PATTERN","DATA_URL_PATTERN","String","trim","match","absoluteRegExp","relativeOrAnchorRegExp","validateUrlMinimal","includes","validateUrl","test","URL"],"sources":["../../../src/lexical/utils/url.ts"],"sourcesContent":["export function sanitizeUrl(url: string): string {\n /** A pattern that matches safe URLs. */\n const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi\n\n /** A pattern that matches safe data URLs. */\n const DATA_URL_PATTERN =\n /^data:(?:image\\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\\/(?:mpeg|mp4|ogg|webm)|audio\\/(?:mp3|oga|ogg|opus));base64,[a-z\\d+/]+=*$/i\n\n url = String(url).trim()\n\n if (url.match(SAFE_URL_PATTERN) != null || url.match(DATA_URL_PATTERN) != null) {\n return url\n }\n\n return 'https://'\n}\n\n// Source: https://stackoverflow.com/a/8234912/2013580\nconst absoluteRegExp =\n /(?:[A-Za-z]{3,9}:(?:\\/\\/)?(?:[-;:&=+$,\\w]+@)?[A-Za-z\\d.-]+|(?:www.|[-;:&=+$,\\w]+@)[A-Za-z\\d.-]+)(?:\\/[+~%/.\\w-]*)?\\??[-+=&;%@.\\w]*#?\\w*/\n\n/**\n * This regex checks for relative URLs starting with / or anchor links starting with # in a string. Tested for the following use cases:\n * - /privacy-policy\n * - /privacy-policy#primary-terms\n * - #primary-terms\n * */\nconst relativeOrAnchorRegExp = /^[\\w\\-./]*(?:#\\w[\\w-]*)?$/\n\n/**\n * Prevents unreasonable URLs from being inserted into the editor.\n * @param url\n */\nexport function validateUrlMinimal(url: string): boolean {\n if (!url) {\n return false\n }\n\n return !url.includes(' ')\n}\n\n// Do not keep validateUrl function too loose. This is run when pasting in text, to determine if links are in that text and if it should create AutoLinkNodes.\n// This is why we do not allow stuff like anchors here, as we don't want copied anchors to be turned into AutoLinkNodes.\nexport function validateUrl(url: string): boolean {\n // TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.\n // Maybe show a dialog where they user can type the URL before inserting it.\n\n if (!url) {\n return false\n }\n\n if (url === 'https://') {\n return true\n }\n\n // This makes sure URLs starting with www. instead of https are valid too\n if (absoluteRegExp.test(url)) {\n return true\n }\n\n // Check relative or anchor links\n if (relativeOrAnchorRegExp.test(url)) {\n return true\n }\n\n // While this doesn't allow URLs starting with www (which is why we use the regex above), it does properly handle tel: URLs\n try {\n new URL(url)\n return true\n } catch {\n /* empty */\n }\n\n return false\n}\n"],"mappings":"AAAA,OAAO,SAASA,YAAYC,GAAW;EACrC,yCACA,MAAMC,gBAAA,GAAmB;EAEzB;EACA,MAAMC,gBAAA,GACJ;EAEFF,GAAA,GAAMG,MAAA,CAAOH,GAAA,EAAKI,IAAI;EAEtB,IAAIJ,GAAA,CAAIK,KAAK,CAACJ,gBAAA,KAAqB,QAAQD,GAAA,CAAIK,KAAK,CAACH,gBAAA,KAAqB,MAAM;IAC9E,OAAOF,GAAA;EACT;EAEA,OAAO;AACT;AAEA;AACA,MAAMM,cAAA,GACJ;AAEF;;;;;;AAMA,MAAMC,sBAAA,GAAyB;AAE/B;;;;AAIA,OAAO,SAASC,mBAAmBR,GAAW;EAC5C,IAAI,CAACA,GAAA,EAAK;IACR,OAAO;EACT;EAEA,OAAO,CAACA,GAAA,CAAIS,QAAQ,CAAC;AACvB;AAEA;AACA;AACA,OAAO,SAASC,YAAYV,GAAW;EACrC;EACA;EAEA,IAAI,CAACA,GAAA,EAAK;IACR,OAAO;EACT;EAEA,IAAIA,GAAA,KAAQ,YAAY;IACtB,OAAO;EACT;EAEA;EACA,IAAIM,cAAA,CAAeK,IAAI,CAACX,GAAA,GAAM;IAC5B,OAAO;EACT;EAEA;EACA,IAAIO,sBAAA,CAAuBI,IAAI,CAACX,GAAA,GAAM;IACpC,OAAO;EACT;EAEA;EACA,IAAI;IACF,IAAIY,GAAA,CAAIZ,GAAA;IACR,OAAO;EACT,EAAE,MAAM;IACN;EAGF,OAAO;AACT","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -48,9 +48,10 @@ export type LexicalRichTextAdapterProvider =
|
|
|
48
48
|
/**
|
|
49
49
|
* This is being called during the payload sanitization process
|
|
50
50
|
*/
|
|
51
|
-
({ config, isRoot, }: {
|
|
51
|
+
({ config, isRoot, parentIsLocalized, }: {
|
|
52
52
|
config: SanitizedConfig;
|
|
53
53
|
isRoot?: boolean;
|
|
54
|
+
parentIsLocalized: boolean;
|
|
54
55
|
}) => Promise<LexicalRichTextAdapter>;
|
|
55
56
|
export type LexicalRichTextFieldProps = {
|
|
56
57
|
admin: LexicalFieldAdminProps;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EAGV,eAAe,EACf,kBAAkB,EAClB,eAAe,EAChB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAE5E,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,sBAAsB,CAAA;IAC9B,QAAQ,CAAC,EACL,CAAC,CAAC,EACA,eAAe,EACf,YAAY,GACb,EAAE;QACD;;;;;;;;;;WAUG;QACH,eAAe,EAAE,qBAAqB,CAAC,GAA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AAE,MAAM,CAAA;CACd,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n FieldPermissions,\n FieldTypes,\n RichTextAdapter,\n RichTextFieldProps,\n SanitizedConfig,\n} from 'payload'\nimport type React from 'react'\n\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n}\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?:\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type LexicalRichTextFieldProps = {\n admin: LexicalFieldAdminProps\n lexicalEditorConfig: LexicalEditorConfig\n} & RichTextFieldProps<SerializedEditorState, AdapterProps, object>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n ClientFeature: React.ReactNode\n key: string\n order: number\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n FieldPermissions,\n FieldTypes,\n RichTextAdapter,\n RichTextFieldProps,\n SanitizedConfig,\n} from 'payload'\nimport type React from 'react'\n\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n}\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?:\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type LexicalRichTextFieldProps = {\n admin: LexicalFieldAdminProps\n lexicalEditorConfig: LexicalEditorConfig\n} & RichTextFieldProps<SerializedEditorState, AdapterProps, object>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n ClientFeature: React.ReactNode\n key: string\n order: number\n}\n"],"mappings":"AAqFA","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ export type CreateServerFeatureArgs<UnSanitizedProps, SanitizedProps, ClientProp
|
|
|
7
7
|
/** unSanitizedEditorConfig.features, but mapped */
|
|
8
8
|
featureProviderMap: ServerFeatureProviderMap;
|
|
9
9
|
isRoot?: boolean;
|
|
10
|
+
parentIsLocalized: boolean;
|
|
10
11
|
props: UnSanitizedProps;
|
|
11
12
|
resolvedFeatures: ResolvedServerFeatureMap;
|
|
12
13
|
unSanitizedEditorConfig: ServerEditorConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServerFeature.d.ts","sourceRoot":"","sources":["../../src/utilities/createServerFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,wBAAwB,EACzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,MAAM,MAAM,uBAAuB,CAAC,gBAAgB,EAAE,cAAc,EAAE,WAAW,IAAI;IACnF,OAAO,EACH,CAAC,CAAC,KAAK,EAAE;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e,CAAA;QACvB,mDAAmD;QACnD,kBAAkB,EAAE,wBAAwB,CAAA;QAC5C,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,iBAAiB,EAAE,OAAO,CAAA;QAC1B,KAAK,EAAE,gBAAgB,CAAA;QAEvB,gBAAgB,EAAE,wBAAwB,CAAA;QAE1C,uBAAuB,EAAE,kBAAkB,CAAA;KAC5C,KACG,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,GACnD,aAAa,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,GAC/C,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,6BAA6B,CAAC,CAAA;CACpF,GAAG,IAAI,CACN,qBAAqB,CAAC,gBAAgB,EAAE,WAAW,CAAC,EACpD,cAAc,GAAG,sBAAsB,GAAG,kBAAkB,GAAG,KAAK,CACrE,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,CAChC,gBAAgB,GAAG,SAAS,EAC5B,cAAc,GAAG,gBAAgB,EACjC,WAAW,GAAG,SAAS,EAEvB,IAAI,EAAE,uBAAuB,CAAC,gBAAgB,EAAE,cAAc,EAAE,WAAW,CAAC,KACzE,6BAA6B,CAAC,gBAAgB,EAAE,cAAc,EAAE,WAAW,CAmD/E,CAAA"}
|
|
@@ -18,6 +18,7 @@ export const createServerFeature = ({
|
|
|
18
18
|
config,
|
|
19
19
|
featureProviderMap,
|
|
20
20
|
isRoot,
|
|
21
|
+
parentIsLocalized,
|
|
21
22
|
resolvedFeatures,
|
|
22
23
|
unSanitizedEditorConfig
|
|
23
24
|
}) => {
|
|
@@ -25,6 +26,7 @@ export const createServerFeature = ({
|
|
|
25
26
|
config,
|
|
26
27
|
featureProviderMap,
|
|
27
28
|
isRoot,
|
|
29
|
+
parentIsLocalized,
|
|
28
30
|
props,
|
|
29
31
|
resolvedFeatures,
|
|
30
32
|
unSanitizedEditorConfig
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServerFeature.js","names":["createServerFeature","dependencies","dependenciesPriority","dependenciesSoft","feature","key","featureProviderProviderServer","props","featureProviderServer","serverFeatureProps","config","featureProviderMap","isRoot","resolvedFeatures","unSanitizedEditorConfig","toReturn","sanitizedServerFeatureProps","newFeature"],"sources":["../../src/utilities/createServerFeature.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport type {\n FeatureProviderProviderServer,\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n ServerFeature,\n ServerFeatureProviderMap,\n} from '../features/typesServer.js'\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\n\nexport type CreateServerFeatureArgs<UnSanitizedProps, SanitizedProps, ClientProps> = {\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n props: UnSanitizedProps\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<SanitizedProps, ClientProps>>\n | ServerFeature<SanitizedProps, ClientProps>)\n | Omit<ServerFeature<SanitizedProps, ClientProps>, 'sanitizedServerFeatureProps'>\n} & Pick<\n FeatureProviderServer<UnSanitizedProps, ClientProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n>\n\nexport const createServerFeature: <\n UnSanitizedProps = undefined,\n SanitizedProps = UnSanitizedProps,\n ClientProps = undefined,\n>(\n args: CreateServerFeatureArgs<UnSanitizedProps, SanitizedProps, ClientProps>,\n) => FeatureProviderProviderServer<UnSanitizedProps, SanitizedProps, ClientProps> = ({\n dependencies,\n dependenciesPriority,\n dependenciesSoft,\n feature,\n key,\n}) => {\n const featureProviderProviderServer: FeatureProviderProviderServer<any, any, any> = (props) => {\n const featureProviderServer: Partial<FeatureProviderServer<any, any, any>> = {\n dependencies,\n dependenciesPriority,\n dependenciesSoft,\n key,\n serverFeatureProps: props,\n }\n\n if (typeof feature === 'function') {\n featureProviderServer.feature = async ({\n config,\n featureProviderMap,\n isRoot,\n resolvedFeatures,\n unSanitizedEditorConfig,\n }) => {\n const toReturn = await feature({\n config,\n featureProviderMap,\n isRoot,\n props,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n\n if (toReturn.sanitizedServerFeatureProps === null) {\n toReturn.sanitizedServerFeatureProps = props\n }\n return toReturn\n }\n } else {\n // For explanation why we have to spread feature, see createClientFeature.ts\n const newFeature: ServerFeature<any, any> = { ...feature }\n\n newFeature.sanitizedServerFeatureProps = props\n featureProviderServer.feature = newFeature\n }\n return featureProviderServer as FeatureProviderServer<any, any, any>\n }\n\n return featureProviderProviderServer\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createServerFeature.js","names":["createServerFeature","dependencies","dependenciesPriority","dependenciesSoft","feature","key","featureProviderProviderServer","props","featureProviderServer","serverFeatureProps","config","featureProviderMap","isRoot","parentIsLocalized","resolvedFeatures","unSanitizedEditorConfig","toReturn","sanitizedServerFeatureProps","newFeature"],"sources":["../../src/utilities/createServerFeature.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport type {\n FeatureProviderProviderServer,\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n ServerFeature,\n ServerFeatureProviderMap,\n} from '../features/typesServer.js'\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\n\nexport type CreateServerFeatureArgs<UnSanitizedProps, SanitizedProps, ClientProps> = {\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n parentIsLocalized: boolean\n props: UnSanitizedProps\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<SanitizedProps, ClientProps>>\n | ServerFeature<SanitizedProps, ClientProps>)\n | Omit<ServerFeature<SanitizedProps, ClientProps>, 'sanitizedServerFeatureProps'>\n} & Pick<\n FeatureProviderServer<UnSanitizedProps, ClientProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n>\n\nexport const createServerFeature: <\n UnSanitizedProps = undefined,\n SanitizedProps = UnSanitizedProps,\n ClientProps = undefined,\n>(\n args: CreateServerFeatureArgs<UnSanitizedProps, SanitizedProps, ClientProps>,\n) => FeatureProviderProviderServer<UnSanitizedProps, SanitizedProps, ClientProps> = ({\n dependencies,\n dependenciesPriority,\n dependenciesSoft,\n feature,\n key,\n}) => {\n const featureProviderProviderServer: FeatureProviderProviderServer<any, any, any> = (props) => {\n const featureProviderServer: Partial<FeatureProviderServer<any, any, any>> = {\n dependencies,\n dependenciesPriority,\n dependenciesSoft,\n key,\n serverFeatureProps: props,\n }\n\n if (typeof feature === 'function') {\n featureProviderServer.feature = async ({\n config,\n featureProviderMap,\n isRoot,\n parentIsLocalized,\n resolvedFeatures,\n unSanitizedEditorConfig,\n }) => {\n const toReturn = await feature({\n config,\n featureProviderMap,\n isRoot,\n parentIsLocalized,\n props,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n\n if (toReturn.sanitizedServerFeatureProps === null) {\n toReturn.sanitizedServerFeatureProps = props\n }\n return toReturn\n }\n } else {\n // For explanation why we have to spread feature, see createClientFeature.ts\n const newFeature: ServerFeature<any, any> = { ...feature }\n\n newFeature.sanitizedServerFeatureProps = props\n featureProviderServer.feature = newFeature\n }\n return featureProviderServer as FeatureProviderServer<any, any, any>\n }\n\n return featureProviderProviderServer\n}\n"],"mappings":"AAiCA,OAAO,MAAMA,mBAAA,GAMuEA,CAAC;EACnFC,YAAY;EACZC,oBAAoB;EACpBC,gBAAgB;EAChBC,OAAO;EACPC;AAAG,CACJ;EACC,MAAMC,6BAAA,GAA+EC,KAAA;IACnF,MAAMC,qBAAA,GAAuE;MAC3EP,YAAA;MACAC,oBAAA;MACAC,gBAAA;MACAE,GAAA;MACAI,kBAAA,EAAoBF;IACtB;IAEA,IAAI,OAAOH,OAAA,KAAY,YAAY;MACjCI,qBAAA,CAAsBJ,OAAO,GAAG,OAAO;QACrCM,MAAM;QACNC,kBAAkB;QAClBC,MAAM;QACNC,iBAAiB;QACjBC,gBAAgB;QAChBC;MAAuB,CACxB;QACC,MAAMC,QAAA,GAAW,MAAMZ,OAAA,CAAQ;UAC7BM,MAAA;UACAC,kBAAA;UACAC,MAAA;UACAC,iBAAA;UACAN,KAAA;UACAO,gBAAA;UACAC;QACF;QAEA,IAAIC,QAAA,CAASC,2BAA2B,KAAK,MAAM;UACjDD,QAAA,CAASC,2BAA2B,GAAGV,KAAA;QACzC;QACA,OAAOS,QAAA;MACT;IACF,OAAO;MACL;MACA,MAAME,UAAA,GAAsC;QAAE,GAAGd;MAAQ;MAEzDc,UAAA,CAAWD,2BAA2B,GAAGV,KAAA;MACzCC,qBAAA,CAAsBJ,OAAO,GAAGc,UAAA;IAClC;IACA,OAAOV,qBAAA;EACT;EAEA,OAAOF,6BAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerContent.js","names":["c","_c","Form","FormSubmit","RenderFields","useConfig","useDocumentInfo","useFieldProps","useTranslation","getFormState","React","useCallback","useEffect","useState","v4","uuid","useEditorConfigContext","DrawerContent","t0","$","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPathSuffix","t","id","schemaPath","config","initialState","setInitialState","field","t1","richTextComponentMap","componentMapRenderedFieldsPath","schemaFieldsPath","t2","get","fields","t3","awaitInitialState","state","apiRoute","routes","api","body","operation","serverURL","t4","t5","t6","formState","prevFormState","onChange","t7","Array","isArray","t8","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","children","_jsx","forceRender","path","readOnly"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormProps } from '@payloadcms/ui'\nimport type { ClientField, FormState } from 'payload'\n\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useTranslation,\n} from '@payloadcms/ui'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id } = useDocumentInfo()\n const { schemaPath } = useFieldProps()\n const { config } = useConfig()\n const [initialState, setInitialState] = useState<
|
|
1
|
+
{"version":3,"file":"DrawerContent.js","names":["c","_c","Form","FormSubmit","RenderFields","useConfig","useDocumentInfo","useFieldProps","useTranslation","getFormState","React","useCallback","useEffect","useState","v4","uuid","useEditorConfigContext","DrawerContent","t0","$","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPathSuffix","t","id","schemaPath","config","initialState","setInitialState","field","t1","richTextComponentMap","componentMapRenderedFieldsPath","schemaFieldsPath","t2","get","fields","t3","awaitInitialState","state","apiRoute","routes","api","body","operation","serverURL","t4","t5","t6","formState","prevFormState","onChange","t7","Array","isArray","t8","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","children","_jsx","forceRender","path","readOnly"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormProps } from '@payloadcms/ui'\nimport type { ClientField, FormState } from 'payload'\n\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useTranslation,\n} from '@payloadcms/ui'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id } = useDocumentInfo()\n const { schemaPath } = useFieldProps()\n const { config } = useConfig()\n const [initialState, setInitialState] = useState<false | FormState>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `lexical_internal_feature.${featureKey}.fields${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any =\n fieldMapOverride ?? (richTextComponentMap.get(componentMapRenderedFieldsPath) as ClientField[]) // Field Schema\n\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: data ?? {},\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id, data])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n return await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id],\n )\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n path=\"\" // See Blocks feature path for details as for why this is empty\n readOnly={false}\n schemaPath={schemaFieldsPath}\n />\n\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SACEC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,cAAc,QACT;AACP,SAASC,YAAY,QAAQ;AAC7B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AACxD,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAAiFC,EAAA;EAAA,MAAAC,CAAA,GAAAlB,EAAA;EAAC;IAAAmB,IAAA;IAAAC,UAAA;IAAAC,gBAAA;IAAAC,kBAAA;IAAAC,wBAAA;IAAAC;EAAA,IAAAP,EAO9F;EACC;IAAAQ;EAAA,IAAclB,cAAA;EACd;IAAAmB;EAAA,IAAerB,eAAA;EACf;IAAAsB;EAAA,IAAuBrB,aAAA;EACvB;IAAAsB;EAAA,IAAmBxB,SAAA;EACnB,OAAAyB,YAAA,EAAAC,eAAA,IAAwClB,QAAA,MAA4B;EACpE;IAAAmB,KAAA,EAAAC;EAAA,IAEIjB,sBAAA;EADK;IAAAkB;EAAA,IAAAD,EAAwB;EAGjC,MAAAE,8BAAA,GAAuC,4BAA4Bd,UAAA,UAAoBI,gBAAA,GAAmB,IAAIA,gBAAA,EAAkB,GAAG,IAAI;EACvI,MAAAW,gBAAA,GACEZ,wBAAA,IACA,GAAGI,UAAA,6BAAuCP,UAAA,GAAaI,gBAAA,GAAmB,IAAIA,gBAAA,EAAkB,GAAG,IAAI;EAAA,I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AAA,GAAAF,KAAA,CAAAC,OAAA,CAAclB,MAAA,IAAUA,MAAA,KAAW;MAAApB,CAAA,OAAAoB,MAAA;MAAApB,CAAA,OAAAuC,EAAA;IAAA;MAAAA,EAAA,GAAAvC,CAAA;IAAA;IAV/CgC,EAAA,GAAAQ,KAAA,CAAAzD,IAAA;MAAA0D,YAAA,GACiBN,QAAA;MAAAO,yBAAA;MAAAtB,MAAA,EAEPgB,EAAmC;MAAAzB,YAAA;MAAAwB,QAAA,GAEhCA,QAAA;MAAAQ,QAAA,EACDvC,kBAAA;MAAAR,IAAA,EACJA,IAAA;MAAAgD,QAAA,GAENC,IAAA,CAAA5D,YAAA;QAAAmC,MAAA,EACUmB,EAAmC;QAAAO,WAAA;QAAAC,IAAA,EAEtC;QAAAC,QAAA;QAAAvC,UAAA,EAEOQ;MAAA,C,GAGd4B,IAAA,CAAA7D,UAAA;QAAA4D,QAAA,EAAarC,CAAA,CAAE;MAAA,C;;;;;;;;;;;;SAjBjByB,E;CAoBJ","ignoreList":[]}
|
package/dist/validate/index.js
CHANGED
|
@@ -36,8 +36,8 @@ export const richTextValidateHOC = ({
|
|
|
36
36
|
const rootNodes = value?.root?.children;
|
|
37
37
|
if (rootNodes && Array.isArray(rootNodes) && rootNodes?.length) {
|
|
38
38
|
return await validateNodes({
|
|
39
|
-
nodeValidations: editorConfig.features.validations,
|
|
40
39
|
nodes: rootNodes,
|
|
40
|
+
nodeValidations: editorConfig.features.validations,
|
|
41
41
|
validation: {
|
|
42
42
|
options,
|
|
43
43
|
value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["validateNodes","richTextValidateHOC","editorConfig","richTextValidate","value","options","req","t","required","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild","rootNodes","Array","isArray","nodeValidations","features","validations","
|
|
1
|
+
{"version":3,"file":"index.js","names":["validateNodes","richTextValidateHOC","editorConfig","richTextValidate","value","options","req","t","required","hasChildren","root","children","length","hasOnlyEmptyParagraph","type","paragraphNode","paragraphNodeChild","rootNodes","Array","isArray","nodes","nodeValidations","features","validations","validation"],"sources":["../../src/validate/index.ts"],"sourcesContent":["import type { SerializedEditorState, SerializedParagraphNode } from 'lexical'\nimport type { RichTextField, Validate } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\n\nimport { validateNodes } from './validateNodes.js'\n\nexport const richTextValidateHOC = ({\n editorConfig,\n}: {\n editorConfig: SanitizedServerEditorConfig\n}) => {\n const richTextValidate: Validate<SerializedEditorState, unknown, unknown, RichTextField> = async (\n value,\n options,\n ) => {\n const {\n req: { t },\n required,\n } = options\n\n if (required) {\n const hasChildren = !!value?.root?.children?.length\n\n let hasOnlyEmptyParagraph = false\n if (value?.root?.children?.length === 1) {\n if (value?.root?.children[0]?.type === 'paragraph') {\n const paragraphNode = value?.root?.children[0] as SerializedParagraphNode\n if (paragraphNode?.children?.length === 0) {\n hasOnlyEmptyParagraph = true\n } else if (paragraphNode?.children?.length === 1) {\n const paragraphNodeChild = paragraphNode?.children[0]\n if (paragraphNodeChild.type === 'text') {\n if (!paragraphNodeChild?.['text']?.length) {\n hasOnlyEmptyParagraph = true\n }\n }\n }\n }\n }\n\n if (!hasChildren || hasOnlyEmptyParagraph) {\n return t('validation:required')\n }\n }\n\n // Traverse through nodes and validate them. Just like a node can hook into the population process (e.g. link or relationship nodes),\n // they can also hook into the validation process. E.g. a block node probably has fields with validation rules.\n\n const rootNodes = value?.root?.children\n if (rootNodes && Array.isArray(rootNodes) && rootNodes?.length) {\n return await validateNodes({\n nodes: rootNodes,\n nodeValidations: editorConfig.features.validations,\n validation: {\n options,\n value,\n },\n })\n }\n\n return true\n }\n\n return richTextValidate\n}\n"],"mappings":"AAKA,SAASA,aAAa,QAAQ;AAE9B,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC;AAAY,CAGb;EACC,MAAMC,gBAAA,GAAqF,MAAAA,CACzFC,KAAA,EACAC,OAAA;I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,OAAO;EACT;EAEA,OAAOD,gBAAA;AACT","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import type { RichTextField, ValidateOptions } from 'payload';
|
|
3
3
|
import type { NodeValidation } from '../features/typesServer.js';
|
|
4
|
-
export declare function validateNodes({
|
|
5
|
-
nodeValidations: Map<string, Array<NodeValidation>>;
|
|
4
|
+
export declare function validateNodes({ nodes, nodeValidations, validation: validationFromProps, }: {
|
|
6
5
|
nodes: SerializedLexicalNode[];
|
|
6
|
+
nodeValidations: Map<string, Array<NodeValidation>>;
|
|
7
7
|
validation: {
|
|
8
8
|
options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>;
|
|
9
9
|
value: SerializedEditorState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateNodes.d.ts","sourceRoot":"","sources":["../../src/validate/validateNodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE,wBAAsB,aAAa,CAAC,EAClC,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"validateNodes.d.ts","sourceRoot":"","sources":["../../src/validate/validateNodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,eAAe,EACf,UAAU,EAAE,mBAAmB,GAChC,EAAE;IACD,KAAK,EAAE,qBAAqB,EAAE,CAAA;IAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAA;IACnD,UAAU,EAAE;QACV,OAAO,EAAE,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,qBAAqB,CAAC,CAAA;QAChF,KAAK,EAAE,qBAAqB,CAAA;KAC7B,CAAA;CACF,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmCzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export async function validateNodes({
|
|
2
|
-
nodeValidations,
|
|
3
2
|
nodes,
|
|
3
|
+
nodeValidations,
|
|
4
4
|
validation: validationFromProps
|
|
5
5
|
}) {
|
|
6
6
|
for (const node of nodes) {
|
|
@@ -21,8 +21,8 @@ export async function validateNodes({
|
|
|
21
21
|
// Validate node's children
|
|
22
22
|
if ('children' in node && node?.children) {
|
|
23
23
|
const childrenValidationResult = await validateNodes({
|
|
24
|
-
nodeValidations,
|
|
25
24
|
nodes: node.children,
|
|
25
|
+
nodeValidations,
|
|
26
26
|
validation: validationFromProps
|
|
27
27
|
});
|
|
28
28
|
if (childrenValidationResult !== true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateNodes.js","names":["validateNodes","
|
|
1
|
+
{"version":3,"file":"validateNodes.js","names":["validateNodes","nodes","nodeValidations","validation","validationFromProps","node","has","type","validations","get","validationResult","children","childrenValidationResult"],"sources":["../../src/validate/validateNodes.ts"],"sourcesContent":["import type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\nimport type { RichTextField, ValidateOptions } from 'payload'\n\nimport type { NodeValidation } from '../features/typesServer.js'\n\nexport async function validateNodes({\n nodes,\n nodeValidations,\n validation: validationFromProps,\n}: {\n nodes: SerializedLexicalNode[]\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>\n value: SerializedEditorState\n }\n}): Promise<string | true> {\n for (const node of nodes) {\n // Validate node\n if (\n nodeValidations &&\n typeof nodeValidations?.has === 'function' &&\n nodeValidations?.has(node.type)\n ) {\n const validations = nodeValidations.get(node.type)\n for (const validation of validations) {\n const validationResult = await validation({\n node,\n nodeValidations,\n validation: validationFromProps,\n })\n if (validationResult !== true) {\n return `${node.type} node failed to validate: ${validationResult}`\n }\n }\n }\n\n // Validate node's children\n if ('children' in node && node?.children) {\n const childrenValidationResult = await validateNodes({\n nodes: node.children as SerializedLexicalNode[],\n nodeValidations,\n validation: validationFromProps,\n })\n if (childrenValidationResult !== true) {\n return childrenValidationResult\n }\n }\n }\n\n return true\n}\n"],"mappings":"AAKA,OAAO,eAAeA,cAAc;EAClCC,KAAK;EACLC,eAAe;EACfC,UAAA,EAAYC;AAAmB,CAQhC;EACC,KAAK,MAAMC,IAAA,IAAQJ,KAAA,EAAO;IACxB;IACA,IACEC,eAAA,IACA,OAAOA,eAAA,EAAiBI,GAAA,KAAQ,cAChCJ,eAAA,EAAiBI,GAAA,CAAID,IAAA,CAAKE,IAAI,GAC9B;MACA,MAAMC,WAAA,GAAcN,eAAA,CAAgBO,GAAG,CAACJ,IAAA,CAAKE,IAAI;MACjD,KAAK,MAAMJ,UAAA,IAAcK,WAAA,EAAa;QACpC,MAAME,gBAAA,GAAmB,MAAMP,UAAA,CAAW;UACxCE,IAAA;UACAH,eAAA;UACAC,UAAA,EAAYC;QACd;QACA,IAAIM,gBAAA,KAAqB,MAAM;UAC7B,OAAO,GAAGL,IAAA,CAAKE,IAAI,6BAA6BG,gBAAA,EAAkB;QACpE;MACF;IACF;IAEA;IACA,IAAI,cAAcL,IAAA,IAAQA,IAAA,EAAMM,QAAA,EAAU;MACxC,MAAMC,wBAAA,GAA2B,MAAMZ,aAAA,CAAc;QACnDC,KAAA,EAAOI,IAAA,CAAKM,QAAQ;QACpBT,eAAA;QACAC,UAAA,EAAYC;MACd;MACA,IAAIQ,wBAAA,KAA6B,MAAM;QACrC,OAAOA,wBAAA;MACT;IACF;EACF;EAEA,OAAO;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.97",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"lexical": "0.17.0",
|
|
57
57
|
"react-error-boundary": "4.0.13",
|
|
58
58
|
"uuid": "10.0.0",
|
|
59
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
60
|
-
"@payloadcms/ui": "3.0.0-beta.
|
|
59
|
+
"@payloadcms/translations": "3.0.0-beta.97",
|
|
60
|
+
"@payloadcms/ui": "3.0.0-beta.97"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@babel/cli": "^7.24.5",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"esbuild-sass-plugin": "3.3.1",
|
|
78
78
|
"eslint-plugin-react-compiler": "0.0.0-experimental-72f06b2-20240822",
|
|
79
79
|
"swc-plugin-transform-remove-imports": "1.15.0",
|
|
80
|
-
"payload": "3.0.0-beta.
|
|
80
|
+
"payload": "3.0.0-beta.97",
|
|
81
81
|
"@payloadcms/eslint-config": "3.0.0-beta.59"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"lexical": "0.17.0",
|
|
97
97
|
"react": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
|
|
98
98
|
"react-dom": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
|
|
99
|
-
"@payloadcms/next": "3.0.0-beta.
|
|
100
|
-
"payload": "3.0.0-beta.
|
|
99
|
+
"@payloadcms/next": "3.0.0-beta.97",
|
|
100
|
+
"payload": "3.0.0-beta.97"
|
|
101
101
|
},
|
|
102
102
|
"engines": {
|
|
103
103
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -120,6 +120,8 @@
|
|
|
120
120
|
"build:without_reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm copyfiles && pnpm build:types && pnpm build:swc && pnpm build:esbuild && rm -rf dist/exports/client && mv dist/exports/client_unoptimized dist/exports/client",
|
|
121
121
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
122
122
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
123
|
+
"lint": "eslint .",
|
|
124
|
+
"lint:fix": "eslint . --fix",
|
|
123
125
|
"translateNewKeys": "node --no-deprecation --import @swc-node/register/esm-register scripts/translateNewKeys.ts"
|
|
124
126
|
}
|
|
125
127
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as ue,b as pe,c as ge,d as he,e as z,f as I,h as ye}from"./chunk-YSI2QILQ.js";import{a as fe,b as T}from"./chunk-OLSILJA6.js";import{jsx as j,jsxs as me}from"react/jsx-runtime";import{FieldDescription as Yt,FieldError as Ut,FieldLabel as Vt,useField as qt,useFieldProps as Jt,withCondition as Qt}from"@payloadcms/ui";import{useCallback as Xt}from"react";import{ErrorBoundary as Zt}from"react-error-boundary";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Wt}from"@lexical/react/LexicalComposer.js";import*as qe from"react";import{useMemo as Ve}from"react";import{c as Bt}from"react/compiler-runtime";import{jsx as P,jsxs as J}from"react/jsx-runtime";import{useLexicalComposerContext as Mt}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as It}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as At}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Ft}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Dt}from"@lexical/react/LexicalRichTextPlugin.js";import{TabIndentationPlugin as Ot}from"@lexical/react/LexicalTabIndentationPlugin.js";import{BLUR_COMMAND as _t,COMMAND_PRIORITY_LOW as Ge,FOCUS_COMMAND as Ht}from"lexical";import*as U from"react";import{useEffect as We,useState as Ye}from"react";import{jsx as xe}from"react/jsx-runtime";import"react";var _=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"?o.Component&&xe(o.Component,{anchorElem:t,clientProps:e}):o.Component&&xe(o.Component,{clientProps:e});import{c as Xe}from"react/compiler-runtime";import{jsx as Ze}from"react/jsx-runtime";import{MarkdownShortcutPlugin as et}from"@lexical/react/LexicalMarkdownShortcutPlugin.js";import"react";var Ee=()=>{let t=Xe(2),{editorConfig:e}=T(),o;return t[0]!==e.features.markdownTransformers?(o=Ze(et,{transformers:e.features.markdownTransformers}),t[0]=e.features.markdownTransformers,t[1]=o):o=t[1],o};import{jsx as K,jsxs as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as ot}from"@lexical/react/LexicalComposerContext.js";import{useFieldProps as Pe,useTranslation as we}from"@payloadcms/ui";import{useCallback as Ce,useMemo as nt,useState as rt}from"react";import"react";import*as ke from"react-dom";import{c as tt}from"react/compiler-runtime";import"react";function be(t,e){let o=tt(4),{maxLength:l,minLength:r}=e,m=l===void 0?75:l,p=r===void 0?1:r,a;return o[0]!==t||o[1]!==m||o[2]!==p?(a=u=>{let{query:g}=u,E="[^"+t+pe+"\\s]",s=new RegExp("(^|\\s|\\()(["+t+"]((?:"+E+"){0,"+m+"}))$").exec(g);if(s!==null){let n=s[1],y=s[3];if(y.length>=p)return{leadOffset:s.index+n.length,matchingString:y,replaceableString:s[2]}}return null},o[0]=t,o[1]=m,o[2]=p,o[3]=a):a=o[3],a}var L="slash-menu-popup";function it({isSelected:t,item:e,onClick:o,onMouseEnter:l}){let{field:{richTextComponentMap:r}}=T(),{schemaPath:m}=Pe(),{i18n:p}=we(),a=`${L}__item ${L}__item-${e.key}`;t&&(a+=` ${L}__item--selected`);let u=e.key;return e.label&&(u=typeof e.label=="function"?e.label({i18n:p,richTextComponentMap:r,schemaPath:m}):e.label),u.length>25&&(u=u.substring(0,25)+"..."),Ne("button",{"aria-selected":t,className:a,id:L+"__item-"+e.key,onClick:o,onMouseEnter:l,ref:g=>{e.ref={current:g}},role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&K(e.Icon,{}),K("span",{className:`${L}__item-text`,children:u})]},e.key)}function Re({anchorElem:t=document.body}){let[e]=ot(),[o,l]=rt(null),{editorConfig:r}=T(),{i18n:m}=we(),{field:{richTextComponentMap:p}}=T(),{schemaPath:a}=Pe(),u=be("/",{minLength:0}),g=Ce(()=>{let s=[];for(let n of r.features.slashMenu.dynamicGroups){let y=n({editor:e,queryString:o});s=s.concat(y)}return s},[e,o,r?.features]),E=nt(()=>{let s=[];for(let n of r?.features.slashMenu.groups??[])s.push(n);if(o){s=s.map(y=>{let h=y.items.filter(c=>{let f=c.key;return c.label&&(f=typeof c.label=="function"?c.label({i18n:m,richTextComponentMap:p,schemaPath:a}):c.label),new RegExp(o,"gi").exec(f)?!0:c.keywords!=null?c.keywords.some(i=>new RegExp(o,"gi").exec(i)):!1});return h.length?{...y,items:h}:null}),s=s.filter(y=>y!=null);let n=g();for(let y of n){let h=s.find(c=>c.key===y.key);h?s=s.filter(c=>c.key!==y.key):h={...y,items:[]},h?.items?.length&&(h.items=h.items.concat(h.items)),s.push(h)}}return s},[g,o,r?.features,m]),d=Ce((s,n,y,h)=>{n&&e.update(()=>{n.remove()}),s.onSelect({editor:e,queryString:h}),y()},[e]);return K(he,{anchorElem:t,groups:E,menuRenderFn:(s,{selectItemAndCleanUp:n,selectedItemKey:y,setSelectedItemKey:h})=>s.current&&E.length?ke.createPortal(K("div",{className:L,children:E.map(c=>{let f=c.key;return c.label&&(f=typeof c.label=="function"?c.label({i18n:m,richTextComponentMap:p,schemaPath:a}):c.label),Ne("div",{className:`${L}__group ${L}__group-${c.key}`,children:[K("div",{className:`${L}__group-title`,children:f}),c.items.map((i,x)=>K(it,{index:x,isSelected:y===i.key,item:i,onClick:()=>{h(i.key),n(i)},onMouseEnter:()=>{h(i.key)}},i.key))]},c.key)})}),s.current):null,onQueryChange:l,onSelectItem:d,triggerFn:u})}import{jsx as ce}from"react/jsx-runtime";import{useLexicalComposerContext as mt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as ut}from"lexical";import*as Le from"react";import{useCallback as ft,useEffect as ve,useRef as pt,useState as gt}from"react";import{createPortal as ht}from"react-dom";var G=(t,e,o,l,r=50,m=25)=>{let p=0;if(t&&!t.contains(l)){let{bottom:a,left:u,right:g,top:E}=t.getBoundingClientRect(),d=E+window.scrollY,s=a+window.scrollY;if(o<d-m||o>s+m||e<u-r||e>g+r)return-1;(e<u||e>g)&&(p=e<u?e-u:e-g)}return p};import{$getNodeByKey as Z}from"lexical";function W(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let l=o.split(",").pop();return e.y=e.y-Number(l.replace(")","")),e}function X(t){let e=(u,g)=>u?parseFloat(window.getComputedStyle(u)[g]):0,{marginBottom:o,marginTop:l}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),p=Math.max(parseFloat(l),r);return{marginBottom:Math.max(parseFloat(o),m),marginTop:p}}import{$getRoot as st}from"lexical";function H(t){return t.getEditorState().read(()=>st().getChildrenKeys())}var lt=1,at=-1,Te=0,B={props:null,result:null};function ct(t,e,o=20){let l=t.x-e.x,r=t.y-e.y;return l*l+r*r<=o*o}function Y(t){let{anchorElem:e,cache_threshold:o=20,editor:l,fuzzy:r=!1,horizontalOffset:m=0,point:{x:p,y:a},startIndex:u=0,useEdgeAsDefault:g=!1,verbose:E=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&ct(B.props.point,t.point,o))return B.result;let d=e.getBoundingClientRect(),s=H(l),n={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return l.getEditorState().read(()=>{if(g){let[c,f]=[l.getElementByKey(s[0]),l.getElementByKey(s[s.length-1])],[i,x]=[W(c),W(f)];if(i&&x&&(a<i.top?(n.blockElem=c,n.distance=i.top-a,n.blockNode=Z(s[0]),n.foundAtIndex=0):a>x.bottom&&(n.distance=a-x.bottom,n.blockNode=Z(s[s.length-1]),n.blockElem=f,n.foundAtIndex=s.length-1),n?.blockElem))return{blockElem:null,isFoundNodeEmptyParagraph:!1}}let y=u,h=Te;for(;y>=0&&y<s.length;){let c=s[y],f=l.getElementByKey(c);if(f===null)break;let i=new I(p+m,a),x=ye.fromDOMRect(W(f)),{marginBottom:b,marginTop:C}=X(f),w=x.generateNewRect({bottom:x.bottom+b,left:d.left,right:d.right,top:x.top-C}),{distance:R,isOnBottomSide:N,isOnTopSide:F}=w.distanceFromPoint(i);if(R===0){n.blockElem=f,n.blockNode=Z(c),n.foundAtIndex=y,n.distance=R,n.blockNode&&n.blockNode.getType()==="paragraph"&&n.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(n.blockElem=null,n.blockNode=null),n.isFoundNodeEmptyParagraph=!0);break}else r&&R<n.distance&&(n.blockElem=f,n.blockNode=Z(c),n.distance=R,n.foundAtIndex=y);h===Te&&(F?h=at:N?h=lt:h=1/0),y+=h}}),B.props=t,B.result={blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph},{blockElem:n.blockElem,blockNode:n.blockNode,foundAtIndex:n.foundAtIndex,isFoundNodeEmptyParagraph:n.isFoundNodeEmptyParagraph}}function ee(t,e){return!!t.closest(`.${e}`)}var dt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Se(t){if(!t||dt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function te(t,e,o,l=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),p=e.getBoundingClientRect(),a=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(d=>t.firstElementChild?.classList.contains(d)))u=r.top+8-a.top;else{let d=Se(t)?parseInt(m.lineHeight,10):0;u=r.top+(d-p.height)/2-a.top}let E=l;e.style.opacity="1",e.style.transform=`translate(${E}px, ${u}px)`}var yt="add-block-menu",oe=1/0;function xt(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function Et(t,e,o){let l=e.parentElement,{editorConfig:r}=T(),m=r?.admin?.hideGutter?-24:12,p=pt(null),[a,u]=gt(null);ve(()=>{function E(d){let s=d.target;if(!z(s))return;let n=G(l,d.pageX,d.pageY,s);if(n===-1){u(null);return}if(ee(s,yt))return;let y=H(t),{blockElem:h,blockNode:c,foundAtIndex:f}=Y({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-n,point:new I(d.x,d.y),returnEmptyParagraphs:!0,startIndex:xt(y.length),useEdgeAsDefault:!1});oe=f,h&&(a?.node!==c||a?.elem!==h)&&u({elem:h,node:c})}return document?.addEventListener("mousemove",E),()=>{document?.removeEventListener("mousemove",E)}},[l,e,t,a]),ve(()=>{p.current&&a?.node&&te(a?.elem,p.current,e,m)},[e,a,m]);let g=ft(E=>{let d=a;d?.node&&(t.update(()=>{let s=!0;if((d.node.getType()!=="paragraph"||d.node.getTextContent()!=="")&&(s=!1),!s){let n=ut();d.node.insertAfter(n),setTimeout(()=>{d={elem:t.getElementByKey(n.getKey()),node:n},u(d)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),d.node&&"select"in d.node&&typeof d.node.select=="function"&&d.node.select()})},1),setTimeout(()=>{t.dispatchCommand(ge,{node:d.node})},2),E.stopPropagation(),E.preventDefault())},[t,a]);return ht(ce(Le.Fragment,{children:ce("button",{className:"icon add-block-menu",onClick:E=>{g(E)},ref:p,type:"button",children:ce("div",{className:o?"icon":""})})}),e)}function Be({anchorElem:t=document.body}){let[e]=mt();return Et(e,t,e._editable)}import{jsx as ne,jsxs as Ct}from"react/jsx-runtime";import{useLexicalComposerContext as Nt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ae}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Fe,$getNodeByKey as Pt}from"lexical";import*as $e from"react";import{useEffect as de,useRef as re,useState as De}from"react";import{createPortal as wt}from"react-dom";var Me=0,bt=-24;var $=0;function Ie(t,e,o,l,r,m,p,a,u,g=!1){let{height:E,top:d}=l.getBoundingClientRect(),{top:s,width:n}=p.getBoundingClientRect(),{marginBottom:y,marginTop:h}=X(l),c=d,f=m>=d+E/2+window.scrollY,i=!1;if(r?.elem)if(l!==r?.elem)(f&&r?.elem&&r?.elem===l.nextElementSibling||!f&&r?.elem&&r?.elem===l.previousElementSibling)&&($++,$<200&&(i=!0));else{$++;let w=r?.boundingBox?.y,R=l.getBoundingClientRect().y;(f===r?.isBelow&&w===R||$<200)&&(i=!1)}if(i)return{isBelow:f,willStayInSamePosition:i};g?c+=E/2:f?c+=E+y/2:c-=h/2;let x=0;g||(f?x=-Me:x=Me);let b=c-s+x,C=bt-e;return o.style.width=`calc(${n}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${C}px, calc(${b}px - 2px))`,r.elem.style.opacity="",r?.elem===l?f?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop=""),$=0,{isBelow:f,willStayInSamePosition:i}}var kt="draggable-block-menu",Oe="application/x-lexical-drag-block",q=1/0;function _e(t){return t===0?1/0:q>=0&&q<t?q:Math.floor(t/2)}function Rt(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function He(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Tt(t,e,o){let l=e.parentElement,r=re(null),m=re(null),p=re(null),a=re(!1),[u,g]=De(null),[E,d]=De(null),{editorConfig:s}=T(),n=s?.admin?.hideGutter?-44:-8;de(()=>{function c(f){let i=f.target;if(!z(i))return;let x=G(l,f.pageX,f.pageY,i);if(x===-1){g(null);return}if(ee(i,kt))return;let b=H(t),{blockElem:C,foundAtIndex:w,isFoundNodeEmptyParagraph:R}=Y({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-x,point:new I(f.x,f.y),startIndex:_e(b.length),useEdgeAsDefault:!1,verbose:!1});q=w,!(!C&&!R)&&u!==C&&g(C)}return document?.addEventListener("mousemove",c),()=>{document?.removeEventListener("mousemove",c)}},[l,e,t,u]),de(()=>{r.current&&te(u,r.current,e,n)},[e,u,n]),de(()=>{function c(i){if(!a.current)return!1;let[x]=Ae(i);if(x)return!1;let{pageY:b,target:C}=i;if(!z(C))return!1;let w=G(l,i.pageX,i.pageY,C,100,50),R=H(t),{blockElem:N,foundAtIndex:F,isFoundNodeEmptyParagraph:D}=Y({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-w,point:new I(i.x,i.y),startIndex:_e(R.length),useEdgeAsDefault:!0,verbose:!0});q=F;let S=m.current;if(N===null||S===null)return!1;if(u!==N){let{isBelow:v,willStayInSamePosition:V}=Ie(s?.admin?.hideGutter?"0px":"3rem",n+(s?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),S,N,E,b,e,i,p,D);i.preventDefault(),V||d({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:v})}else He(S,E?.elem),d({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1});return!0}function f(i){if(!a.current)return!1;let[x]=Ae(i);if(x)return!1;let{dataTransfer:b,pageY:C,target:w}=i,R=b?.getData(Oe)||"";return t.update(()=>{let N=Pt(R);if(!N||!z(w))return!1;let F=G(l,i.pageX,i.pageY,w,100,50),{blockElem:D,isFoundNodeEmptyParagraph:S}=Y({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-F,point:new I(i.x,i.y),useEdgeAsDefault:!0});if(!D)return!1;let v=Fe(D);if(!v)return!1;if(v===N)return!0;let{height:V,top:se}=W(D),ae=C>=se+V/2+window.scrollY;S?(v.insertBefore(N),v.remove()):ae?v.insertAfter(N):v.insertBefore(N),u!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(M=>{M.remove()});let O=t.getElementByKey(N.getKey());setTimeout(()=>{let M=O.getBoundingClientRect(),k=document.createElement("div");k.className="lexical-block-highlighter",k.style.backgroundColor="var(--theme-elevation-1000",k.style.transition="opacity 0.5s ease-in-out",k.style.zIndex="1",k.style.pointerEvents="none",k.style.boxSizing="border-box",k.style.borderRadius="4px",k.style.position="absolute",document.body.appendChild(k),k.style.opacity="0.1",k.style.height=`${M.height+8}px`,k.style.width=`${M.width+8}px`,k.style.top=`${M.top+window.scrollY-4}px`,k.style.left=`${M.left-4}px`,setTimeout(()=>{k.style.opacity="0",setTimeout(()=>{k.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",c),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",c),document.removeEventListener("drop",f)}},[l,n,e,t,E,u,s?.admin?.hideGutter]);function y(c){let f=c.dataTransfer;if(!f||!u)return;Rt(f,u);let i="";t.update(()=>{let x=Fe(u);x&&(i=x.getKey())}),a.current=!0,f.setData(Oe,i)}function h(){a.current=!1,He(m.current,E?.elem)}return wt(Ct($e.Fragment,{children:[ne("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:h,onDragStart:y,ref:r,children:ne("div",{className:o?"icon":""})}),ne("div",{className:"draggable-block-target-line",ref:m}),ne("div",{className:"debug-highlight",ref:p})]}),e)}function je({anchorElem:t=document.body}){let[e]=Nt();return Tt(e,t,e._editable)}import{c as St}from"react/compiler-runtime";import{jsx as ze}from"react/jsx-runtime";import{ContentEditable as vt}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Lt}from"@payloadcms/ui";import"react";function Ke(t){let e=St(3),{className:o}=t,{t:l}=Lt(),r;return e[0]!==l||e[1]!==o?(r=ze(vt,{"aria-placeholder":l("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:ze("p",{className:"editor-placeholder",children:l("lexical:general:placeholder")})}),e[0]=l,e[1]=o,e[2]=r):r=e[2],r}var Ue=t=>{let e=Bt(22),{editorConfig:o,editorContainerRef:l,onChange:r}=t,m=T(),[p]=Mt(),[a,u]=Ye(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=i=>{i!==null&&u(i)},e[0]=g):g=e[0];let E=g,d,s;e[1]!==m||e[2]!==p?(d=()=>{if(!m?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}m?.parentEditor?.uuid&&m.parentEditor?.registerChild(m.uuid,m);let i=()=>{m.focusEditor(m)},x=()=>{m.blurEditor(m)},b=p.registerCommand(Ht,()=>(i(),!0),Ge),C=p.registerCommand(_t,()=>(x(),!0),Ge);return()=>{b(),C(),m.parentEditor?.unregisterChild?.(m.uuid)}},s=[p,m],e[1]=m,e[2]=p,e[3]=d,e[4]=s):(d=e[3],s=e[4]),We(d,s);let[n,y]=Ye(!1),h,c;e[5]!==n?(h=()=>{let i=()=>{let x=window.matchMedia("(max-width: 768px)").matches;x!==n&&y(x)};return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},c=[n],e[5]=n,e[6]=h,e[7]=c):(h=e[6],c=e[7]),We(h,c);let f;if(e[8]!==o.features||e[9]!==r||e[10]!==a||e[11]!==n||e[12]!==p||e[13]!==l){let i;e[15]!==r?(i=(b,C,w)=>{(!w.has("focus")||w.size>1)&&r?.(b,C,w)},e[15]=r,e[16]=i):i=e[16];let x;e[17]!==a||e[18]!==n||e[19]!==p||e[20]!==o?(x=a&&J(U.Fragment,{children:[!n&&p.isEditable()&&J(U.Fragment,{children:[P(je,{anchorElem:a}),P(Be,{anchorElem:a})]}),o.features.plugins.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&n))return P(_,{anchorElem:a,clientProps:b.clientProps,plugin:b},b.key)}),p.isEditable()&&P(U.Fragment,{children:P(Re,{anchorElem:a})})]}),e[17]=a,e[18]=n,e[19]=p,e[20]=o,e[21]=x):x=e[21],f=J(U.Fragment,{children:[o.features.plugins.map($t),J("div",{className:"editor-container",ref:l,children:[o.features.plugins.map(jt),P(Dt,{ErrorBoundary:It,contentEditable:P("div",{className:"editor-scroller",children:P("div",{className:"editor",ref:E,children:P(Ke,{})})})}),P(Ft,{ignoreSelectionChange:!0,onChange:i}),x,p.isEditable()&&J(U.Fragment,{children:[P(At,{}),o?.features?.markdownTransformers?.length>0&&P(Ee,{})]}),P(Ot,{}),o.features.plugins.map(zt),o.features.plugins.map(Kt)]}),o.features.plugins.map(Gt)]}),e[8]=o.features,e[9]=r,e[10]=a,e[11]=n,e[12]=p,e[13]=l,e[14]=f}else f=e[14];return f};function $t(t){if(t.position==="aboveContainer")return P(_,{clientProps:t.clientProps,plugin:t},t.key)}function jt(t){if(t.position==="top")return P(_,{clientProps:t.clientProps,plugin:t},t.key)}function zt(t){if(t.position==="normal")return P(_,{clientProps:t.clientProps,plugin:t},t.key)}function Kt(t){if(t.position==="bottom")return P(_,{clientProps:t.clientProps,plugin:t},t.key)}function Gt(t){if(t.position==="belowContainer")return P(_,{clientProps:t.clientProps,plugin:t},t.key)}var Je=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Je,{providers:e.slice(1),children:t})}):A(o,{children:t})},Qe=t=>{let{editorConfig:e,field:o,onChange:l,path:r,readOnly:m,value:p}=t,a=T(),u=qe.useRef(null),g=Ve(()=>{let d=p;return e?.features?.hooks?.load?.length&&e.features.hooks.load.forEach(s=>{d=s({incomingEditorState:d})}),d},[e,p]),E=Ve(()=>{if(g&&typeof g!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(g));if(g&&Array.isArray(g)&&!("root"in g))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/beta/lexical/migration#migration-via-migration-script-recommended");if(g&&"jsonContent"in g)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/beta/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:m!==!0,editorState:g!=null?JSON.stringify(g):void 0,namespace:e.lexical.namespace,nodes:[...ue({editorConfig:e})],onError:d=>{throw d},theme:e.lexical.theme}},[e,g,m]);return E?A(Wt,{initialConfig:E,children:A(fe,{editorConfig:e,editorContainerRef:u,field:o,parentContext:a,children:A(Je,{providers:e.features.providers,children:A(Ue,{editorConfig:e,editorContainerRef:u,onChange:l})})})},r):A("p",{children:"Loading..."})};import"./bundled.css";var ie="rich-text-lexical",eo=t=>{let{descriptionProps:e,editorConfig:o,errorProps:l,field:{name:r,_path:m,admin:{className:p,components:{Description:a,Error:u,Label:g},readOnly:E,style:d,width:s}={},label:n,required:y},field:h,labelProps:c,readOnly:f,validate:i}=t,x=f||E,b=Xt((Q,O)=>{if(typeof i=="function")return i(Q,{...O,props:t,required:y})},[i,y]),{path:C,readOnly:w}=Jt(),R=qt({path:C??m??r,validate:b}),{formInitializing:N,formProcessing:F,initialValue:D,path:S,setValue:v,showError:V,value:se}=R,le=x||w||F||N,ae=[ie,"field-type",p,V&&"error",le&&`${ie}--read-only`,o?.admin?.hideGutter!==!0?`${ie}--show-gutter`:null].filter(Boolean).join(" ");return me("div",{className:ae,style:{...d,width:s},children:[j(Ut,{CustomError:u,field:h,path:S,...l||{},alignCaret:"left"}),j(Vt,{Label:g,field:h,label:n,required:y,...c||{}}),me("div",{className:`${ie}__wrap`,children:[j(Zt,{fallbackRender:to,onReset:()=>{},children:j(Qe,{editorConfig:o,field:h,onChange:Q=>{let O=Q.toJSON();o?.features?.hooks?.save?.length&&o.features.hooks.save.forEach(M=>{O=M({incomingEditorState:O})}),v(O)},path:S,readOnly:le,value:se},JSON.stringify({initialValue:D,path:S}))}),j(Yt,{Description:a,field:h,...e||{}})]})]},S)};function to({error:t}){return me("div",{className:"errorBoundary",role:"alert",children:[j("p",{children:"Something went wrong:"}),j("pre",{style:{color:"red"},children:t.message})]})}var ar=Qt(eo);export{ar as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-SUWHJ4HF.js.map
|