@payloadcms/richtext-lexical 3.15.0 → 3.15.2-canary.36e50dd
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/index.js +1 -1
- package/dist/exports/client/index.js.map +2 -2
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts +1 -1
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts.map +1 -1
- package/dist/utilities/jsx/lexicalMarkdownCopy.js +1 -1
- package/dist/utilities/jsx/lexicalMarkdownCopy.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ElementNode } from 'lexical';
|
|
2
2
|
import type { Transformer } from '../../packages/@lexical/markdown/index.js';
|
|
3
|
-
export declare function normalizeMarkdown(input: string, shouldMergeAdjacentLines
|
|
3
|
+
export declare function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string;
|
|
4
4
|
/**
|
|
5
5
|
* Renders markdown from a string. The selection is moved to the start after the operation.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicalMarkdownCopy.d.ts","sourceRoot":"","sources":["../../../src/utilities/jsx/lexicalMarkdownCopy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,KAAK,EAEV,WAAW,EACZ,MAAM,2CAA2C,CAAA;AAuBlD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"lexicalMarkdownCopy.d.ts","sourceRoot":"","sources":["../../../src/utilities/jsx/lexicalMarkdownCopy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,KAAK,EAEV,WAAW,EACZ,MAAM,2CAA2C,CAAA;AAuBlD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO,GAAG,MAAM,CA6D1F;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,KAAK,CAAC,WAAW,CAAgB,EAC/C,IAAI,CAAC,EAAE,WAAW,EAClB,sBAAsB,UAAQ,EAC9B,wBAAwB,UAAO,GAC9B,IAAI,CAMN"}
|
|
@@ -14,7 +14,7 @@ const TABLE_ROW_REG_EXP = /^\|(.+)\|\s?$/;
|
|
|
14
14
|
const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
|
|
15
15
|
const TAG_START_REGEX = /^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i;
|
|
16
16
|
const TAG_END_REGEX = /^[ \t]*<\/[a-z_][\w-]*\s*>/i;
|
|
17
|
-
export function normalizeMarkdown(input, shouldMergeAdjacentLines
|
|
17
|
+
export function normalizeMarkdown(input, shouldMergeAdjacentLines) {
|
|
18
18
|
const lines = input.split('\n');
|
|
19
19
|
let inCodeBlock = false;
|
|
20
20
|
const sanitizedLines = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicalMarkdownCopy.js","names":["$convertFromMarkdownString","$originalConvertFromMarkdownString","TRANSFORMERS","EMPTY_OR_WHITESPACE_ONLY","ORDERED_LIST_REGEX","UNORDERED_LIST_REGEX","CHECK_LIST_REGEX","HEADING_REGEX","QUOTE_REGEX","CODE_START_REGEX","CODE_END_REGEX","CODE_SINGLE_LINE_REGEX","TABLE_ROW_REG_EXP","TABLE_ROW_DIVIDER_REG_EXP","TAG_START_REGEX","TAG_END_REGEX","normalizeMarkdown","input","shouldMergeAdjacentLines","lines","split","inCodeBlock","sanitizedLines","i","length","line","lastLine","test","push","trim","join","markdown","transformers","node","shouldPreserveNewLines","sanitizedMarkdown"],"sources":["../../../src/utilities/jsx/lexicalMarkdownCopy.ts"],"sourcesContent":["/* eslint-disable regexp/no-unused-capturing-group */\n\nimport type { ElementNode } from 'lexical'\n\nimport type {\n MultilineElementTransformer as _MultilineElementTransformer,\n Transformer,\n} from '../../packages/@lexical/markdown/index.js'\n\nimport {\n $convertFromMarkdownString as $originalConvertFromMarkdownString,\n TRANSFORMERS,\n} from '../../packages/@lexical/markdown/index.js'\n\nconst EMPTY_OR_WHITESPACE_ONLY = /^[\\t ]*$/\nconst ORDERED_LIST_REGEX = /^(\\s*)(\\d+)\\.\\s/\nconst UNORDERED_LIST_REGEX = /^(\\s*)[-*+]\\s/\nconst CHECK_LIST_REGEX = /^(\\s*)(?:-\\s)?\\s?(\\[(\\s|x)?\\])\\s/i\nconst HEADING_REGEX = /^(#{1,6})\\s/\nconst QUOTE_REGEX = /^>\\s/\n// Match start of ``` or escaped \\`\\`\\` code blocks\nconst CODE_START_REGEX = /^[ \\t]*(\\\\`\\\\`\\\\`|```)(\\w+)?/\n// Match end of ``` or escaped \\`\\`\\` code blocks\nconst CODE_END_REGEX = /[ \\t]*(\\\\`\\\\`\\\\`|```)$/\nconst CODE_SINGLE_LINE_REGEX = /^[ \\t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/\nconst TABLE_ROW_REG_EXP = /^\\|(.+)\\|\\s?$/\nconst TABLE_ROW_DIVIDER_REG_EXP = /^(\\| ?:?-*:? ?)+\\|\\s?$/\nconst TAG_START_REGEX = /^[ \\t]*<[a-z_][\\w-]*(?:\\s[^<>]*)?\\/?>/i\nconst TAG_END_REGEX = /^[ \\t]*<\\/[a-z_][\\w-]*\\s*>/i\n\nexport function normalizeMarkdown(input: string, shouldMergeAdjacentLines
|
|
1
|
+
{"version":3,"file":"lexicalMarkdownCopy.js","names":["$convertFromMarkdownString","$originalConvertFromMarkdownString","TRANSFORMERS","EMPTY_OR_WHITESPACE_ONLY","ORDERED_LIST_REGEX","UNORDERED_LIST_REGEX","CHECK_LIST_REGEX","HEADING_REGEX","QUOTE_REGEX","CODE_START_REGEX","CODE_END_REGEX","CODE_SINGLE_LINE_REGEX","TABLE_ROW_REG_EXP","TABLE_ROW_DIVIDER_REG_EXP","TAG_START_REGEX","TAG_END_REGEX","normalizeMarkdown","input","shouldMergeAdjacentLines","lines","split","inCodeBlock","sanitizedLines","i","length","line","lastLine","test","push","trim","join","markdown","transformers","node","shouldPreserveNewLines","sanitizedMarkdown"],"sources":["../../../src/utilities/jsx/lexicalMarkdownCopy.ts"],"sourcesContent":["/* eslint-disable regexp/no-unused-capturing-group */\n\nimport type { ElementNode } from 'lexical'\n\nimport type {\n MultilineElementTransformer as _MultilineElementTransformer,\n Transformer,\n} from '../../packages/@lexical/markdown/index.js'\n\nimport {\n $convertFromMarkdownString as $originalConvertFromMarkdownString,\n TRANSFORMERS,\n} from '../../packages/@lexical/markdown/index.js'\n\nconst EMPTY_OR_WHITESPACE_ONLY = /^[\\t ]*$/\nconst ORDERED_LIST_REGEX = /^(\\s*)(\\d+)\\.\\s/\nconst UNORDERED_LIST_REGEX = /^(\\s*)[-*+]\\s/\nconst CHECK_LIST_REGEX = /^(\\s*)(?:-\\s)?\\s?(\\[(\\s|x)?\\])\\s/i\nconst HEADING_REGEX = /^(#{1,6})\\s/\nconst QUOTE_REGEX = /^>\\s/\n// Match start of ``` or escaped \\`\\`\\` code blocks\nconst CODE_START_REGEX = /^[ \\t]*(\\\\`\\\\`\\\\`|```)(\\w+)?/\n// Match end of ``` or escaped \\`\\`\\` code blocks\nconst CODE_END_REGEX = /[ \\t]*(\\\\`\\\\`\\\\`|```)$/\nconst CODE_SINGLE_LINE_REGEX = /^[ \\t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/\nconst TABLE_ROW_REG_EXP = /^\\|(.+)\\|\\s?$/\nconst TABLE_ROW_DIVIDER_REG_EXP = /^(\\| ?:?-*:? ?)+\\|\\s?$/\nconst TAG_START_REGEX = /^[ \\t]*<[a-z_][\\w-]*(?:\\s[^<>]*)?\\/?>/i\nconst TAG_END_REGEX = /^[ \\t]*<\\/[a-z_][\\w-]*\\s*>/i\n\nexport function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string {\n const lines = input.split('\\n')\n let inCodeBlock = false\n const sanitizedLines: string[] = []\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]\n const lastLine = sanitizedLines[sanitizedLines.length - 1]\n\n // Code blocks of ```single line``` don't toggle the inCodeBlock flag\n if (CODE_SINGLE_LINE_REGEX.test(line)) {\n sanitizedLines.push(line)\n continue\n }\n\n // Toggle inCodeBlock state when encountering start or end of a code block\n if (CODE_START_REGEX.test(line)) {\n inCodeBlock = true\n sanitizedLines.push(line)\n continue\n }\n\n if (CODE_END_REGEX.test(line)) {\n inCodeBlock = false\n sanitizedLines.push(line)\n continue\n }\n\n // If we are inside a code block, keep the line unchanged\n if (inCodeBlock) {\n sanitizedLines.push(line)\n continue\n }\n\n // In markdown the concept of \"empty paragraphs\" does not exist.\n // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.\n if (\n EMPTY_OR_WHITESPACE_ONLY.test(line) ||\n EMPTY_OR_WHITESPACE_ONLY.test(lastLine) ||\n !lastLine ||\n HEADING_REGEX.test(lastLine) ||\n HEADING_REGEX.test(line) ||\n QUOTE_REGEX.test(line) ||\n ORDERED_LIST_REGEX.test(line) ||\n UNORDERED_LIST_REGEX.test(line) ||\n CHECK_LIST_REGEX.test(line) ||\n TABLE_ROW_REG_EXP.test(line) ||\n TABLE_ROW_DIVIDER_REG_EXP.test(line) ||\n !shouldMergeAdjacentLines ||\n TAG_START_REGEX.test(line) ||\n TAG_END_REGEX.test(line) ||\n TAG_START_REGEX.test(lastLine) ||\n TAG_END_REGEX.test(lastLine)\n ) {\n sanitizedLines.push(line)\n } else {\n sanitizedLines[sanitizedLines.length - 1] = lastLine + ' ' + line.trim()\n }\n }\n\n return sanitizedLines.join('\\n')\n}\n\n/**\n * Renders markdown from a string. The selection is moved to the start after the operation.\n *\n * @param {boolean} [shouldPreserveNewLines] By setting this to true, new lines will be preserved between conversions\n * @param {boolean} [shouldMergeAdjacentLines] By setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.\n */\nexport function $convertFromMarkdownString(\n markdown: string,\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines = false,\n shouldMergeAdjacentLines = true,\n): void {\n const sanitizedMarkdown = shouldPreserveNewLines\n ? markdown\n : normalizeMarkdown(markdown, shouldMergeAdjacentLines)\n\n return $originalConvertFromMarkdownString(sanitizedMarkdown, transformers, node) // shouldPreserveNewLines to true, as we do our own, modified markdown normalization here.\n}\n"],"mappings":"AAAA,qDASA,SACEA,0BAAA,IAA8BC,kCAAkC,EAChEC,YAAY,QACP;AAEP,MAAMC,wBAAA,GAA2B;AACjC,MAAMC,kBAAA,GAAqB;AAC3B,MAAMC,oBAAA,GAAuB;AAC7B,MAAMC,gBAAA,GAAmB;AACzB,MAAMC,aAAA,GAAgB;AACtB,MAAMC,WAAA,GAAc;AACpB;AACA,MAAMC,gBAAA,GAAmB;AACzB;AACA,MAAMC,cAAA,GAAiB;AACvB,MAAMC,sBAAA,GAAyB;AAC/B,MAAMC,iBAAA,GAAoB;AAC1B,MAAMC,yBAAA,GAA4B;AAClC,MAAMC,eAAA,GAAkB;AACxB,MAAMC,aAAA,GAAgB;AAEtB,OAAO,SAASC,kBAAkBC,KAAa,EAAEC,wBAAiC;EAChF,MAAMC,KAAA,GAAQF,KAAA,CAAMG,KAAK,CAAC;EAC1B,IAAIC,WAAA,GAAc;EAClB,MAAMC,cAAA,GAA2B,EAAE;EAEnC,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIJ,KAAA,CAAMK,MAAM,EAAED,CAAA,IAAK;IACrC,MAAME,IAAA,GAAON,KAAK,CAACI,CAAA,CAAE;IACrB,MAAMG,QAAA,GAAWJ,cAAc,CAACA,cAAA,CAAeE,MAAM,GAAG,EAAE;IAE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F;EAEA,OAAOP,cAAA,CAAeQ,IAAI,CAAC;AAC7B;AAEA;;;;;;AAMA,OAAO,SAAS9B,2BACd+B,QAAgB,EAChBC,YAAA,GAAmC9B,YAAY,EAC/C+B,IAAkB,EAClBC,sBAAA,GAAyB,KAAK,EAC9BhB,wBAAA,GAA2B,IAAI;EAE/B,MAAMiB,iBAAA,GAAoBD,sBAAA,GACtBH,QAAA,GACAf,iBAAA,CAAkBe,QAAA,EAAUb,wBAAA;EAEhC,OAAOjB,kCAAA,CAAmCkC,iBAAA,EAAmBH,YAAA,EAAcC,IAAA,EAAM;EAAA;AACnF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.2-canary.36e50dd",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -352,8 +352,8 @@
|
|
|
352
352
|
"react-error-boundary": "4.1.2",
|
|
353
353
|
"ts-essentials": "10.0.3",
|
|
354
354
|
"uuid": "10.0.0",
|
|
355
|
-
"@payloadcms/translations": "3.15.
|
|
356
|
-
"@payloadcms/ui": "3.15.
|
|
355
|
+
"@payloadcms/translations": "3.15.2-canary.36e50dd",
|
|
356
|
+
"@payloadcms/ui": "3.15.2-canary.36e50dd"
|
|
357
357
|
},
|
|
358
358
|
"devDependencies": {
|
|
359
359
|
"@babel/cli": "7.25.9",
|
|
@@ -373,8 +373,8 @@
|
|
|
373
373
|
"esbuild-sass-plugin": "3.3.1",
|
|
374
374
|
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
|
|
375
375
|
"swc-plugin-transform-remove-imports": "2.0.0",
|
|
376
|
-
"
|
|
377
|
-
"
|
|
376
|
+
"payload": "3.15.2-canary.36e50dd",
|
|
377
|
+
"@payloadcms/eslint-config": "3.9.0"
|
|
378
378
|
},
|
|
379
379
|
"peerDependencies": {
|
|
380
380
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
@@ -392,8 +392,8 @@
|
|
|
392
392
|
"lexical": "0.20.0",
|
|
393
393
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
394
394
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
395
|
-
"@payloadcms/next": "3.15.
|
|
396
|
-
"payload": "3.15.
|
|
395
|
+
"@payloadcms/next": "3.15.2-canary.36e50dd",
|
|
396
|
+
"payload": "3.15.2-canary.36e50dd"
|
|
397
397
|
},
|
|
398
398
|
"engines": {
|
|
399
399
|
"node": "^18.20.2 || >=20.9.0"
|