@payloadcms/richtext-lexical 3.60.0-canary.10 → 3.60.0-canary.12
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/bundled.css +1 -1
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/converters/lexicalToHtml_deprecated/converter/index.d.ts +10 -1
- package/dist/features/converters/lexicalToHtml_deprecated/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml_deprecated/converter/index.js +10 -1
- package/dist/features/converters/lexicalToHtml_deprecated/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToHtml_deprecated/index.d.ts +2 -1
- package/dist/features/converters/lexicalToHtml_deprecated/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml_deprecated/index.js +2 -1
- package/dist/features/converters/lexicalToHtml_deprecated/index.js.map +1 -1
- package/dist/features/lists/checklist/client/index.d.ts.map +1 -1
- package/dist/features/lists/checklist/client/index.js +4 -2
- package/dist/features/lists/checklist/client/index.js.map +1 -1
- package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
- package/dist/features/lists/checklist/server/index.js +3 -2
- package/dist/features/lists/checklist/server/index.js.map +1 -1
- package/dist/features/lists/orderedList/client/index.d.ts.map +1 -1
- package/dist/features/lists/orderedList/client/index.js +5 -3
- package/dist/features/lists/orderedList/client/index.js.map +1 -1
- package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
- package/dist/features/lists/orderedList/server/index.js +3 -2
- package/dist/features/lists/orderedList/server/index.js.map +1 -1
- package/dist/features/lists/shared/shouldRegisterListBaseNodes.d.ts +2 -0
- package/dist/features/lists/shared/shouldRegisterListBaseNodes.d.ts.map +1 -0
- package/dist/features/lists/shared/shouldRegisterListBaseNodes.js +14 -0
- package/dist/features/lists/shared/shouldRegisterListBaseNodes.js.map +1 -0
- package/dist/features/textState/feature.client.js +9 -7
- package/dist/features/textState/feature.client.js.map +1 -1
- package/dist/features/textState/textState.d.ts +11 -5
- package/dist/features/textState/textState.d.ts.map +1 -1
- package/dist/features/textState/textState.js +6 -3
- package/dist/features/textState/textState.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/package.json +7 -7
|
@@ -38,7 +38,16 @@ export type ConvertLexicalToHTMLArgs = {
|
|
|
38
38
|
req?: null | undefined;
|
|
39
39
|
});
|
|
40
40
|
/**
|
|
41
|
-
* @deprecated - will be removed in 4.0
|
|
41
|
+
* @deprecated - will be removed in 4.0. Use the function exported from `@payloadcms/richtext-lexical/html` instead.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // old (deprecated)
|
|
45
|
+
* import { convertLexicalToHTML } from '@payloadcms/richtext-lexical'
|
|
46
|
+
* // new (recommended)
|
|
47
|
+
* import { convertLexicalToHTML } from '@payloadcms/richtext-lexical/html'
|
|
48
|
+
* ```
|
|
49
|
+
* For more details, you can refer to https://payloadcms.com/docs/rich-text/converting-html to see all the
|
|
50
|
+
* ways to convert lexical to HTML.
|
|
42
51
|
*/
|
|
43
52
|
export declare function convertLexicalToHTML({ converters, currentDepth, data, depth, draft, overrideAccess, payload, req, showHiddenFields, }: ConvertLexicalToHTMLArgs): Promise<string>;
|
|
44
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/converter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAIhF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,qBAAqB,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,CACA;IACE;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAA;IACf;;;;;OAKG;IACH,GAAG,EAAE,cAAc,CAAA;CACpB,GACD;IACE;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CACJ,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/converter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAIhF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,qBAAqB,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,CACA;IACE;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAA;IACf;;;;;OAKG;IACH,GAAG,EAAE,cAAc,CAAA;CACpB,GACD;IACE;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CACJ,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,UAAU,EACV,YAAY,EACZ,IAAI,EACJ,KAAK,EACL,KAAK,EACL,cAAc,EACd,OAAO,EACP,GAAG,EACH,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2B5C;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,EAC9C,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,cAAc,EACd,MAAM,EACN,GAAG,EACH,gBAAgB,GACjB,EAAE;IACD,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,qBAAqB,EAAE,CAAA;IACrC,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,+BAA+B,CAAA;IACvC;;OAEG;IACH,GAAG,EAAE,IAAI,GAAG,cAAc,CAAA;IAC1B,gBAAgB,EAAE,OAAO,CAAA;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CA8ClB"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { createLocalReq } from 'payload';
|
|
2
2
|
import { hasText } from '../../../../validate/hasText.js';
|
|
3
3
|
/**
|
|
4
|
-
* @deprecated - will be removed in 4.0
|
|
4
|
+
* @deprecated - will be removed in 4.0. Use the function exported from `@payloadcms/richtext-lexical/html` instead.
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* // old (deprecated)
|
|
8
|
+
* import { convertLexicalToHTML } from '@payloadcms/richtext-lexical'
|
|
9
|
+
* // new (recommended)
|
|
10
|
+
* import { convertLexicalToHTML } from '@payloadcms/richtext-lexical/html'
|
|
11
|
+
* ```
|
|
12
|
+
* For more details, you can refer to https://payloadcms.com/docs/rich-text/converting-html to see all the
|
|
13
|
+
* ways to convert lexical to HTML.
|
|
5
14
|
*/
|
|
6
15
|
export async function convertLexicalToHTML({
|
|
7
16
|
converters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createLocalReq","hasText","convertLexicalToHTML","converters","currentDepth","data","depth","draft","overrideAccess","payload","req","showHiddenFields","undefined","config","defaultDepth","convertLexicalNodesToHTML","lexicalNodes","root","children","parent","unknownConverter","find","converter","nodeTypes","includes","htmlArray","Promise","all","map","node","i","converterForNode","type","childIndex","error","console","join"],"sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/converter/index.ts"],"sourcesContent":["import type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport { createLocalReq } from 'payload'\n\nimport type { HTMLConverter, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { hasText } from '../../../../validate/hasText.js'\n\n/**\n * @deprecated - will be removed in 4.0\n */\nexport type ConvertLexicalToHTMLArgs = {\n converters: HTMLConverter[]\n currentDepth?: number\n data: SerializedEditorState\n depth?: number\n draft?: boolean // default false\n overrideAccess?: boolean // default false\n showHiddenFields?: boolean // default false\n} & (\n | {\n /**\n * This payload property will only be used if req is undefined.\n */\n payload?: never\n /**\n * When the converter is called, req CAN be passed in depending on where it's run.\n * If this is undefined and config is passed through, lexical will create a new req object for you. If this is null or\n * config is undefined, lexical will not create a new req object for you and local API / server-side-only\n * functionality will be disabled.\n */\n req: PayloadRequest\n }\n | {\n /**\n * This payload property will only be used if req is undefined.\n */\n payload?: Payload\n /**\n * When the converter is called, req CAN be passed in depending on where it's run.\n * If this is undefined and config is passed through, lexical will create a new req object for you. If this is null or\n * config is undefined, lexical will not create a new req object for you and local API / server-side-only\n * functionality will be disabled.\n */\n req?: null | undefined\n }\n)\n\n/**\n * @deprecated - will be removed in 4.0\n */\nexport async function convertLexicalToHTML({\n converters,\n currentDepth,\n data,\n depth,\n draft,\n overrideAccess,\n payload,\n req,\n showHiddenFields,\n}: ConvertLexicalToHTMLArgs): Promise<string> {\n if (hasText(data)) {\n if (req === undefined && payload) {\n req = await createLocalReq({}, payload)\n }\n\n if (!currentDepth) {\n currentDepth = 0\n }\n\n if (!depth) {\n depth = req?.payload?.config?.defaultDepth\n }\n\n return await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth: depth!,\n draft: draft === undefined ? false : draft,\n lexicalNodes: data?.root?.children,\n overrideAccess: overrideAccess === undefined ? false : overrideAccess,\n parent: data?.root,\n req: req!,\n showHiddenFields: showHiddenFields === undefined ? false : showHiddenFields,\n })\n }\n return ''\n}\n\n/**\n * @deprecated - will be removed in 4.0\n */\nexport async function convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n}: {\n converters: HTMLConverter[]\n currentDepth: number\n depth: number\n draft: boolean\n lexicalNodes: SerializedLexicalNode[]\n overrideAccess: boolean\n parent: SerializedLexicalNodeWithParent\n /**\n * When the converter is called, req CAN be passed in depending on where it's run.\n */\n req: null | PayloadRequest\n showHiddenFields: boolean\n}): Promise<string> {\n const unknownConverter = converters.find((converter) => converter.nodeTypes.includes('unknown'))\n\n const htmlArray = await Promise.all(\n lexicalNodes.map(async (node, i) => {\n const converterForNode = converters.find((converter) =>\n converter.nodeTypes.includes(node.type),\n )\n try {\n if (!converterForNode) {\n if (unknownConverter) {\n return await unknownConverter.converter({\n childIndex: i,\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n })\n }\n return '<span>unknown node</span>'\n }\n return await converterForNode.converter({\n childIndex: i,\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n })\n } catch (error) {\n console.error('Error converting lexical node to HTML:', error, 'node:', node)\n return ''\n }\n }),\n )\n\n return htmlArray.join('') || ''\n}\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAI/B,SAASC,OAAO,QAAQ;AA0CxB
|
|
1
|
+
{"version":3,"file":"index.js","names":["createLocalReq","hasText","convertLexicalToHTML","converters","currentDepth","data","depth","draft","overrideAccess","payload","req","showHiddenFields","undefined","config","defaultDepth","convertLexicalNodesToHTML","lexicalNodes","root","children","parent","unknownConverter","find","converter","nodeTypes","includes","htmlArray","Promise","all","map","node","i","converterForNode","type","childIndex","error","console","join"],"sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/converter/index.ts"],"sourcesContent":["import type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport { createLocalReq } from 'payload'\n\nimport type { HTMLConverter, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { hasText } from '../../../../validate/hasText.js'\n\n/**\n * @deprecated - will be removed in 4.0\n */\nexport type ConvertLexicalToHTMLArgs = {\n converters: HTMLConverter[]\n currentDepth?: number\n data: SerializedEditorState\n depth?: number\n draft?: boolean // default false\n overrideAccess?: boolean // default false\n showHiddenFields?: boolean // default false\n} & (\n | {\n /**\n * This payload property will only be used if req is undefined.\n */\n payload?: never\n /**\n * When the converter is called, req CAN be passed in depending on where it's run.\n * If this is undefined and config is passed through, lexical will create a new req object for you. If this is null or\n * config is undefined, lexical will not create a new req object for you and local API / server-side-only\n * functionality will be disabled.\n */\n req: PayloadRequest\n }\n | {\n /**\n * This payload property will only be used if req is undefined.\n */\n payload?: Payload\n /**\n * When the converter is called, req CAN be passed in depending on where it's run.\n * If this is undefined and config is passed through, lexical will create a new req object for you. If this is null or\n * config is undefined, lexical will not create a new req object for you and local API / server-side-only\n * functionality will be disabled.\n */\n req?: null | undefined\n }\n)\n\n/**\n * @deprecated - will be removed in 4.0. Use the function exported from `@payloadcms/richtext-lexical/html` instead.\n * @example\n * ```ts\n * // old (deprecated)\n * import { convertLexicalToHTML } from '@payloadcms/richtext-lexical'\n * // new (recommended)\n * import { convertLexicalToHTML } from '@payloadcms/richtext-lexical/html'\n * ```\n * For more details, you can refer to https://payloadcms.com/docs/rich-text/converting-html to see all the\n * ways to convert lexical to HTML.\n */\nexport async function convertLexicalToHTML({\n converters,\n currentDepth,\n data,\n depth,\n draft,\n overrideAccess,\n payload,\n req,\n showHiddenFields,\n}: ConvertLexicalToHTMLArgs): Promise<string> {\n if (hasText(data)) {\n if (req === undefined && payload) {\n req = await createLocalReq({}, payload)\n }\n\n if (!currentDepth) {\n currentDepth = 0\n }\n\n if (!depth) {\n depth = req?.payload?.config?.defaultDepth\n }\n\n return await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth: depth!,\n draft: draft === undefined ? false : draft,\n lexicalNodes: data?.root?.children,\n overrideAccess: overrideAccess === undefined ? false : overrideAccess,\n parent: data?.root,\n req: req!,\n showHiddenFields: showHiddenFields === undefined ? false : showHiddenFields,\n })\n }\n return ''\n}\n\n/**\n * @deprecated - will be removed in 4.0\n */\nexport async function convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n}: {\n converters: HTMLConverter[]\n currentDepth: number\n depth: number\n draft: boolean\n lexicalNodes: SerializedLexicalNode[]\n overrideAccess: boolean\n parent: SerializedLexicalNodeWithParent\n /**\n * When the converter is called, req CAN be passed in depending on where it's run.\n */\n req: null | PayloadRequest\n showHiddenFields: boolean\n}): Promise<string> {\n const unknownConverter = converters.find((converter) => converter.nodeTypes.includes('unknown'))\n\n const htmlArray = await Promise.all(\n lexicalNodes.map(async (node, i) => {\n const converterForNode = converters.find((converter) =>\n converter.nodeTypes.includes(node.type),\n )\n try {\n if (!converterForNode) {\n if (unknownConverter) {\n return await unknownConverter.converter({\n childIndex: i,\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n })\n }\n return '<span>unknown node</span>'\n }\n return await converterForNode.converter({\n childIndex: i,\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n })\n } catch (error) {\n console.error('Error converting lexical node to HTML:', error, 'node:', node)\n return ''\n }\n }),\n )\n\n return htmlArray.join('') || ''\n}\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAI/B,SAASC,OAAO,QAAQ;AA0CxB;;;;;;;;;;;;AAYA,OAAO,eAAeC,qBAAqB;EACzCC,UAAU;EACVC,YAAY;EACZC,IAAI;EACJC,KAAK;EACLC,KAAK;EACLC,cAAc;EACdC,OAAO;EACPC,GAAG;EACHC;AAAgB,CACS;EACzB,IAAIV,OAAA,CAAQI,IAAA,GAAO;IACjB,IAAIK,GAAA,KAAQE,SAAA,IAAaH,OAAA,EAAS;MAChCC,GAAA,GAAM,MAAMV,cAAA,CAAe,CAAC,GAAGS,OAAA;IACjC;IAEA,IAAI,CAACL,YAAA,EAAc;MACjBA,YAAA,GAAe;IACjB;IAEA,IAAI,CAACE,KAAA,EAAO;MACVA,KAAA,GAAQI,GAAA,EAAKD,OAAA,EAASI,MAAA,EAAQC,YAAA;IAChC;IAEA,OAAO,MAAMC,yBAAA,CAA0B;MACrCZ,UAAA;MACAC,YAAA;MACAE,KAAA,EAAOA,KAAA;MACPC,KAAA,EAAOA,KAAA,KAAUK,SAAA,GAAY,QAAQL,KAAA;MACrCS,YAAA,EAAcX,IAAA,EAAMY,IAAA,EAAMC,QAAA;MAC1BV,cAAA,EAAgBA,cAAA,KAAmBI,SAAA,GAAY,QAAQJ,cAAA;MACvDW,MAAA,EAAQd,IAAA,EAAMY,IAAA;MACdP,GAAA,EAAKA,GAAA;MACLC,gBAAA,EAAkBA,gBAAA,KAAqBC,SAAA,GAAY,QAAQD;IAC7D;EACF;EACA,OAAO;AACT;AAEA;;;AAGA,OAAO,eAAeI,0BAA0B;EAC9CZ,UAAU;EACVC,YAAY;EACZE,KAAK;EACLC,KAAK;EACLS,YAAY;EACZR,cAAc;EACdW,MAAM;EACNT,GAAG;EACHC;AAAgB,CAcjB;EACC,MAAMS,gBAAA,GAAmBjB,UAAA,CAAWkB,IAAI,CAAEC,SAAA,IAAcA,SAAA,CAAUC,SAAS,CAACC,QAAQ,CAAC;EAErF,MAAMC,SAAA,GAAY,MAAMC,OAAA,CAAQC,GAAG,CACjCX,YAAA,CAAaY,GAAG,CAAC,OAAOC,IAAA,EAAMC,CAAA;IAC5B,MAAMC,gBAAA,GAAmB5B,UAAA,CAAWkB,IAAI,CAAEC,SAAA,IACxCA,SAAA,CAAUC,SAAS,CAACC,QAAQ,CAACK,IAAA,CAAKG,IAAI;IAExC,IAAI;MACF,IAAI,CAACD,gBAAA,EAAkB;QACrB,IAAIX,gBAAA,EAAkB;UACpB,OAAO,MAAMA,gBAAA,CAAiBE,SAAS,CAAC;YACtCW,UAAA,EAAYH,CAAA;YACZ3B,UAAA;YACAC,YAAA;YACAE,KAAA;YACAC,KAAA;YACAsB,IAAA;YACArB,cAAA;YACAW,MAAA;YACAT,GAAA;YACAC;UACF;QACF;QACA,OAAO;MACT;MACA,OAAO,MAAMoB,gBAAA,CAAiBT,SAAS,CAAC;QACtCW,UAAA,EAAYH,CAAA;QACZ3B,UAAA;QACAC,YAAA;QACAE,KAAA;QACAC,KAAA;QACAsB,IAAA;QACArB,cAAA;QACAW,MAAA;QACAT,GAAA;QACAC;MACF;IACF,EAAE,OAAOuB,KAAA,EAAO;MACdC,OAAA,CAAQD,KAAK,CAAC,0CAA0CA,KAAA,EAAO,SAASL,IAAA;MACxE,OAAO;IACT;EACF;EAGF,OAAOJ,SAAA,CAAUW,IAAI,CAAC,OAAO;AAC/B","ignoreList":[]}
|
|
@@ -5,7 +5,8 @@ export type HTMLConverterFeatureProps = {
|
|
|
5
5
|
}) => HTMLConverter<any>[]) | HTMLConverter<any>[];
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* @deprecated - will be removed in 4.0
|
|
8
|
+
* @deprecated - will be removed in 4.0. Please refer to https://payloadcms.com/docs/rich-text/converting-html
|
|
9
|
+
* to see all the ways to convert lexical to HTML.
|
|
9
10
|
*/
|
|
10
11
|
export declare const HTMLConverterFeature: import("../../typesServer.js").FeatureProviderProviderServer<HTMLConverterFeatureProps, HTMLConverterFeatureProps, undefined>;
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/converters/lexicalToHtml_deprecated/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAIzD,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,CAAC,EACP,CAAC,CAAC,EAAE,iBAAiB,EAAE,EAAE;QAAE,iBAAiB,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,CAAA;KAAE,KAAK,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,GAC9F,aAAa,CAAC,GAAG,CAAC,EAAE,CAAA;CACzB,CAAA;AAGD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/converters/lexicalToHtml_deprecated/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAIzD,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,CAAC,EACP,CAAC,CAAC,EAAE,iBAAiB,EAAE,EAAE;QAAE,iBAAiB,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,CAAA;KAAE,KAAK,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,GAC9F,aAAa,CAAC,GAAG,CAAC,EAAE,CAAA;CACzB,CAAA;AAGD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+HAG/B,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createServerFeature } from '../../../utilities/createServerFeature.js';
|
|
2
2
|
// This is just used to save the props on the richText field
|
|
3
3
|
/**
|
|
4
|
-
* @deprecated - will be removed in 4.0
|
|
4
|
+
* @deprecated - will be removed in 4.0. Please refer to https://payloadcms.com/docs/rich-text/converting-html
|
|
5
|
+
* to see all the ways to convert lexical to HTML.
|
|
5
6
|
*/
|
|
6
7
|
export const HTMLConverterFeature = createServerFeature({
|
|
7
8
|
feature: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createServerFeature","HTMLConverterFeature","feature","key"],"sources":["../../../../src/features/converters/lexicalToHtml_deprecated/index.ts"],"sourcesContent":["import type { HTMLConverter } from './converter/types.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\n\nexport type HTMLConverterFeatureProps = {\n converters?:\n | (({ defaultConverters }: { defaultConverters: HTMLConverter<any>[] }) => HTMLConverter<any>[])\n | HTMLConverter<any>[]\n}\n\n// This is just used to save the props on the richText field\n/**\n * @deprecated - will be removed in 4.0\n */\nexport const HTMLConverterFeature = createServerFeature<HTMLConverterFeatureProps>({\n feature: {},\n key: 'htmlConverter',\n})\n"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ;AAQpC;AACA
|
|
1
|
+
{"version":3,"file":"index.js","names":["createServerFeature","HTMLConverterFeature","feature","key"],"sources":["../../../../src/features/converters/lexicalToHtml_deprecated/index.ts"],"sourcesContent":["import type { HTMLConverter } from './converter/types.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\n\nexport type HTMLConverterFeatureProps = {\n converters?:\n | (({ defaultConverters }: { defaultConverters: HTMLConverter<any>[] }) => HTMLConverter<any>[])\n | HTMLConverter<any>[]\n}\n\n// This is just used to save the props on the richText field\n/**\n * @deprecated - will be removed in 4.0. Please refer to https://payloadcms.com/docs/rich-text/converting-html\n * to see all the ways to convert lexical to HTML.\n */\nexport const HTMLConverterFeature = createServerFeature<HTMLConverterFeatureProps>({\n feature: {},\n key: 'htmlConverter',\n})\n"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ;AAQpC;AACA;;;;AAIA,OAAO,MAAMC,oBAAA,GAAuBD,mBAAA,CAA+C;EACjFE,OAAA,EAAS,CAAC;EACVC,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/checklist/client/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/checklist/client/index.tsx"],"names":[],"mappings":"AAyDA,eAAO,MAAM,sBAAsB,uFA4CjC,CAAA"}
|
|
@@ -6,6 +6,7 @@ import { ChecklistIcon } from '../../../../lexical/ui/icons/Checklist/index.js';
|
|
|
6
6
|
import { createClientFeature } from '../../../../utilities/createClientFeature.js';
|
|
7
7
|
import { toolbarTextDropdownGroupWithItems } from '../../../shared/toolbar/textDropdownGroup.js';
|
|
8
8
|
import { LexicalListPlugin } from '../../plugin/index.js';
|
|
9
|
+
import { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js';
|
|
9
10
|
import { slashMenuListGroupWithItems } from '../../shared/slashMenuListGroup.js';
|
|
10
11
|
import { CHECK_LIST } from '../markdownTransformers.js';
|
|
11
12
|
import { LexicalCheckListPlugin } from './plugin/index.js';
|
|
@@ -54,7 +55,8 @@ export const ChecklistFeatureClient = createClientFeature(({
|
|
|
54
55
|
Component: LexicalCheckListPlugin,
|
|
55
56
|
position: 'normal'
|
|
56
57
|
}];
|
|
57
|
-
|
|
58
|
+
const shouldRegister = shouldRegisterListBaseNodes('checklist', featureProviderMap);
|
|
59
|
+
if (shouldRegister) {
|
|
58
60
|
plugins.push({
|
|
59
61
|
Component: LexicalListPlugin,
|
|
60
62
|
position: 'normal'
|
|
@@ -62,7 +64,7 @@ export const ChecklistFeatureClient = createClientFeature(({
|
|
|
62
64
|
}
|
|
63
65
|
return {
|
|
64
66
|
markdownTransformers: [CHECK_LIST],
|
|
65
|
-
nodes:
|
|
67
|
+
nodes: shouldRegister ? [ListNode, ListItemNode] : [],
|
|
66
68
|
plugins,
|
|
67
69
|
slashMenu: {
|
|
68
70
|
groups: [slashMenuListGroupWithItems([{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["$isListNode","INSERT_CHECK_LIST_COMMAND","ListItemNode","ListNode","$isRangeSelection","ChecklistIcon","createClientFeature","toolbarTextDropdownGroupWithItems","LexicalListPlugin","slashMenuListGroupWithItems","CHECK_LIST","LexicalCheckListPlugin","toolbarGroups","ChildComponent","isActive","selection","node","getNodes","getListType","parent","getParent","parentParent","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","ChecklistFeatureClient","featureProviderMap","plugins","Component","position","
|
|
1
|
+
{"version":3,"file":"index.js","names":["$isListNode","INSERT_CHECK_LIST_COMMAND","ListItemNode","ListNode","$isRangeSelection","ChecklistIcon","createClientFeature","toolbarTextDropdownGroupWithItems","LexicalListPlugin","shouldRegisterListBaseNodes","slashMenuListGroupWithItems","CHECK_LIST","LexicalCheckListPlugin","toolbarGroups","ChildComponent","isActive","selection","node","getNodes","getListType","parent","getParent","parentParent","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","ChecklistFeatureClient","featureProviderMap","plugins","Component","position","shouldRegister","push","markdownTransformers","nodes","slashMenu","groups","Icon","keywords","toolbarFixed","toolbarInline"],"sources":["../../../../../src/features/lists/checklist/client/index.tsx"],"sourcesContent":["'use client'\nimport { $isListNode, INSERT_CHECK_LIST_COMMAND, ListItemNode, ListNode } from '@lexical/list'\nimport { $isRangeSelection } from 'lexical'\n\nimport type { ToolbarGroup } from '../../../toolbars/types.js'\nimport type { ClientFeature } from '../../../typesClient.js'\n\nimport { ChecklistIcon } from '../../../../lexical/ui/icons/Checklist/index.js'\nimport { createClientFeature } from '../../../../utilities/createClientFeature.js'\nimport { toolbarTextDropdownGroupWithItems } from '../../../shared/toolbar/textDropdownGroup.js'\nimport { LexicalListPlugin } from '../../plugin/index.js'\nimport { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js'\nimport { slashMenuListGroupWithItems } from '../../shared/slashMenuListGroup.js'\nimport { CHECK_LIST } from '../markdownTransformers.js'\nimport { LexicalCheckListPlugin } from './plugin/index.js'\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarTextDropdownGroupWithItems([\n {\n ChildComponent: ChecklistIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isListNode(node) && node.getListType() === 'check') {\n continue\n }\n\n const parent = node.getParent()\n\n if ($isListNode(parent) && parent.getListType() === 'check') {\n continue\n }\n\n const parentParent = parent?.getParent()\n // Example scenario: Node = textNode, parent = listItemNode, parentParent = listNode\n if ($isListNode(parentParent) && parentParent.getListType() === 'check') {\n continue\n }\n\n return false\n }\n return true\n },\n key: 'checklist',\n label: ({ i18n }) => {\n return i18n.t('lexical:checklist:label')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined)\n },\n order: 12,\n },\n ]),\n]\n\nexport const ChecklistFeatureClient = createClientFeature(({ featureProviderMap }) => {\n const plugins: ClientFeature<undefined>['plugins'] = [\n {\n Component: LexicalCheckListPlugin,\n position: 'normal',\n },\n ]\n\n const shouldRegister = shouldRegisterListBaseNodes('checklist', featureProviderMap)\n if (shouldRegister) {\n plugins.push({\n Component: LexicalListPlugin,\n position: 'normal',\n })\n }\n\n return {\n markdownTransformers: [CHECK_LIST],\n nodes: shouldRegister ? [ListNode, ListItemNode] : [],\n plugins,\n slashMenu: {\n groups: [\n slashMenuListGroupWithItems([\n {\n Icon: ChecklistIcon,\n key: 'checklist',\n keywords: ['check list', 'check', 'checklist', 'cl'],\n label: ({ i18n }) => {\n return i18n.t('lexical:checklist:label')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined)\n },\n },\n ]),\n ],\n },\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n }\n})\n"],"mappings":"AAAA;;AACA,SAASA,WAAW,EAAEC,yBAAyB,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AAC/E,SAASC,iBAAiB,QAAQ;AAKlC,SAASC,aAAa,QAAQ;AAC9B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iCAAiC,QAAQ;AAClD,SAASC,iBAAiB,QAAQ;AAClC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,UAAU,QAAQ;AAC3B,SAASC,sBAAsB,QAAQ;AAEvC,MAAMC,aAAA,GAAgC,CACpCN,iCAAA,CAAkC,CAChC;EACEO,cAAA,EAAgBT,aAAA;EAChBU,QAAA,EAAUA,CAAC;IAAEC;EAAS,CAAE;IACtB,IAAI,CAACZ,iBAAA,CAAkBY,SAAA,GAAY;MACjC,OAAO;IACT;IACA,KAAK,MAAMC,IAAA,IAAQD,SAAA,CAAUE,QAAQ,IAAI;MACvC,IAAIlB,WAAA,CAAYiB,IAAA,KAASA,IAAA,CAAKE,WAAW,OAAO,SAAS;QACvD;MACF;MAEA,MAAMC,MAAA,GAASH,IAAA,CAAKI,SAAS;MAE7B,IAAIrB,WAAA,CAAYoB,MAAA,KAAWA,MAAA,CAAOD,WAAW,OAAO,SAAS;QAC3D;MACF;MAEA,MAAMG,YAAA,GAAeF,MAAA,EAAQC,SAAA;MAC7B;MACA,IAAIrB,WAAA,CAAYsB,YAAA,KAAiBA,YAAA,CAAaH,WAAW,OAAO,SAAS;QACvE;MACF;MAEA,OAAO;IACT;IACA,OAAO;EACT;EACAI,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;EAChB;EACAC,QAAA,EAAUA,CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC,eAAe,CAAC5B,yBAAA,EAA2B6B,SAAA;EACpD;EACAC,KAAA,EAAO;AACT,EACD,EACF;AAED,OAAO,MAAMC,sBAAA,GAAyB1B,mBAAA,CAAoB,CAAC;EAAE2B;AAAkB,CAAE;EAC/E,MAAMC,OAAA,GAA+C,CACnD;IACEC,SAAA,EAAWvB,sBAAA;IACXwB,QAAA,EAAU;EACZ,EACD;EAED,MAAMC,cAAA,GAAiB5B,2BAAA,CAA4B,aAAawB,kBAAA;EAChE,IAAII,cAAA,EAAgB;IAClBH,OAAA,CAAQI,IAAI,CAAC;MACXH,SAAA,EAAW3B,iBAAA;MACX4B,QAAA,EAAU;IACZ;EACF;EAEA,OAAO;IACLG,oBAAA,EAAsB,CAAC5B,UAAA,CAAW;IAClC6B,KAAA,EAAOH,cAAA,GAAiB,CAAClC,QAAA,EAAUD,YAAA,CAAa,GAAG,EAAE;IACrDgC,OAAA;IACAO,SAAA,EAAW;MACTC,MAAA,EAAQ,CACNhC,2BAAA,CAA4B,CAC1B;QACEiC,IAAA,EAAMtC,aAAA;QACNkB,GAAA,EAAK;QACLqB,QAAA,EAAU,CAAC,cAAc,SAAS,aAAa,KAAK;QACpDpB,KAAA,EAAOA,CAAC;UAAEC;QAAI,CAAE;UACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;QAChB;QACAC,QAAA,EAAUA,CAAC;UAAEC;QAAM,CAAE;UACnBA,MAAA,CAAOC,eAAe,CAAC5B,yBAAA,EAA2B6B,SAAA;QACpD;MACF,EACD;IAEL;IACAe,YAAA,EAAc;MACZH,MAAA,EAAQ7B;IACV;IACAiC,aAAA,EAAe;MACbJ,MAAA,EAAQ7B;IACV;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/checklist/server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/checklist/server/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,kGAyB3B,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { ListItemNode, ListNode } from '@lexical/list';
|
|
|
2
2
|
import { createServerFeature } from '../../../../utilities/createServerFeature.js';
|
|
3
3
|
import { createNode } from '../../../typeUtilities.js';
|
|
4
4
|
import { ListHTMLConverter, ListItemHTMLConverter } from '../../htmlConverter.js';
|
|
5
|
+
import { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js';
|
|
5
6
|
import { CHECK_LIST } from '../markdownTransformers.js';
|
|
6
7
|
import { i18n } from './i18n.js';
|
|
7
8
|
export const ChecklistFeature = createServerFeature({
|
|
@@ -12,7 +13,7 @@ export const ChecklistFeature = createServerFeature({
|
|
|
12
13
|
ClientFeature: '@payloadcms/richtext-lexical/client#ChecklistFeatureClient',
|
|
13
14
|
i18n,
|
|
14
15
|
markdownTransformers: [CHECK_LIST],
|
|
15
|
-
nodes:
|
|
16
|
+
nodes: shouldRegisterListBaseNodes('checklist', featureProviderMap) ? [createNode({
|
|
16
17
|
converters: {
|
|
17
18
|
html: ListHTMLConverter
|
|
18
19
|
},
|
|
@@ -22,7 +23,7 @@ export const ChecklistFeature = createServerFeature({
|
|
|
22
23
|
html: ListItemHTMLConverter
|
|
23
24
|
},
|
|
24
25
|
node: ListItemNode
|
|
25
|
-
})]
|
|
26
|
+
})] : []
|
|
26
27
|
};
|
|
27
28
|
},
|
|
28
29
|
key: 'checklist'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ListItemNode","ListNode","createServerFeature","createNode","ListHTMLConverter","ListItemHTMLConverter","CHECK_LIST","i18n","ChecklistFeature","feature","featureProviderMap","ClientFeature","markdownTransformers","nodes","
|
|
1
|
+
{"version":3,"file":"index.js","names":["ListItemNode","ListNode","createServerFeature","createNode","ListHTMLConverter","ListItemHTMLConverter","shouldRegisterListBaseNodes","CHECK_LIST","i18n","ChecklistFeature","feature","featureProviderMap","ClientFeature","markdownTransformers","nodes","converters","html","node","key"],"sources":["../../../../../src/features/lists/checklist/server/index.ts"],"sourcesContent":["import { ListItemNode, ListNode } from '@lexical/list'\n\nimport { createServerFeature } from '../../../../utilities/createServerFeature.js'\nimport { createNode } from '../../../typeUtilities.js'\nimport { ListHTMLConverter, ListItemHTMLConverter } from '../../htmlConverter.js'\nimport { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js'\nimport { CHECK_LIST } from '../markdownTransformers.js'\nimport { i18n } from './i18n.js'\n\nexport const ChecklistFeature = createServerFeature({\n feature: ({ featureProviderMap }) => {\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#ChecklistFeatureClient',\n i18n,\n markdownTransformers: [CHECK_LIST],\n nodes: shouldRegisterListBaseNodes('checklist', featureProviderMap)\n ? [\n createNode({\n converters: {\n html: ListHTMLConverter as any, // ListHTMLConverter uses a different generic type than ListNode[exportJSON], thus we need to cast as any\n },\n node: ListNode,\n }),\n createNode({\n converters: {\n html: ListItemHTMLConverter as any,\n },\n node: ListItemNode,\n }),\n ]\n : [],\n }\n },\n key: 'checklist',\n})\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,QAAQ,QAAQ;AAEvC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ;AACzD,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,UAAU,QAAQ;AAC3B,SAASC,IAAI,QAAQ;AAErB,OAAO,MAAMC,gBAAA,GAAmBP,mBAAA,CAAoB;EAClDQ,OAAA,EAASA,CAAC;IAAEC;EAAkB,CAAE;IAC9B,OAAO;MACLC,aAAA,EAAe;MACfJ,IAAA;MACAK,oBAAA,EAAsB,CAACN,UAAA,CAAW;MAClCO,KAAA,EAAOR,2BAAA,CAA4B,aAAaK,kBAAA,IAC5C,CACER,UAAA,CAAW;QACTY,UAAA,EAAY;UACVC,IAAA,EAAMZ;QACR;QACAa,IAAA,EAAMhB;MACR,IACAE,UAAA,CAAW;QACTY,UAAA,EAAY;UACVC,IAAA,EAAMX;QACR;QACAY,IAAA,EAAMjB;MACR,GACD,GACD;IACN;EACF;EACAkB,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/orderedList/client/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/orderedList/client/index.tsx"],"names":[],"mappings":"AAuDA,eAAO,MAAM,wBAAwB,uFAqCnC,CAAA"}
|
|
@@ -6,6 +6,7 @@ import { OrderedListIcon } from '../../../../lexical/ui/icons/OrderedList/index.
|
|
|
6
6
|
import { createClientFeature } from '../../../../utilities/createClientFeature.js';
|
|
7
7
|
import { toolbarTextDropdownGroupWithItems } from '../../../shared/toolbar/textDropdownGroup.js';
|
|
8
8
|
import { LexicalListPlugin } from '../../plugin/index.js';
|
|
9
|
+
import { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js';
|
|
9
10
|
import { slashMenuListGroupWithItems } from '../../shared/slashMenuListGroup.js';
|
|
10
11
|
import { ORDERED_LIST } from '../markdownTransformer.js';
|
|
11
12
|
const toolbarGroups = [toolbarTextDropdownGroupWithItems([{
|
|
@@ -49,13 +50,14 @@ const toolbarGroups = [toolbarTextDropdownGroupWithItems([{
|
|
|
49
50
|
export const OrderedListFeatureClient = createClientFeature(({
|
|
50
51
|
featureProviderMap
|
|
51
52
|
}) => {
|
|
53
|
+
const shouldRegister = shouldRegisterListBaseNodes('ordered', featureProviderMap);
|
|
52
54
|
return {
|
|
53
55
|
markdownTransformers: [ORDERED_LIST],
|
|
54
|
-
nodes:
|
|
55
|
-
plugins:
|
|
56
|
+
nodes: shouldRegister ? [ListNode, ListItemNode] : [],
|
|
57
|
+
plugins: shouldRegister ? [{
|
|
56
58
|
Component: LexicalListPlugin,
|
|
57
59
|
position: 'normal'
|
|
58
|
-
}],
|
|
60
|
+
}] : [],
|
|
59
61
|
slashMenu: {
|
|
60
62
|
groups: [slashMenuListGroupWithItems([{
|
|
61
63
|
Icon: OrderedListIcon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["$isListNode","INSERT_ORDERED_LIST_COMMAND","ListItemNode","ListNode","$isRangeSelection","OrderedListIcon","createClientFeature","toolbarTextDropdownGroupWithItems","LexicalListPlugin","slashMenuListGroupWithItems","ORDERED_LIST","toolbarGroups","ChildComponent","isActive","selection","node","getNodes","getListType","parent","getParent","parentParent","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","OrderedListFeatureClient","featureProviderMap","
|
|
1
|
+
{"version":3,"file":"index.js","names":["$isListNode","INSERT_ORDERED_LIST_COMMAND","ListItemNode","ListNode","$isRangeSelection","OrderedListIcon","createClientFeature","toolbarTextDropdownGroupWithItems","LexicalListPlugin","shouldRegisterListBaseNodes","slashMenuListGroupWithItems","ORDERED_LIST","toolbarGroups","ChildComponent","isActive","selection","node","getNodes","getListType","parent","getParent","parentParent","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","OrderedListFeatureClient","featureProviderMap","shouldRegister","markdownTransformers","nodes","plugins","Component","position","slashMenu","groups","Icon","keywords","toolbarFixed","toolbarInline"],"sources":["../../../../../src/features/lists/orderedList/client/index.tsx"],"sourcesContent":["'use client'\nimport { $isListNode, INSERT_ORDERED_LIST_COMMAND, ListItemNode, ListNode } from '@lexical/list'\nimport { $isRangeSelection } from 'lexical'\n\nimport type { ToolbarGroup } from '../../../toolbars/types.js'\n\nimport { OrderedListIcon } from '../../../../lexical/ui/icons/OrderedList/index.js'\nimport { createClientFeature } from '../../../../utilities/createClientFeature.js'\nimport { toolbarTextDropdownGroupWithItems } from '../../../shared/toolbar/textDropdownGroup.js'\nimport { LexicalListPlugin } from '../../plugin/index.js'\nimport { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js'\nimport { slashMenuListGroupWithItems } from '../../shared/slashMenuListGroup.js'\nimport { ORDERED_LIST } from '../markdownTransformer.js'\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarTextDropdownGroupWithItems([\n {\n ChildComponent: OrderedListIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isListNode(node) && node.getListType() === 'number') {\n continue\n }\n\n const parent = node.getParent()\n\n if ($isListNode(parent) && parent.getListType() === 'number') {\n continue\n }\n\n const parentParent = parent?.getParent()\n // Example scenario: Node = textNode, parent = listItemNode, parentParent = listNode\n if ($isListNode(parentParent) && parentParent.getListType() === 'number') {\n continue\n }\n\n return false\n }\n return true\n },\n key: 'orderedList',\n label: ({ i18n }) => {\n return i18n.t('lexical:orderedList:label')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)\n },\n order: 10,\n },\n ]),\n]\n\nexport const OrderedListFeatureClient = createClientFeature(({ featureProviderMap }) => {\n const shouldRegister = shouldRegisterListBaseNodes('ordered', featureProviderMap)\n return {\n markdownTransformers: [ORDERED_LIST],\n nodes: shouldRegister ? [ListNode, ListItemNode] : [],\n plugins: shouldRegister\n ? [\n {\n Component: LexicalListPlugin,\n position: 'normal',\n },\n ]\n : [],\n slashMenu: {\n groups: [\n slashMenuListGroupWithItems([\n {\n Icon: OrderedListIcon,\n key: 'orderedList',\n keywords: ['ordered list', 'ol'],\n label: ({ i18n }) => {\n return i18n.t('lexical:orderedList:label')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)\n },\n },\n ]),\n ],\n },\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n }\n})\n"],"mappings":"AAAA;;AACA,SAASA,WAAW,EAAEC,2BAA2B,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AACjF,SAASC,iBAAiB,QAAQ;AAIlC,SAASC,eAAe,QAAQ;AAChC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,iCAAiC,QAAQ;AAClD,SAASC,iBAAiB,QAAQ;AAClC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,YAAY,QAAQ;AAE7B,MAAMC,aAAA,GAAgC,CACpCL,iCAAA,CAAkC,CAChC;EACEM,cAAA,EAAgBR,eAAA;EAChBS,QAAA,EAAUA,CAAC;IAAEC;EAAS,CAAE;IACtB,IAAI,CAACX,iBAAA,CAAkBW,SAAA,GAAY;MACjC,OAAO;IACT;IACA,KAAK,MAAMC,IAAA,IAAQD,SAAA,CAAUE,QAAQ,IAAI;MACvC,IAAIjB,WAAA,CAAYgB,IAAA,KAASA,IAAA,CAAKE,WAAW,OAAO,UAAU;QACxD;MACF;MAEA,MAAMC,MAAA,GAASH,IAAA,CAAKI,SAAS;MAE7B,IAAIpB,WAAA,CAAYmB,MAAA,KAAWA,MAAA,CAAOD,WAAW,OAAO,UAAU;QAC5D;MACF;MAEA,MAAMG,YAAA,GAAeF,MAAA,EAAQC,SAAA;MAC7B;MACA,IAAIpB,WAAA,CAAYqB,YAAA,KAAiBA,YAAA,CAAaH,WAAW,OAAO,UAAU;QACxE;MACF;MAEA,OAAO;IACT;IACA,OAAO;EACT;EACAI,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;EAChB;EACAC,QAAA,EAAUA,CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC,eAAe,CAAC3B,2BAAA,EAA6B4B,SAAA;EACtD;EACAC,KAAA,EAAO;AACT,EACD,EACF;AAED,OAAO,MAAMC,wBAAA,GAA2BzB,mBAAA,CAAoB,CAAC;EAAE0B;AAAkB,CAAE;EACjF,MAAMC,cAAA,GAAiBxB,2BAAA,CAA4B,WAAWuB,kBAAA;EAC9D,OAAO;IACLE,oBAAA,EAAsB,CAACvB,YAAA,CAAa;IACpCwB,KAAA,EAAOF,cAAA,GAAiB,CAAC9B,QAAA,EAAUD,YAAA,CAAa,GAAG,EAAE;IACrDkC,OAAA,EAASH,cAAA,GACL,CACE;MACEI,SAAA,EAAW7B,iBAAA;MACX8B,QAAA,EAAU;IACZ,EACD,GACD,EAAE;IACNC,SAAA,EAAW;MACTC,MAAA,EAAQ,CACN9B,2BAAA,CAA4B,CAC1B;QACE+B,IAAA,EAAMpC,eAAA;QACNiB,GAAA,EAAK;QACLoB,QAAA,EAAU,CAAC,gBAAgB,KAAK;QAChCnB,KAAA,EAAOA,CAAC;UAAEC;QAAI,CAAE;UACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;QAChB;QACAC,QAAA,EAAUA,CAAC;UAAEC;QAAM,CAAE;UACnBA,MAAA,CAAOC,eAAe,CAAC3B,2BAAA,EAA6B4B,SAAA;QACtD;MACF,EACD;IAEL;IACAc,YAAA,EAAc;MACZH,MAAA,EAAQ5B;IACV;IACAgC,aAAA,EAAe;MACbJ,MAAA,EAAQ5B;IACV;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/orderedList/server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/lists/orderedList/server/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB,kGAyB7B,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { ListItemNode, ListNode } from '@lexical/list';
|
|
|
2
2
|
import { createServerFeature } from '../../../../utilities/createServerFeature.js';
|
|
3
3
|
import { createNode } from '../../../typeUtilities.js';
|
|
4
4
|
import { ListHTMLConverter, ListItemHTMLConverter } from '../../htmlConverter.js';
|
|
5
|
+
import { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js';
|
|
5
6
|
import { ORDERED_LIST } from '../markdownTransformer.js';
|
|
6
7
|
import { i18n } from './i18n.js';
|
|
7
8
|
export const OrderedListFeature = createServerFeature({
|
|
@@ -12,7 +13,7 @@ export const OrderedListFeature = createServerFeature({
|
|
|
12
13
|
ClientFeature: '@payloadcms/richtext-lexical/client#OrderedListFeatureClient',
|
|
13
14
|
i18n,
|
|
14
15
|
markdownTransformers: [ORDERED_LIST],
|
|
15
|
-
nodes:
|
|
16
|
+
nodes: shouldRegisterListBaseNodes('ordered', featureProviderMap) ? [createNode({
|
|
16
17
|
converters: {
|
|
17
18
|
html: ListHTMLConverter
|
|
18
19
|
},
|
|
@@ -22,7 +23,7 @@ export const OrderedListFeature = createServerFeature({
|
|
|
22
23
|
html: ListItemHTMLConverter
|
|
23
24
|
},
|
|
24
25
|
node: ListItemNode
|
|
25
|
-
})]
|
|
26
|
+
})] : []
|
|
26
27
|
};
|
|
27
28
|
},
|
|
28
29
|
key: 'orderedList'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ListItemNode","ListNode","createServerFeature","createNode","ListHTMLConverter","ListItemHTMLConverter","ORDERED_LIST","i18n","OrderedListFeature","feature","featureProviderMap","ClientFeature","markdownTransformers","nodes","
|
|
1
|
+
{"version":3,"file":"index.js","names":["ListItemNode","ListNode","createServerFeature","createNode","ListHTMLConverter","ListItemHTMLConverter","shouldRegisterListBaseNodes","ORDERED_LIST","i18n","OrderedListFeature","feature","featureProviderMap","ClientFeature","markdownTransformers","nodes","converters","html","node","key"],"sources":["../../../../../src/features/lists/orderedList/server/index.ts"],"sourcesContent":["import { ListItemNode, ListNode } from '@lexical/list'\n\nimport { createServerFeature } from '../../../../utilities/createServerFeature.js'\nimport { createNode } from '../../../typeUtilities.js'\nimport { ListHTMLConverter, ListItemHTMLConverter } from '../../htmlConverter.js'\nimport { shouldRegisterListBaseNodes } from '../../shared/shouldRegisterListBaseNodes.js'\nimport { ORDERED_LIST } from '../markdownTransformer.js'\nimport { i18n } from './i18n.js'\n\nexport const OrderedListFeature = createServerFeature({\n feature: ({ featureProviderMap }) => {\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#OrderedListFeatureClient',\n i18n,\n markdownTransformers: [ORDERED_LIST],\n nodes: shouldRegisterListBaseNodes('ordered', featureProviderMap)\n ? [\n createNode({\n converters: {\n html: ListHTMLConverter as any, // ListHTMLConverter uses a different generic type than ListNode[exportJSON], thus we need to cast as any\n },\n node: ListNode,\n }),\n createNode({\n converters: {\n html: ListItemHTMLConverter as any,\n },\n node: ListItemNode,\n }),\n ]\n : [],\n }\n },\n key: 'orderedList',\n})\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,QAAQ,QAAQ;AAEvC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ;AACzD,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,YAAY,QAAQ;AAC7B,SAASC,IAAI,QAAQ;AAErB,OAAO,MAAMC,kBAAA,GAAqBP,mBAAA,CAAoB;EACpDQ,OAAA,EAASA,CAAC;IAAEC;EAAkB,CAAE;IAC9B,OAAO;MACLC,aAAA,EAAe;MACfJ,IAAA;MACAK,oBAAA,EAAsB,CAACN,YAAA,CAAa;MACpCO,KAAA,EAAOR,2BAAA,CAA4B,WAAWK,kBAAA,IAC1C,CACER,UAAA,CAAW;QACTY,UAAA,EAAY;UACVC,IAAA,EAAMZ;QACR;QACAa,IAAA,EAAMhB;MACR,IACAE,UAAA,CAAW;QACTY,UAAA,EAAY;UACVC,IAAA,EAAMX;QACR;QACAY,IAAA,EAAMjB;MACR,GACD,GACD;IACN;EACF;EACAkB,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shouldRegisterListBaseNodes.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/shared/shouldRegisterListBaseNodes.ts"],"names":[],"mappings":"AAEA,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,WAazC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Priority order: unordered > ordered > checklist.
|
|
2
|
+
// That's why we don't include unordered among the parameter options. It registers by default.
|
|
3
|
+
export function shouldRegisterListBaseNodes(type, featureProviderMap) {
|
|
4
|
+
if (type === 'ordered') {
|
|
5
|
+
// OrderedList only registers if UnorderedList is NOT present
|
|
6
|
+
return !featureProviderMap.has('unorderedList');
|
|
7
|
+
}
|
|
8
|
+
if (type === 'checklist') {
|
|
9
|
+
// Checklist only registers if neither UnorderedList nor OrderedList are present
|
|
10
|
+
return !featureProviderMap.has('unorderedList') && !featureProviderMap.has('orderedList');
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=shouldRegisterListBaseNodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shouldRegisterListBaseNodes.js","names":["shouldRegisterListBaseNodes","type","featureProviderMap","has"],"sources":["../../../../src/features/lists/shared/shouldRegisterListBaseNodes.ts"],"sourcesContent":["// Priority order: unordered > ordered > checklist.\n// That's why we don't include unordered among the parameter options. It registers by default.\nexport function shouldRegisterListBaseNodes(\n type: 'checklist' | 'ordered',\n featureProviderMap: Map<string, unknown>,\n) {\n if (type === 'ordered') {\n // OrderedList only registers if UnorderedList is NOT present\n return !featureProviderMap.has('unorderedList')\n }\n\n if (type === 'checklist') {\n // Checklist only registers if neither UnorderedList nor OrderedList are present\n return !featureProviderMap.has('unorderedList') && !featureProviderMap.has('orderedList')\n }\n\n return false\n}\n"],"mappings":"AAAA;AACA;AACA,OAAO,SAASA,4BACdC,IAA6B,EAC7BC,kBAAwC;EAExC,IAAID,IAAA,KAAS,WAAW;IACtB;IACA,OAAO,CAACC,kBAAA,CAAmBC,GAAG,CAAC;EACjC;EAEA,IAAIF,IAAA,KAAS,aAAa;IACxB;IACA,OAAO,CAACC,kBAAA,CAAmBC,GAAG,CAAC,oBAAoB,CAACD,kBAAA,CAAmBC,GAAG,CAAC;EAC7E;EAEA,OAAO;AACT","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js';
|
|
5
5
|
import { createClientFeature } from '../../utilities/createClientFeature.js';
|
|
6
6
|
import { registerTextStates, setTextState, StatePlugin } from './textState.js';
|
|
7
|
-
const toolbarGroups = props => {
|
|
7
|
+
const toolbarGroups = (props, stateMap) => {
|
|
8
8
|
const items = [];
|
|
9
9
|
for (const stateKey in props.state) {
|
|
10
10
|
const key = props.state[stateKey];
|
|
@@ -19,7 +19,7 @@ const toolbarGroups = props => {
|
|
|
19
19
|
onSelect: ({
|
|
20
20
|
editor
|
|
21
21
|
}) => {
|
|
22
|
-
setTextState(editor, stateKey, stateValue);
|
|
22
|
+
setTextState(editor, stateMap, stateKey, stateValue);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -34,7 +34,7 @@ const toolbarGroups = props => {
|
|
|
34
34
|
editor
|
|
35
35
|
}) => {
|
|
36
36
|
for (const stateKey in props.state) {
|
|
37
|
-
setTextState(editor, stateKey, undefined);
|
|
37
|
+
setTextState(editor, stateMap, stateKey, undefined);
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
order: 1
|
|
@@ -54,17 +54,19 @@ const toolbarGroups = props => {
|
|
|
54
54
|
export const TextStateFeatureClient = createClientFeature(({
|
|
55
55
|
props
|
|
56
56
|
}) => {
|
|
57
|
-
registerTextStates(props.state);
|
|
57
|
+
const stateMap = registerTextStates(props.state);
|
|
58
58
|
return {
|
|
59
59
|
plugins: [{
|
|
60
|
-
Component: StatePlugin
|
|
60
|
+
Component: () => StatePlugin({
|
|
61
|
+
stateMap
|
|
62
|
+
}),
|
|
61
63
|
position: 'normal'
|
|
62
64
|
}],
|
|
63
65
|
toolbarFixed: {
|
|
64
|
-
groups: toolbarGroups(props)
|
|
66
|
+
groups: toolbarGroups(props, stateMap)
|
|
65
67
|
},
|
|
66
68
|
toolbarInline: {
|
|
67
|
-
groups: toolbarGroups(props)
|
|
69
|
+
groups: toolbarGroups(props, stateMap)
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.client.js","names":["TextStateIcon","createClientFeature","registerTextStates","setTextState","StatePlugin","toolbarGroups","props","items","stateKey","state","key","stateValue","meta","push","ChildComponent","_jsx","css","label","onSelect","editor","clearStyle","i18n","t","undefined","order","type","color","TextStateFeatureClient","plugins","Component","position","toolbarFixed","groups","toolbarInline"],"sources":["../../../src/features/textState/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport type { ToolbarDropdownGroup, ToolbarGroup } from '../toolbars/types.js'\nimport type { TextStateFeatureProps } from './feature.server.js'\n\nimport { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js'\nimport { createClientFeature } from '../../utilities/createClientFeature.js'\nimport { registerTextStates, setTextState, StatePlugin } from './textState.js'\n\nconst toolbarGroups = (props: TextStateFeatureProps): ToolbarGroup[] => {\n const items: ToolbarDropdownGroup['items'] = []\n\n for (const stateKey in props.state) {\n const key = props.state[stateKey]!\n for (const stateValue in key) {\n const meta = key[stateValue]!\n items.push({\n ChildComponent: () => <TextStateIcon css={meta.css} />,\n key: stateValue,\n label: meta.label,\n onSelect: ({ editor }) => {\n setTextState(editor, stateKey, stateValue)\n },\n })\n }\n }\n\n const clearStyle: ToolbarDropdownGroup['items'] = [\n {\n ChildComponent: () => <TextStateIcon />,\n key: `clear-style`,\n label: ({ i18n }) => i18n.t('lexical:textState:defaultStyle'),\n onSelect: ({ editor }) => {\n for (const stateKey in props.state) {\n setTextState(editor, stateKey, undefined)\n }\n },\n order: 1,\n },\n ]\n\n return [\n {\n type: 'dropdown',\n ChildComponent: () => <TextStateIcon css={{ color: 'var(--theme-elevation-600)' }} />,\n items: [...clearStyle, ...items],\n key: 'textState',\n order: 30,\n },\n ]\n}\n\nexport const TextStateFeatureClient = createClientFeature<TextStateFeatureProps>(({ props }) => {\n registerTextStates(props.state)\n return {\n plugins: [\n {\n Component: StatePlugin,\n position: 'normal',\n },\n ],\n toolbarFixed: {\n groups: toolbarGroups(props),\n },\n toolbarInline: {\n groups: toolbarGroups(props),\n },\n }\n})\n"],"mappings":"AAAA;;;AAKA,SAASA,aAAa,QAAQ;AAC9B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,kBAAkB,EAAEC,YAAY,
|
|
1
|
+
{"version":3,"file":"feature.client.js","names":["TextStateIcon","createClientFeature","registerTextStates","setTextState","StatePlugin","toolbarGroups","props","stateMap","items","stateKey","state","key","stateValue","meta","push","ChildComponent","_jsx","css","label","onSelect","editor","clearStyle","i18n","t","undefined","order","type","color","TextStateFeatureClient","plugins","Component","position","toolbarFixed","groups","toolbarInline"],"sources":["../../../src/features/textState/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport type { ToolbarDropdownGroup, ToolbarGroup } from '../toolbars/types.js'\nimport type { TextStateFeatureProps } from './feature.server.js'\n\nimport { TextStateIcon } from '../../lexical/ui/icons/TextState/index.js'\nimport { createClientFeature } from '../../utilities/createClientFeature.js'\nimport { registerTextStates, setTextState, type StateMap, StatePlugin } from './textState.js'\n\nconst toolbarGroups = (props: TextStateFeatureProps, stateMap: StateMap): ToolbarGroup[] => {\n const items: ToolbarDropdownGroup['items'] = []\n\n for (const stateKey in props.state) {\n const key = props.state[stateKey]!\n for (const stateValue in key) {\n const meta = key[stateValue]!\n items.push({\n ChildComponent: () => <TextStateIcon css={meta.css} />,\n key: stateValue,\n label: meta.label,\n onSelect: ({ editor }) => {\n setTextState(editor, stateMap, stateKey, stateValue)\n },\n })\n }\n }\n\n const clearStyle: ToolbarDropdownGroup['items'] = [\n {\n ChildComponent: () => <TextStateIcon />,\n key: `clear-style`,\n label: ({ i18n }) => i18n.t('lexical:textState:defaultStyle'),\n onSelect: ({ editor }) => {\n for (const stateKey in props.state) {\n setTextState(editor, stateMap, stateKey, undefined)\n }\n },\n order: 1,\n },\n ]\n\n return [\n {\n type: 'dropdown',\n ChildComponent: () => <TextStateIcon css={{ color: 'var(--theme-elevation-600)' }} />,\n items: [...clearStyle, ...items],\n key: 'textState',\n order: 30,\n },\n ]\n}\n\nexport const TextStateFeatureClient = createClientFeature<TextStateFeatureProps>(({ props }) => {\n const stateMap = registerTextStates(props.state)\n return {\n plugins: [\n {\n Component: () => StatePlugin({ stateMap }),\n position: 'normal',\n },\n ],\n toolbarFixed: {\n groups: toolbarGroups(props, stateMap),\n },\n toolbarInline: {\n groups: toolbarGroups(props, stateMap),\n },\n }\n})\n"],"mappings":"AAAA;;;AAKA,SAASA,aAAa,QAAQ;AAC9B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,kBAAkB,EAAEC,YAAY,EAAiBC,WAAW,QAAQ;AAE7E,MAAMC,aAAA,GAAgBA,CAACC,KAAA,EAA8BC,QAAA;EACnD,MAAMC,KAAA,GAAuC,EAAE;EAE/C,KAAK,MAAMC,QAAA,IAAYH,KAAA,CAAMI,KAAK,EAAE;IAClC,MAAMC,GAAA,GAAML,KAAA,CAAMI,KAAK,CAACD,QAAA,CAAS;IACjC,KAAK,MAAMG,UAAA,IAAcD,GAAA,EAAK;MAC5B,MAAME,IAAA,GAAOF,GAAG,CAACC,UAAA,CAAW;MAC5BJ,KAAA,CAAMM,IAAI,CAAC;QACTC,cAAA,EAAgBA,CAAA,kBAAMC,IAAA,CAAChB,aAAA;UAAciB,GAAA,EAAKJ,IAAA,CAAKI;;QAC/CN,GAAA,EAAKC,UAAA;QACLM,KAAA,EAAOL,IAAA,CAAKK,KAAK;QACjBC,QAAA,EAAUA,CAAC;UAAEC;QAAM,CAAE;UACnBjB,YAAA,CAAaiB,MAAA,EAAQb,QAAA,EAAUE,QAAA,EAAUG,UAAA;QAC3C;MACF;IACF;EACF;EAEA,MAAMS,UAAA,GAA4C,CAChD;IACEN,cAAA,EAAgBA,CAAA,kBAAMC,IAAA,CAAChB,aAAA;IACvBW,GAAA,EAAK,aAAa;IAClBO,KAAA,EAAOA,CAAC;MAAEI;IAAI,CAAE,KAAKA,IAAA,CAAKC,CAAC,CAAC;IAC5BJ,QAAA,EAAUA,CAAC;MAAEC;IAAM,CAAE;MACnB,KAAK,MAAMX,QAAA,IAAYH,KAAA,CAAMI,KAAK,EAAE;QAClCP,YAAA,CAAaiB,MAAA,EAAQb,QAAA,EAAUE,QAAA,EAAUe,SAAA;MAC3C;IACF;IACAC,KAAA,EAAO;EACT,EACD;EAED,OAAO,CACL;IACEC,IAAA,EAAM;IACNX,cAAA,EAAgBA,CAAA,kBAAMC,IAAA,CAAChB,aAAA;MAAciB,GAAA,EAAK;QAAEU,KAAA,EAAO;MAA6B;;IAChFnB,KAAA,EAAO,C,GAAIa,UAAA,E,GAAeb,KAAA,CAAM;IAChCG,GAAA,EAAK;IACLc,KAAA,EAAO;EACT,EACD;AACH;AAEA,OAAO,MAAMG,sBAAA,GAAyB3B,mBAAA,CAA2C,CAAC;EAAEK;AAAK,CAAE;EACzF,MAAMC,QAAA,GAAWL,kBAAA,CAAmBI,KAAA,CAAMI,KAAK;EAC/C,OAAO;IACLmB,OAAA,EAAS,CACP;MACEC,SAAA,EAAWA,CAAA,KAAM1B,WAAA,CAAY;QAAEG;MAAS;MACxCwB,QAAA,EAAU;IACZ,EACD;IACDC,YAAA,EAAc;MACZC,MAAA,EAAQ5B,aAAA,CAAcC,KAAA,EAAOC,QAAA;IAC/B;IACA2B,aAAA,EAAe;MACbD,MAAA,EAAQ5B,aAAA,CAAcC,KAAA,EAAOC,QAAA;IAC/B;EACF;AACF","ignoreList":[]}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type { LexicalEditor } from 'lexical';
|
|
2
|
-
import { type TextStateFeatureProps } from './feature.server.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { LexicalEditor, StateConfig } from 'lexical';
|
|
2
|
+
import { type StateValues, type TextStateFeatureProps } from './feature.server.js';
|
|
3
|
+
export type StateMap = Map<string, {
|
|
4
|
+
stateConfig: StateConfig<string, string | undefined>;
|
|
5
|
+
stateValues: StateValues;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function registerTextStates(state: TextStateFeatureProps['state']): StateMap;
|
|
8
|
+
export declare function setTextState(editor: LexicalEditor, stateMap: StateMap, stateKey: string, value: string | undefined): void;
|
|
9
|
+
export declare function StatePlugin({ stateMap }: {
|
|
10
|
+
stateMap: StateMap;
|
|
11
|
+
}): null;
|
|
6
12
|
//# sourceMappingURL=textState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textState.d.ts","sourceRoot":"","sources":["../../../src/features/textState/textState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"textState.d.ts","sourceRoot":"","sources":["../../../src/features/textState/textState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAOzD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAElF,MAAM,MAAM,QAAQ,GAAG,GAAG,CACxB,MAAM,EACN;IACE,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACpD,WAAW,EAAE,WAAW,CAAA;CACzB,CACF,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,YAYvE;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,QAW1B;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,QA8C/D"}
|
|
@@ -2,8 +2,8 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
|
|
|
2
2
|
import { $forEachSelectedTextNode } from '@lexical/selection';
|
|
3
3
|
import { $getNodeByKey, $getState, $setState, createState, TextNode } from 'lexical';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
|
-
const stateMap = new Map();
|
|
6
5
|
export function registerTextStates(state) {
|
|
6
|
+
const stateMap = new Map();
|
|
7
7
|
for (const stateKey in state) {
|
|
8
8
|
const stateValues = state[stateKey];
|
|
9
9
|
const stateConfig = createState(stateKey, {
|
|
@@ -14,8 +14,9 @@ export function registerTextStates(state) {
|
|
|
14
14
|
stateValues
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
+
return stateMap;
|
|
17
18
|
}
|
|
18
|
-
export function setTextState(editor, stateKey, value) {
|
|
19
|
+
export function setTextState(editor, stateMap, stateKey, value) {
|
|
19
20
|
editor.update(() => {
|
|
20
21
|
$forEachSelectedTextNode(textNode => {
|
|
21
22
|
const stateMapEntry = stateMap.get(stateKey);
|
|
@@ -26,7 +27,9 @@ export function setTextState(editor, stateKey, value) {
|
|
|
26
27
|
});
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
|
-
export function StatePlugin(
|
|
30
|
+
export function StatePlugin({
|
|
31
|
+
stateMap
|
|
32
|
+
}) {
|
|
30
33
|
const [editor] = useLexicalComposerContext();
|
|
31
34
|
useEffect(() => {
|
|
32
35
|
return editor.registerMutationListener(TextNode, mutatedNodes => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textState.js","names":["useLexicalComposerContext","$forEachSelectedTextNode","$getNodeByKey","$getState","$setState","createState","TextNode","useEffect","
|
|
1
|
+
{"version":3,"file":"textState.js","names":["useLexicalComposerContext","$forEachSelectedTextNode","$getNodeByKey","$getState","$setState","createState","TextNode","useEffect","registerTextStates","state","stateMap","Map","stateKey","stateValues","stateConfig","parse","value","Object","keys","includes","undefined","set","setTextState","editor","update","textNode","stateMapEntry","get","Error","StatePlugin","registerMutationListener","mutatedNodes","getEditorState","read","nodeKey","mutation","node","dom","getElementByKey","mergedStyles","create","forEach","stateEntry","stateValue","dataset","css","assign","style","cssText"],"sources":["../../../src/features/textState/textState.ts"],"sourcesContent":["import type { LexicalEditor, StateConfig } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $forEachSelectedTextNode } from '@lexical/selection'\nimport { $getNodeByKey, $getState, $setState, createState, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { type StateValues, type TextStateFeatureProps } from './feature.server.js'\n\nexport type StateMap = Map<\n string,\n {\n stateConfig: StateConfig<string, string | undefined>\n stateValues: StateValues\n }\n>\n\nexport function registerTextStates(state: TextStateFeatureProps['state']) {\n const stateMap: StateMap = new Map()\n\n for (const stateKey in state) {\n const stateValues = state[stateKey]!\n const stateConfig = createState(stateKey, {\n parse: (value) =>\n typeof value === 'string' && Object.keys(stateValues).includes(value) ? value : undefined,\n })\n stateMap.set(stateKey, { stateConfig, stateValues })\n }\n return stateMap\n}\n\nexport function setTextState(\n editor: LexicalEditor,\n stateMap: StateMap,\n stateKey: string,\n value: string | undefined,\n) {\n editor.update(() => {\n $forEachSelectedTextNode((textNode) => {\n const stateMapEntry = stateMap.get(stateKey)\n if (!stateMapEntry) {\n throw new Error(`State config for ${stateKey} not found`)\n }\n $setState(textNode, stateMapEntry.stateConfig, value)\n })\n })\n}\n\nexport function StatePlugin({ stateMap }: { stateMap: StateMap }) {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerMutationListener(TextNode, (mutatedNodes) => {\n editor.getEditorState().read(() => {\n for (const [nodeKey, mutation] of mutatedNodes) {\n if (mutation === 'destroyed') {\n continue\n }\n const node = $getNodeByKey(nodeKey)\n const dom = editor.getElementByKey(nodeKey)\n if (!node || !dom) {\n continue\n }\n\n const mergedStyles: Record<string, string> = Object.create(null)\n // Examples:\n // stateKey: 'color'\n // stateValue: 'bg-red'\n stateMap.forEach((stateEntry, stateKey) => {\n const stateValue = $getState(node, stateEntry.stateConfig)\n if (!stateValue) {\n // clear the previous dataset value for this key\n delete dom.dataset[stateKey]\n return\n } // skip - nothing else to do\n\n dom.dataset[stateKey] = stateValue\n\n const css = stateEntry.stateValues[stateValue]?.css\n if (css) {\n // merge existing styles with the new ones\n Object.assign(mergedStyles, css)\n }\n })\n\n // wipe previous inline styles once, then set the merged ones\n dom.style.cssText = ''\n Object.assign(dom.style, mergedStyles)\n }\n })\n })\n }, [editor])\n\n return null\n}\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SAASC,aAAa,EAAEC,SAAS,EAAEC,SAAS,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAC3E,SAASC,SAAS,QAAQ;AAY1B,OAAO,SAASC,mBAAmBC,KAAqC;EACtE,MAAMC,QAAA,GAAqB,IAAIC,GAAA;EAE/B,KAAK,MAAMC,QAAA,IAAYH,KAAA,EAAO;IAC5B,MAAMI,WAAA,GAAcJ,KAAK,CAACG,QAAA,CAAS;IACnC,MAAME,WAAA,GAAcT,WAAA,CAAYO,QAAA,EAAU;MACxCG,KAAA,EAAQC,KAAA,IACN,OAAOA,KAAA,KAAU,YAAYC,MAAA,CAAOC,IAAI,CAACL,WAAA,EAAaM,QAAQ,CAACH,KAAA,IAASA,KAAA,GAAQI;IACpF;IACAV,QAAA,CAASW,GAAG,CAACT,QAAA,EAAU;MAAEE,WAAA;MAAaD;IAAY;EACpD;EACA,OAAOH,QAAA;AACT;AAEA,OAAO,SAASY,aACdC,MAAqB,EACrBb,QAAkB,EAClBE,QAAgB,EAChBI,KAAyB;EAEzBO,MAAA,CAAOC,MAAM,CAAC;IACZvB,wBAAA,CAA0BwB,QAAA;MACxB,MAAMC,aAAA,GAAgBhB,QAAA,CAASiB,GAAG,CAACf,QAAA;MACnC,IAAI,CAACc,aAAA,EAAe;QAClB,MAAM,IAAIE,KAAA,CAAM,oBAAoBhB,QAAA,YAAoB;MAC1D;MACAR,SAAA,CAAUqB,QAAA,EAAUC,aAAA,CAAcZ,WAAW,EAAEE,KAAA;IACjD;EACF;AACF;AAEA,OAAO,SAASa,YAAY;EAAEnB;AAAQ,CAA0B;EAC9D,MAAM,CAACa,MAAA,CAAO,GAAGvB,yBAAA;EAEjBO,SAAA,CAAU;IACR,OAAOgB,MAAA,CAAOO,wBAAwB,CAACxB,QAAA,EAAWyB,YAAA;MAChDR,MAAA,CAAOS,cAAc,GAAGC,IAAI,CAAC;QAC3B,KAAK,MAAM,CAACC,OAAA,EAASC,QAAA,CAAS,IAAIJ,YAAA,EAAc;UAC9C,IAAII,QAAA,KAAa,aAAa;YAC5B;UACF;UACA,MAAMC,IAAA,GAAOlC,aAAA,CAAcgC,OAAA;UAC3B,MAAMG,GAAA,GAAMd,MAAA,CAAOe,eAAe,CAACJ,OAAA;UACnC,IAAI,CAACE,IAAA,IAAQ,CAACC,GAAA,EAAK;YACjB;UACF;UAEA,MAAME,YAAA,GAAuCtB,MAAA,CAAOuB,MAAM,CAAC;UAC3D;UACA;UACA;UACA9B,QAAA,CAAS+B,OAAO,CAAC,CAACC,UAAA,EAAY9B,QAAA;YAC5B,MAAM+B,UAAA,GAAaxC,SAAA,CAAUiC,IAAA,EAAMM,UAAA,CAAW5B,WAAW;YACzD,IAAI,CAAC6B,UAAA,EAAY;cACf;cACA,OAAON,GAAA,CAAIO,OAAO,CAAChC,QAAA,CAAS;cAC5B;YACF,EAAE;YAEFyB,GAAA,CAAIO,OAAO,CAAChC,QAAA,CAAS,GAAG+B,UAAA;YAExB,MAAME,GAAA,GAAMH,UAAA,CAAW7B,WAAW,CAAC8B,UAAA,CAAW,EAAEE,GAAA;YAChD,IAAIA,GAAA,EAAK;cACP;cACA5B,MAAA,CAAO6B,MAAM,CAACP,YAAA,EAAcM,GAAA;YAC9B;UACF;UAEA;UACAR,GAAA,CAAIU,KAAK,CAACC,OAAO,GAAG;UACpB/B,MAAA,CAAO6B,MAAM,CAACT,GAAA,CAAIU,KAAK,EAAER,YAAA;QAC3B;MACF;IACF;EACF,GAAG,CAAChB,MAAA,CAAO;EAEX,OAAO;AACT","ignoreList":[]}
|