@ainsleydev/payload-helper 0.0.27 → 0.0.29
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/util/lexical.js +1 -1
- package/dist/util/lexical.js.map +1 -1
- package/package.json +16 -10
package/dist/util/lexical.js
CHANGED
|
@@ -59,7 +59,7 @@ import { $getRoot, $getSelection } from 'lexical';
|
|
|
59
59
|
$getRoot().select();
|
|
60
60
|
// Insert them at a selection.
|
|
61
61
|
const selection = $getSelection();
|
|
62
|
-
|
|
62
|
+
//if (selection) selection.insertNodes(nodes);
|
|
63
63
|
}, {
|
|
64
64
|
discrete: true
|
|
65
65
|
});
|
package/dist/util/lexical.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/lexical.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless';\nimport { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html';\n// import { sqliteAdapter } from '@payloadcms/db-sqlite';\n// import {\n// \tdefaultEditorConfig,\n// \tgetEnabledNodes,\n// \tlexicalEditor,\n// \tsanitizeServerEditorConfig,\n// } from '@payloadcms/richtext-lexical';\nimport { JSDOM } from 'jsdom';\nimport { $getRoot, $getSelection, type LexicalEditor } from 'lexical';\nimport type { SerializedEditorState } from 'lexical';\n// import { buildConfig, getPayload } from 'payload';\n// import { importWithoutClientFiles } from 'payload/node';\n\n// const loadEditor = async (): Promise<LexicalEditor> => {\n// \tconst config = {\n// \t\tsecret: 'testing',\n// \t\teditor: lexicalEditor({\n// \t\t\tadmin: {\n// \t\t\t\thideGutter: false,\n// \t\t\t},\n// \t\t}),\n// \t\tdb: sqliteAdapter({\n// \t\t\tclient: {\n// \t\t\t\turl: 'file:./local.db',\n// \t\t\t},\n// \t\t}),\n// \t};\n//\n// \tconst instance = await getPayload({\n// \t\tconfig: buildConfig(config),\n// \t});\n//\n// \tconst editorConfig = await sanitizeServerEditorConfig(defaultEditorConfig, instance.config);\n//\n// \treturn createHeadlessEditor({\n// \t\tnodes: getEnabledNodes({\n// \t\t\teditorConfig,\n// \t\t}),\n// \t});\n// };\n\n/**\n * Converts an HTML string to a Lexical editor state.\n *\n * @param {string} html - The HTML string to convert.\n * @returns {SerializedEditorState} The serialized editor state.\n */\nexport const htmlToLexical = (html: string): SerializedEditorState => {\n\tconst editor = createHeadlessEditor({\n\t\tnodes: [],\n\t\tonError: (error) => {\n\t\t\tconsole.error(error);\n\t\t},\n\t});\n\n\teditor.update(\n\t\t() => {\n\t\t\t// In a headless environment you can use a package such as JSDom to parse the HTML string.\n\t\t\tconst dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);\n\n\t\t\t// Once you have the DOM instance it's easy to generate LexicalNodes.\n\t\t\tconst nodes = $generateNodesFromDOM(editor, dom.window.document);\n\n\t\t\t// Select the root\n\t\t\t$getRoot().select();\n\n\t\t\t// Insert them at a selection.\n\t\t\tconst selection = $getSelection();\n\n\t\t\
|
|
1
|
+
{"version":3,"sources":["../../src/util/lexical.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless';\nimport { $generateHtmlFromNodes, $generateNodesFromDOM } from '@lexical/html';\n// import { sqliteAdapter } from '@payloadcms/db-sqlite';\n// import {\n// \tdefaultEditorConfig,\n// \tgetEnabledNodes,\n// \tlexicalEditor,\n// \tsanitizeServerEditorConfig,\n// } from '@payloadcms/richtext-lexical';\nimport { JSDOM } from 'jsdom';\nimport { $getRoot, $getSelection, type LexicalEditor } from 'lexical';\nimport type { SerializedEditorState } from 'lexical';\n// import { buildConfig, getPayload } from 'payload';\n// import { importWithoutClientFiles } from 'payload/node';\n\n// const loadEditor = async (): Promise<LexicalEditor> => {\n// \tconst config = {\n// \t\tsecret: 'testing',\n// \t\teditor: lexicalEditor({\n// \t\t\tadmin: {\n// \t\t\t\thideGutter: false,\n// \t\t\t},\n// \t\t}),\n// \t\tdb: sqliteAdapter({\n// \t\t\tclient: {\n// \t\t\t\turl: 'file:./local.db',\n// \t\t\t},\n// \t\t}),\n// \t};\n//\n// \tconst instance = await getPayload({\n// \t\tconfig: buildConfig(config),\n// \t});\n//\n// \tconst editorConfig = await sanitizeServerEditorConfig(defaultEditorConfig, instance.config);\n//\n// \treturn createHeadlessEditor({\n// \t\tnodes: getEnabledNodes({\n// \t\t\teditorConfig,\n// \t\t}),\n// \t});\n// };\n\n/**\n * Converts an HTML string to a Lexical editor state.\n *\n * @param {string} html - The HTML string to convert.\n * @returns {SerializedEditorState} The serialized editor state.\n */\nexport const htmlToLexical = (html: string): SerializedEditorState => {\n\tconst editor = createHeadlessEditor({\n\t\tnodes: [],\n\t\tonError: (error) => {\n\t\t\tconsole.error(error);\n\t\t},\n\t});\n\n\teditor.update(\n\t\t() => {\n\t\t\t// In a headless environment you can use a package such as JSDom to parse the HTML string.\n\t\t\tconst dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);\n\n\t\t\t// Once you have the DOM instance it's easy to generate LexicalNodes.\n\t\t\tconst nodes = $generateNodesFromDOM(editor, dom.window.document);\n\n\t\t\t// Select the root\n\t\t\t$getRoot().select();\n\n\t\t\t// Insert them at a selection.\n\t\t\tconst selection = $getSelection();\n\n\t\t\t//if (selection) selection.insertNodes(nodes);\n\t\t},\n\t\t{ discrete: true },\n\t);\n\n\treturn editor.getEditorState().toJSON();\n\n\t// let state = {};\n\t//\n\t// loadEditor().then((editor) => {\n\t// \teditor.update(\n\t// \t\t() => {\n\t// \t\t\t// In a headless environment you can use a package such as JSDom to parse the HTML string.\n\t// \t\t\tconst dom = new JSDOM(`<!DOCTYPE html><body>${html}</body>`);\n\t//\n\t// \t\t\t// Once you have the DOM instance it's easy to generate LexicalNodes.\n\t// \t\t\tconst nodes = $generateNodesFromDOM(editor, dom.window.document);\n\t//\n\t// \t\t\t// Select the root\n\t// \t\t\t$getRoot().select();\n\t//\n\t// \t\t\t// Insert them at a selection.\n\t// \t\t\tconst selection = $getSelection();\n\t//\n\t// \t\t\tif (selection) selection.insertNodes(nodes);\n\t// \t\t},\n\t// \t\t{ discrete: true },\n\t// \t);\n\t//\n\t// \tstate = editor.getEditorState().toJSON();\n\t// });\n\t//\n\t// return state as SerializedEditorState;\n};\n\n/**\n * Converts a Lexical editor state to an HTML string.\n *\n * @param {SerializedEditorState} json - The serialized editor state to convert.\n * @returns {string} The HTML string.\n */\nexport const lexicalToHtml = (json: SerializedEditorState): string => {\n\tconst editor = createHeadlessEditor({\n\t\tnodes: [],\n\t\tonError: (error) => {\n\t\t\tconsole.error(error);\n\t\t},\n\t});\n\n\t// Initialize a JSDOM instance\n\tconst dom = new JSDOM('');\n\n\t// @ts-ignore\n\tglobalThis.window = dom.window;\n\tglobalThis.document = dom.window.document;\n\n\teditor.update(() => {\n\t\tconst editorState = editor.parseEditorState(json);\n\t\teditor.setEditorState(editorState);\n\t});\n\n\t// Convert the editor state to HTML\n\tlet html = '';\n\teditor.getEditorState().read(() => {\n\t\thtml = $generateHtmlFromNodes(editor);\n\t});\n\n\treturn html;\n};\n"],"names":["createHeadlessEditor","$generateHtmlFromNodes","$generateNodesFromDOM","JSDOM","$getRoot","$getSelection","htmlToLexical","html","editor","nodes","onError","error","console","update","dom","window","document","select","selection","discrete","getEditorState","toJSON","lexicalToHtml","json","globalThis","editorState","parseEditorState","setEditorState","read"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,sBAAsB,EAAEC,qBAAqB,QAAQ,gBAAgB;AAC9E,yDAAyD;AACzD,WAAW;AACX,wBAAwB;AACxB,oBAAoB;AACpB,kBAAkB;AAClB,+BAA+B;AAC/B,yCAAyC;AACzC,SAASC,KAAK,QAAQ,QAAQ;AAC9B,SAASC,QAAQ,EAAEC,aAAa,QAA4B,UAAU;AAEtE,qDAAqD;AACrD,2DAA2D;AAE3D,2DAA2D;AAC3D,oBAAoB;AACpB,uBAAuB;AACvB,4BAA4B;AAC5B,cAAc;AACd,yBAAyB;AACzB,QAAQ;AACR,QAAQ;AACR,wBAAwB;A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;IAEA,8BAA8B;IAC9B,MAAMG,MAAM,IAAIX,MAAM;IAEtB,aAAa;IACbqB,WAAWT,MAAM,GAAGD,IAAIC,MAAM;IAC9BS,WAAWR,QAAQ,GAAGF,IAAIC,MAAM,CAACC,QAAQ;IAEzCR,OAAOK,MAAM,CAAC;QACb,MAAMY,cAAcjB,OAAOkB,gBAAgB,CAACH;QAC5Cf,OAAOmB,cAAc,CAACF;IACvB;IAEA,mCAAmC;IACnC,IAAIlB,OAAO;IACXC,OAAOY,cAAc,GAAGQ,IAAI,CAAC;QAC5BrB,OAAON,uBAAuBO;IAC/B;IAEA,OAAOD;AACR,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainsleydev/payload-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "Payload CMS utilities, collections and global types for ainsley.dev builds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
},
|
|
33
33
|
"files": ["dist", "bin.js", "types.js", "types.ts", "types.d.ts"],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"
|
|
36
|
-
"@
|
|
35
|
+
"payload": "3.28.1",
|
|
36
|
+
"@payloadcms/db-sqlite": "3.28.1",
|
|
37
|
+
"@payloadcms/richtext-lexical": "3.28.1",
|
|
38
|
+
"@payloadcms/plugin-form-builder": "3.28.1",
|
|
39
|
+
"@payloadcms/plugin-seo": "3.28.1",
|
|
40
|
+
"@lexical/headless": "0.27.1",
|
|
41
|
+
"@lexical/html": "0.27.1",
|
|
37
42
|
"@nouance/payload-better-fields-plugin": "^1.4.1",
|
|
38
|
-
"@payloadcms/db-sqlite": "3.14.0",
|
|
39
|
-
"@payloadcms/richtext-lexical": "3.14.0",
|
|
40
|
-
"@payloadcms/plugin-form-builder": "3.14.0",
|
|
41
|
-
"@payloadcms/plugin-seo": "3.14.0",
|
|
42
43
|
"@types/json-schema": "^7.0.15",
|
|
43
44
|
"chalk": "^5.3.0",
|
|
44
45
|
"commander": "^12.1.0",
|
|
45
46
|
"dotenv": "^16.4.5",
|
|
46
47
|
"jsdom": "^24.1.1",
|
|
47
|
-
"lexical": "0.
|
|
48
|
-
"mime-types": "^2.1.35"
|
|
49
|
-
"payload": "3.14.0"
|
|
48
|
+
"lexical": "0.27.1",
|
|
49
|
+
"mime-types": "^2.1.35"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@ainsleydev/eslint-config": "workspace:*",
|
|
@@ -66,5 +66,11 @@
|
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=18",
|
|
68
68
|
"pnpm": ">=9"
|
|
69
|
+
},
|
|
70
|
+
"pnpm": {
|
|
71
|
+
"onlyBuiltDependencies": ["sharp"],
|
|
72
|
+
"overrides": {
|
|
73
|
+
"lexical": "0.27.1"
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
}
|