@payloadcms/richtext-lexical 3.0.0-beta.90 → 3.0.0-beta.91
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-SUWHJ4HF.js +2 -0
- package/dist/exports/client/Field-SUWHJ4HF.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js +2 -0
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-NI6Z4GBD.js → chunk-OLSILJA6.js} +1 -1
- package/dist/exports/client/{chunk-NI6Z4GBD.js.map → chunk-OLSILJA6.js.map} +1 -1
- package/dist/exports/client/{chunk-G5DTIOPI.js → chunk-TD7O23AB.js} +2 -2
- package/dist/exports/client/{chunk-G5DTIOPI.js.map → chunk-TD7O23AB.js.map} +2 -2
- package/dist/exports/client/{chunk-LGUXX2QH.js → chunk-UJDWBQ2K.js} +2 -2
- package/dist/exports/client/{chunk-LGUXX2QH.js.map → chunk-UJDWBQ2K.js.map} +2 -2
- package/dist/exports/client/{chunk-OKMIHD2R.js → chunk-YL453UOS.js} +2 -2
- package/dist/exports/client/chunk-YSI2QILQ.js +2 -0
- package/dist/exports/client/{chunk-TO2W7Q2G.js.map → chunk-YSI2QILQ.js.map} +2 -2
- package/dist/exports/client/component-2YLEVOFH.js +2 -0
- package/dist/exports/client/component-2YLEVOFH.js.map +7 -0
- package/dist/exports/client/{component-LCAAX56T.js → component-7RAP75FW.js} +2 -2
- package/dist/exports/client/{componentInline-72VZAAHP.js → componentInline-YSHGRL2J.js} +2 -2
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/debug/testRecorder/client/plugin/index.js +187 -363
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +234 -470
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -16
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +59 -123
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +5 -3
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +8 -5
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +6 -4
- 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/inline/client/Toolbar/index.js +53 -94
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +3 -0
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +9 -7
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -109
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +96 -135
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +114 -139
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +7 -25
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +4 -6
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/ui/icons/Caret/index.svg +2 -2
- package/dist/lexical/utils/setFloatingElemPosition.js +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js +16 -1
- package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
- package/package.json +13 -13
- package/dist/exports/client/Field-63NGLPJB.js +0 -2
- package/dist/exports/client/Field-63NGLPJB.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-3QWBV4GT.js +0 -2
- package/dist/exports/client/RelationshipComponent-3QWBV4GT.js.map +0 -7
- package/dist/exports/client/chunk-TO2W7Q2G.js +0 -2
- package/dist/exports/client/component-3OFD6Q4Z.js +0 -2
- package/dist/exports/client/component-3OFD6Q4Z.js.map +0 -7
- /package/dist/exports/client/{chunk-OKMIHD2R.js.map → chunk-YL453UOS.js.map} +0 -0
- /package/dist/exports/client/{component-LCAAX56T.js.map → component-7RAP75FW.js.map} +0 -0
- /package/dist/exports/client/{componentInline-72VZAAHP.js.map → componentInline-YSHGRL2J.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setHandlePosition.js","names":["doesLineHeightAffectElement","setHandlePosition","targetElem","handleElem","anchorElem","leftOffset","style","opacity","transform","targetRect","getBoundingClientRect","targetStyle","window","getComputedStyle","floatingElemRect","anchorElementRect","top","
|
|
1
|
+
{"version":3,"file":"setHandlePosition.js","names":["doesLineHeightAffectElement","setHandlePosition","targetElem","handleElem","anchorElem","leftOffset","style","opacity","transform","targetRect","getBoundingClientRect","targetStyle","window","getComputedStyle","floatingElemRect","anchorElementRect","top","isBlockStyle","some","classes","firstElementChild","classList","contains","actualLineHeight","parseInt","lineHeight","height","left"],"sources":["../../../../../src/lexical/plugins/handles/utils/setHandlePosition.ts"],"sourcesContent":["'use client'\nimport { doesLineHeightAffectElement } from './doesLineHeightAffectElement.js'\n\nexport function setHandlePosition(\n targetElem: HTMLElement | null,\n handleElem: HTMLElement,\n anchorElem: HTMLElement,\n leftOffset: number = 0, // SPACE\n) {\n if (!targetElem) {\n handleElem.style.opacity = '0'\n handleElem.style.transform = 'translate(-10000px, -10000px)'\n return\n }\n\n const targetRect = targetElem.getBoundingClientRect()\n const targetStyle = window.getComputedStyle(targetElem)\n const floatingElemRect = handleElem.getBoundingClientRect()\n const anchorElementRect = anchorElem.getBoundingClientRect()\n\n let top: number\n\n const isBlockStyle = ['lexical-block', 'lexical-upload', 'lexical-relationship'].some((classes) =>\n targetElem.firstElementChild?.classList.contains(classes),\n )\n\n if (!isBlockStyle) {\n // No need to let line height affect the re-positioning of the floating element if line height has no\n // visual effect on the element. Otherwise, the floating element will be positioned incorrectly.\n const actualLineHeight = doesLineHeightAffectElement(targetElem)\n ? parseInt(targetStyle.lineHeight, 10)\n : 0\n\n top = targetRect.top + (actualLineHeight - floatingElemRect.height) / 2 - anchorElementRect.top\n } else {\n top = targetRect.top + 8 - anchorElementRect.top\n }\n\n const left = leftOffset\n\n handleElem.style.opacity = '1'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
@@ -1,3 +1,3 @@
|
|
|
1
1
|
<svg width="7" height="4" viewBox="0 0 7 4" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M1.25 3.5L3.75 1L6.25 3.5"
|
|
3
|
-
</svg>
|
|
2
|
+
<path d="M1.25 3.5L3.75 1L6.25 3.5" />
|
|
3
|
+
</svg>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
const VERTICAL_GAP = 10;
|
|
4
|
-
const HORIZONTAL_OFFSET =
|
|
4
|
+
const HORIZONTAL_OFFSET = 32;
|
|
5
5
|
// TODO: needs refactoring
|
|
6
6
|
// This is supposed to position the floatingElem based on the parent (anchorElem) and the target (targetRect) which is usually the selected text.
|
|
7
7
|
// So basically, it positions the floatingElem either below or above the target (targetRect) and aligns it to the left or center of the target (targetRect).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setFloatingElemPosition.js","names":["VERTICAL_GAP","HORIZONTAL_OFFSET","setFloatingElemPosition","args","alwaysDisplayOnTop","anchorElem","anchorFlippedOffset","floatingElem","horizontalOffset","horizontalPosition","specialHandlingForCaret","targetRect","verticalGap","scrollerElem","parentElement","style","opacity","transform","floatingElemRect","getBoundingClientRect","anchorElementRect","editorScrollerRect","top","height","left","width","addedToTop","right","bottom"],"sources":["../../../src/lexical/utils/setFloatingElemPosition.ts"],"sourcesContent":["'use client'\nconst VERTICAL_GAP = 10\nconst HORIZONTAL_OFFSET =
|
|
1
|
+
{"version":3,"file":"setFloatingElemPosition.js","names":["VERTICAL_GAP","HORIZONTAL_OFFSET","setFloatingElemPosition","args","alwaysDisplayOnTop","anchorElem","anchorFlippedOffset","floatingElem","horizontalOffset","horizontalPosition","specialHandlingForCaret","targetRect","verticalGap","scrollerElem","parentElement","style","opacity","transform","floatingElemRect","getBoundingClientRect","anchorElementRect","editorScrollerRect","top","height","left","width","addedToTop","right","bottom"],"sources":["../../../src/lexical/utils/setFloatingElemPosition.ts"],"sourcesContent":["'use client'\nconst VERTICAL_GAP = 10\nconst HORIZONTAL_OFFSET = 32\n\n// TODO: needs refactoring\n// This is supposed to position the floatingElem based on the parent (anchorElem) and the target (targetRect) which is usually the selected text.\n// So basically, it positions the floatingElem either below or above the target (targetRect) and aligns it to the left or center of the target (targetRect).\n// This is used for positioning the floating toolbar (anchor: richtext editor) and its caret (anchor: floating toolbar)\nexport function setFloatingElemPosition(args: {\n alwaysDisplayOnTop?: boolean\n anchorElem: HTMLElement\n anchorFlippedOffset?: number // Offset which was added to the anchor (for caret, floating toolbar) if it was flipped\n floatingElem: HTMLElement\n horizontalOffset?: number\n horizontalPosition?: 'center' | 'left'\n specialHandlingForCaret?: boolean\n targetRect: ClientRect | null\n verticalGap?: number\n}): number {\n const {\n alwaysDisplayOnTop = false,\n anchorElem,\n anchorFlippedOffset = 0, // Offset which was added to the anchor (for caret, floating toolbar) if it was flipped\n floatingElem,\n horizontalOffset = HORIZONTAL_OFFSET,\n horizontalPosition = 'left',\n specialHandlingForCaret = false,\n targetRect,\n verticalGap = VERTICAL_GAP,\n } = args\n // Returns the top offset if the target was flipped\n const scrollerElem = anchorElem.parentElement\n\n if (targetRect === null || scrollerElem == null) {\n floatingElem.style.opacity = '0'\n floatingElem.style.transform = 'translate(-10000px, -10000px)'\n return\n }\n\n const floatingElemRect = floatingElem.getBoundingClientRect()\n const anchorElementRect = anchorElem.getBoundingClientRect()\n const editorScrollerRect = scrollerElem.getBoundingClientRect()\n\n let top = targetRect.top - floatingElemRect.height - verticalGap\n let left = targetRect.left - horizontalOffset\n\n if (horizontalPosition === 'center') {\n // Calculate left to position floatingElem to the horizontal middle of targetRect\n left = targetRect.left + targetRect.width / 2 - floatingElemRect.width / 2\n }\n\n let addedToTop = 0\n if (!alwaysDisplayOnTop && top < editorScrollerRect.top && !specialHandlingForCaret) {\n addedToTop = floatingElemRect.height + targetRect.height + verticalGap * 2\n\n top += addedToTop\n }\n\n if (horizontalPosition === 'center') {\n if (left + floatingElemRect.width > editorScrollerRect.right) {\n left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset\n } else if (left < editorScrollerRect.left) {\n left = editorScrollerRect.left + horizontalOffset\n }\n } else {\n if (left + floatingElemRect.width > editorScrollerRect.right) {\n left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset\n }\n }\n\n left -= anchorElementRect.left\n\n floatingElem.style.opacity = '1'\n\n if (specialHandlingForCaret && anchorFlippedOffset !== 0) {\n // Floating select toolbar was flipped (positioned below text rather than above). Thus, the caret now needs to be positioned\n // on the other side and rotated.\n top -= anchorElementRect.bottom - anchorFlippedOffset + floatingElemRect.height - 3\n // top += anchorFlippedOffset - anchorElementRect.height - floatingElemRect.height + 2\n floatingElem.style.transform = `translate(${left}px, ${top}px) rotate(180deg)`\n } else {\n top -= anchorElementRect.top\n\n floatingElem.style.transform = `translate(${left}px, ${top}px)`\n }\n\n return addedToTop\n}\n"],"mappings":"AAAA;;AACA,MAAMA,YAAA,GAAe;AACrB,MAAMC,iBAAA,GAAoB;AAE1B;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBC,IAUvC;EACC,MAAM;IACJC,kBAAA,GAAqB,KAAK;IAC1BC,UAAU;IACVC,mBAAA,GAAsB,CAAC;IACvBC,YAAY;IACZC,gBAAA,GAAmBP,iBAAiB;IACpCQ,kBAAA,GAAqB,MAAM;IAC3BC,uBAAA,GAA0B,KAAK;IAC/BC,UAAU;IACVC,WAAA,GAAcZ;EAAY,CAC3B,GAAGG,IAAA;EACJ;EACA,MAAMU,YAAA,GAAeR,UAAA,CAAWS,aAAa;EAE7C,IAAIH,UAAA,KAAe,QAAQE,YAAA,IAAgB,MAAM;IAC/CN,YAAA,CAAaQ,KAAK,CAACC,OAAO,GAAG;IAC7BT,YAAA,CAAaQ,KAAK,CAACE,SAAS,GAAG;IAC/B;EACF;EAEA,MAAMC,gBAAA,GAAmBX,YAAA,CAAaY,qBAAqB;EAC3D,MAAMC,iBAAA,GAAoBf,UA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O,GAAG;EAE7B,IAAIN,uBAAA,IAA2BJ,mBAAA,KAAwB,GAAG;IACxD;IACA;IACAgB,GAAA,IAAOF,iBAAA,CAAkBQ,MAAM,GAAGtB,mBAAA,GAAsBY,gBAAA,CAAiBK,MAAM,GAAG;IAClF;IACAhB,YAAA,CAAaQ,KAAK,CAACE,SAAS,GAAG,aAAaO,IAAA,OAAWF,GAAA,oBAAuB;EAChF,OAAO;IACLA,GAAA,IAAOF,iBAAA,CAAkBE,GAAG;IAE5Bf,YAAA,CAAaQ,KAAK,CAACE,SAAS,GAAG,aAAaO,IAAA,OAAWF,GAAA,KAAQ;EACjE;EAEA,OAAOI,UAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/migrateSlateToLexical/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyC,OAAO,EAAE,MAAM,SAAS,CAAA;AAI7E;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/migrateSlateToLexical/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyC,OAAO,EAAE,MAAM,SAAS,CAAA;AAI7E;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,iBAoC5E"}
|
|
@@ -13,6 +13,7 @@ export async function migrateSlateToLexical({
|
|
|
13
13
|
payload
|
|
14
14
|
}) {
|
|
15
15
|
const collections = payload.config.collections;
|
|
16
|
+
const errors = [];
|
|
16
17
|
const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [null];
|
|
17
18
|
const totalCollections = collections.length;
|
|
18
19
|
for (const locale of allLocales) {
|
|
@@ -22,6 +23,7 @@ export async function migrateSlateToLexical({
|
|
|
22
23
|
await migrateCollection({
|
|
23
24
|
collection,
|
|
24
25
|
cur: curCollection,
|
|
26
|
+
errors,
|
|
25
27
|
locale,
|
|
26
28
|
max: totalCollections,
|
|
27
29
|
payload
|
|
@@ -29,14 +31,21 @@ export async function migrateSlateToLexical({
|
|
|
29
31
|
}
|
|
30
32
|
for (const global of payload.config.globals) {
|
|
31
33
|
await migrateGlobal({
|
|
34
|
+
errors,
|
|
32
35
|
global,
|
|
33
36
|
locale,
|
|
34
37
|
payload
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
40
|
}
|
|
41
|
+
if (errors.length) {
|
|
42
|
+
console.error(`Found ${errors.length} errors::`, JSON.stringify(errors, null, 2));
|
|
43
|
+
} else {
|
|
44
|
+
console.log('Migration successful - no errors');
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
async function migrateGlobal({
|
|
48
|
+
errors,
|
|
40
49
|
global,
|
|
41
50
|
locale,
|
|
42
51
|
payload
|
|
@@ -45,6 +54,7 @@ async function migrateGlobal({
|
|
|
45
54
|
const document = await payload.findGlobal({
|
|
46
55
|
slug: global.slug,
|
|
47
56
|
depth: 0,
|
|
57
|
+
draft: true,
|
|
48
58
|
locale: locale || undefined,
|
|
49
59
|
overrideAccess: true
|
|
50
60
|
});
|
|
@@ -58,20 +68,22 @@ async function migrateGlobal({
|
|
|
58
68
|
slug: global.slug,
|
|
59
69
|
data: document,
|
|
60
70
|
depth: 0,
|
|
71
|
+
draft: document?._status === 'draft',
|
|
61
72
|
locale: locale || undefined
|
|
62
73
|
});
|
|
63
74
|
// Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration
|
|
64
75
|
} catch (e) {
|
|
65
76
|
console.log('Error updating global', e, {
|
|
66
|
-
id: document.id,
|
|
67
77
|
slug: global.slug
|
|
68
78
|
});
|
|
79
|
+
errors.push(e);
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
82
|
}
|
|
72
83
|
async function migrateCollection({
|
|
73
84
|
collection,
|
|
74
85
|
cur,
|
|
86
|
+
errors,
|
|
75
87
|
locale,
|
|
76
88
|
max,
|
|
77
89
|
payload
|
|
@@ -88,6 +100,7 @@ async function migrateCollection({
|
|
|
88
100
|
const documents = await payload.find({
|
|
89
101
|
collection: collection.slug,
|
|
90
102
|
depth: 0,
|
|
103
|
+
draft: true,
|
|
91
104
|
locale: locale || undefined,
|
|
92
105
|
overrideAccess: true,
|
|
93
106
|
page,
|
|
@@ -107,10 +120,12 @@ async function migrateCollection({
|
|
|
107
120
|
collection: collection.slug,
|
|
108
121
|
data: document,
|
|
109
122
|
depth: 0,
|
|
123
|
+
draft: document?._status === 'draft',
|
|
110
124
|
locale: locale || undefined
|
|
111
125
|
});
|
|
112
126
|
// Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration
|
|
113
127
|
} catch (e) {
|
|
128
|
+
errors.push(e);
|
|
114
129
|
console.log('Error updating collection', e, {
|
|
115
130
|
id: document.id,
|
|
116
131
|
slug: collection.slug
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["migrateDocumentFieldsRecursively","migrateSlateToLexical","payload","collections","config","allLocales","localization","localeCodes","totalCollections","length","locale","curCollection","collection","migrateCollection","cur","max","global","globals","migrateGlobal","console","log","slug","document","findGlobal","depth","undefined","overrideAccess","found","migrateDocument","fields","updateGlobal","data","e","
|
|
1
|
+
{"version":3,"file":"index.js","names":["migrateDocumentFieldsRecursively","migrateSlateToLexical","payload","collections","config","errors","allLocales","localization","localeCodes","totalCollections","length","locale","curCollection","collection","migrateCollection","cur","max","global","globals","migrateGlobal","console","error","JSON","stringify","log","slug","document","findGlobal","depth","draft","undefined","overrideAccess","found","migrateDocument","fields","updateGlobal","data","_status","e","push","documentCount","count","totalDocs","page","migrated","documents","find","pagination","docs","id","update"],"sources":["../../../src/utilities/migrateSlateToLexical/index.ts"],"sourcesContent":["import type { CollectionConfig, Field, GlobalConfig, Payload } from 'payload'\n\nimport { migrateDocumentFieldsRecursively } from './migrateDocumentFieldsRecursively.js'\n\n/**\n * This goes through every single collection and field in the payload config, and migrates its data from Slate to Lexical. This does not support sub-fields within slate.\n *\n * It will only translate fields fulfilling all these requirements:\n * - field schema uses lexical editor\n * - lexical editor has SlateToLexicalFeature added\n * - saved field data is in Slate format\n *\n * @param payload\n */\nexport async function migrateSlateToLexical({ payload }: { payload: Payload }) {\n const collections = payload.config.collections\n\n const errors = []\n\n const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [null]\n\n const totalCollections = collections.length\n for (const locale of allLocales) {\n let curCollection = 0\n for (const collection of collections) {\n curCollection++\n await migrateCollection({\n collection,\n cur: curCollection,\n errors,\n locale,\n max: totalCollections,\n payload,\n })\n }\n for (const global of payload.config.globals) {\n await migrateGlobal({\n errors,\n global,\n locale,\n payload,\n })\n }\n }\n\n if (errors.length) {\n console.error(`Found ${errors.length} errors::`, JSON.stringify(errors, null, 2))\n } else {\n console.log('Migration successful - no errors')\n }\n}\n\nasync function migrateGlobal({\n errors,\n global,\n locale,\n payload,\n}: {\n errors: any[]\n global: GlobalConfig\n locale: null | string\n payload: Payload\n}) {\n console.log(`SlateToLexical: ${locale}: Migrating global:`, global.slug)\n\n const document = await payload.findGlobal({\n slug: global.slug,\n depth: 0,\n draft: true,\n locale: locale || undefined,\n overrideAccess: true,\n })\n\n const found = migrateDocument({\n document,\n fields: global.fields,\n })\n\n if (found) {\n try {\n await payload.updateGlobal({\n slug: global.slug,\n data: document,\n depth: 0,\n draft: document?._status === 'draft',\n locale: locale || undefined,\n })\n // Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration\n } catch (e) {\n console.log('Error updating global', e, {\n slug: global.slug,\n })\n errors.push(e)\n }\n }\n}\n\nasync function migrateCollection({\n collection,\n cur,\n errors,\n locale,\n max,\n payload,\n}: {\n collection: CollectionConfig\n cur: number\n errors: any[]\n locale: null | string\n max: number\n payload: Payload\n}) {\n console.log(\n `SlateToLexical: ${locale}: Migrating collection:`,\n collection.slug,\n '(' + cur + '/' + max + ')',\n )\n\n const documentCount = (\n await payload.count({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n })\n ).totalDocs\n\n let page = 1\n let migrated = 0\n\n while (migrated < documentCount) {\n const documents = await payload.find({\n collection: collection.slug,\n depth: 0,\n draft: true,\n locale: locale || undefined,\n overrideAccess: true,\n page,\n pagination: true,\n })\n\n for (const document of documents.docs) {\n migrated++\n console.log(\n `SlateToLexical: ${locale}: Migrating collection:`,\n collection.slug,\n '(' +\n cur +\n '/' +\n max +\n ') - Migrating Document: ' +\n document.id +\n ' (' +\n migrated +\n '/' +\n documentCount +\n ')',\n )\n const found = migrateDocument({\n document,\n fields: collection.fields,\n })\n\n if (found) {\n try {\n await payload.update({\n id: document.id,\n collection: collection.slug,\n data: document,\n depth: 0,\n draft: document?._status === 'draft',\n locale: locale || undefined,\n })\n // Catch it, because some errors were caused by the user previously (e.g. invalid relationships) and will throw an error now, even though they are not related to the migration\n } catch (e) {\n errors.push(e)\n\n console.log('Error updating collection', e, {\n id: document.id,\n slug: collection.slug,\n })\n }\n }\n }\n page++\n }\n}\n\nfunction migrateDocument({\n document,\n fields,\n}: {\n document: Record<string, unknown>\n fields: Field[]\n}): boolean {\n return !!migrateDocumentFieldsRecursively({\n data: document,\n fields,\n found: 0,\n })\n}\n"],"mappings":"AAEA,SAASA,gCAAgC,QAAQ;AAEjD;;;;;;;;;;AAUA,OAAO,eAAeC,sBAAsB;EAAEC;AAAO,CAAwB;EAC3E,MAAMC,WAAA,GAAcD,OAAA,CAAQE,MAAM,CAACD,WAAW;EAE9C,MAAME,MAAA,GAAS,EAAE;EAEjB,MAAMC,UAAA,GAAaJ,OAAA,CAAQE,MAAM,CAACG,YAAY,GAAGL,OAAA,CAAQE,MAAM,CAACG,YAAY,CAACC,WAAW,GAAG,CAAC,KAAK;EAEjG,MAAMC,gBAAA,GAAmB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,MACAC,GAAA,GACA,6BACAU,QAAA,CAASuB,EAAE,GACX,OACAL,QAAA,GACA,MACAJ,aAAA,GACA;MAEJ,MAAMR,KAAA,GAAQC,eAAA,CAAgB;QAC5BP,QAAA;QACAQ,MAAA,EAAQrB,UAAA,CAAWqB;MACrB;MAEA,IAAIF,KAAA,EAAO;QACT,IAAI;UACF,MAAM9B,OAAA,CAAQgD,MAAM,CAAC;YACnBD,EAAA,EAAIvB,QAAA,CAASuB,EAAE;YACfpC,UAAA,EAAYA,UAAA,CAAWY,IAAI;YAC3BW,IAAA,EAAMV,QAAA;YACNE,KAAA,EAAO;YACPC,KAAA,EAAOH,QAAA,EAAUW,OAAA,KAAY;YAC7B1B,MAAA,EAAQA,MAAA,IAAUmB;UACpB;UACA;QACF,EAAE,OAAOQ,CAAA,EAAG;UACVjC,MAAA,CAAOkC,IAAI,CAACD,CAAA;UAEZlB,OAAA,CAAQI,GAAG,CAAC,6BAA6Bc,CAAA,EAAG;YAC1CW,EAAA,EAAIvB,QAAA,CAASuB,EAAE;YACfxB,IAAA,EAAMZ,UAAA,CAAWY;UACnB;QACF;MACF;IACF;IACAkB,IAAA;EACF;AACF;AAEA,SAASV,gBAAgB;EACvBP,QAAQ;EACRQ;AAAM,CAIP;EACC,OAAO,CAAC,CAAClC,gCAAA,CAAiC;IACxCoC,IAAA,EAAMV,QAAA;IACNQ,MAAA;IACAF,KAAA,EAAO;EACT;AACF","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.91",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
"@types/node": "20.12.5",
|
|
68
68
|
"@types/react": "npm:types-react@19.0.0-rc.0",
|
|
69
69
|
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.0",
|
|
70
|
-
"babel-plugin-react-compiler": "0.0.0-experimental-
|
|
70
|
+
"babel-plugin-react-compiler": "0.0.0-experimental-48eb8f4-20240822",
|
|
71
71
|
"babel-plugin-transform-remove-imports": "^1.8.0",
|
|
72
|
-
"esbuild": "0.23.
|
|
72
|
+
"esbuild": "0.23.1",
|
|
73
73
|
"esbuild-sass-plugin": "3.3.1",
|
|
74
|
-
"eslint-plugin-react-compiler": "0.0.0-experimental-
|
|
74
|
+
"eslint-plugin-react-compiler": "0.0.0-experimental-72f06b2-20240822",
|
|
75
75
|
"swc-plugin-transform-remove-imports": "1.15.0",
|
|
76
76
|
"@payloadcms/eslint-config": "3.0.0-beta.59",
|
|
77
|
-
"@payloadcms/
|
|
78
|
-
"@payloadcms/
|
|
79
|
-
"@payloadcms/
|
|
80
|
-
"payload": "3.0.0-beta.
|
|
77
|
+
"@payloadcms/next": "3.0.0-beta.91",
|
|
78
|
+
"@payloadcms/ui": "3.0.0-beta.91",
|
|
79
|
+
"@payloadcms/translations": "3.0.0-beta.91",
|
|
80
|
+
"payload": "3.0.0-beta.91"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@faceless-ui/modal": "3.0.0-beta.2",
|
|
@@ -95,10 +95,10 @@
|
|
|
95
95
|
"lexical": "0.17.0",
|
|
96
96
|
"react": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
|
|
97
97
|
"react-dom": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
|
|
98
|
-
"@payloadcms/
|
|
99
|
-
"payload": "3.0.0-beta.
|
|
100
|
-
"@payloadcms/
|
|
101
|
-
"@payloadcms/
|
|
98
|
+
"@payloadcms/next": "3.0.0-beta.91",
|
|
99
|
+
"payload": "3.0.0-beta.91",
|
|
100
|
+
"@payloadcms/ui": "3.0.0-beta.91",
|
|
101
|
+
"@payloadcms/translations": "3.0.0-beta.91"
|
|
102
102
|
},
|
|
103
103
|
"engines": {
|
|
104
104
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"build:reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm build:swc && pnpm build:babel && pnpm copyfiles && pnpm build:esbuild && pnpm build:types",
|
|
119
119
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
120
120
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
121
|
-
"
|
|
121
|
+
"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",
|
|
122
122
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
123
123
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
124
124
|
"translateNewKeys": "node --no-deprecation --import @swc-node/register/esm-register scripts/translateNewKeys.ts"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as he,b as xe,c as be,d as Ce,e as J,f as $,h as Ee}from"./chunk-TO2W7Q2G.js";import{a as ye,b as M}from"./chunk-NI6Z4GBD.js";import{jsx as V,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as to,FieldError as oo,FieldLabel as no,useField as ro,useFieldProps as io,withCondition as so}from"@payloadcms/ui";import{useCallback as lo}from"react";import{ErrorBoundary as ao}from"react-error-boundary";import{jsx as z}from"react/jsx-runtime";import{LexicalComposer as eo}from"@lexical/react/LexicalComposer.js";import*as Ze from"react";import{useMemo as Xe}from"react";import{c as jt}from"react/compiler-runtime";import{jsx as w,jsxs as ne}from"react/jsx-runtime";import{useLexicalComposerContext as zt}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ht}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Kt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Gt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Wt}from"@lexical/react/LexicalRichTextPlugin.js";import{TabIndentationPlugin as Yt}from"@lexical/react/LexicalTabIndentationPlugin.js";import{BLUR_COMMAND as Ut,COMMAND_PRIORITY_LOW as Ve,FOCUS_COMMAND as Vt}from"lexical";import*as te from"react";import{useEffect as qe,useState as Je}from"react";import{jsx as Ne}from"react/jsx-runtime";import"react";var W=({anchorElem:t,clientProps:e,plugin:n})=>n.position==="floatingAnchorElem"?n.Component&&Ne(n.Component,{anchorElem:t,clientProps:e}):n.Component&&Ne(n.Component,{clientProps:e});import{c as it}from"react/compiler-runtime";import{jsx as st}from"react/jsx-runtime";import{MarkdownShortcutPlugin as lt}from"@lexical/react/LexicalMarkdownShortcutPlugin.js";import"react";var we=()=>{let t=it(2),{editorConfig:e}=M(),n;return t[0]!==e.features.markdownTransformers?(n=st(lt,{transformers:e.features.markdownTransformers}),t[0]=e.features.markdownTransformers,t[1]=n):n=t[1],n};import{jsx as Q,jsxs as ke}from"react/jsx-runtime";import{useLexicalComposerContext as ct}from"@lexical/react/LexicalComposerContext.js";import{useFieldProps as Re,useTranslation as Se}from"@payloadcms/ui";import{useCallback as Te,useMemo as ut,useState as dt}from"react";import"react";import*as ve from"react-dom";import{c as at}from"react/compiler-runtime";import"react";function Pe(t,e){let n=at(4),{maxLength:o,minLength:r}=e,a=o===void 0?75:o,m=r===void 0?1:r,p;return n[0]!==t||n[1]!==a||n[2]!==m?(p=c=>{let{query:s}=c,b="[^"+t+xe+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+b+"){0,"+a+"}))$").exec(s);if(l!==null){let i=l[1],g=l[3];if(g.length>=m)return{leadOffset:l.index+i.length,matchingString:g,replaceableString:l[2]}}return null},n[0]=t,n[1]=a,n[2]=m,n[3]=p):p=n[3],p}var A="slash-menu-popup";function mt({isSelected:t,item:e,onClick:n,onMouseEnter:o}){let{field:{richTextComponentMap:r}}=M(),{schemaPath:a}=Re(),{i18n:m}=Se(),p=`${A}__item ${A}__item-${e.key}`;t&&(p+=` ${A}__item--selected`);let c=e.key;return e.label&&(c=typeof e.label=="function"?e.label({i18n:m,richTextComponentMap:r,schemaPath:a}):e.label),c.length>25&&(c=c.substring(0,25)+"..."),ke("button",{"aria-selected":t,className:p,id:A+"__item-"+e.key,onClick:n,onMouseEnter:o,ref:s=>{e.ref={current:s}},role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&Q(e.Icon,{}),Q("span",{className:`${A}__item-text`,children:c})]},e.key)}function Me({anchorElem:t=document.body}){let[e]=ct(),[n,o]=dt(null),{editorConfig:r}=M(),{i18n:a}=Se(),{field:{richTextComponentMap:m}}=M(),{schemaPath:p}=Re(),c=Pe("/",{minLength:0}),s=Te(()=>{let l=[];for(let i of r.features.slashMenu.dynamicGroups){let g=i({editor:e,queryString:n});l=l.concat(g)}return l},[e,n,r?.features]),b=ut(()=>{let l=[];for(let i of r?.features.slashMenu.groups??[])l.push(i);if(n){l=l.map(g=>{let h=g.items.filter(d=>{let f=d.key;return d.label&&(f=typeof d.label=="function"?d.label({i18n:a,richTextComponentMap:m,schemaPath:p}):d.label),new RegExp(n,"gi").exec(f)?!0:d.keywords!=null?d.keywords.some(u=>new RegExp(n,"gi").exec(u)):!1});return h.length?{...g,items:h}:null}),l=l.filter(g=>g!=null);let i=s();for(let g of i){let h=l.find(d=>d.key===g.key);h?l=l.filter(d=>d.key!==g.key):h={...g,items:[]},h?.items?.length&&(h.items=h.items.concat(h.items)),l.push(h)}}return l},[s,n,r?.features,a]),y=Te((l,i,g,h)=>{i&&e.update(()=>{i.remove()}),l.onSelect({editor:e,queryString:h}),g()},[e]);return Q(Ce,{anchorElem:t,groups:b,menuRenderFn:(l,{selectItemAndCleanUp:i,selectedItemKey:g,setSelectedItemKey:h})=>l.current&&b.length?ve.createPortal(Q("div",{className:A,children:b.map(d=>{let f=d.key;return d.label&&(f=typeof d.label=="function"?d.label({i18n:a,richTextComponentMap:m,schemaPath:p}):d.label),ke("div",{className:`${A}__group ${A}__group-${d.key}`,children:[Q("div",{className:`${A}__group-title`,children:f}),d.items.map((u,x)=>Q(mt,{index:x,isSelected:g===u.key,item:u,onClick:()=>{h(u.key),i(u)},onMouseEnter:()=>{h(u.key)}},u.key))]},d.key)})}),l.current):null,onQueryChange:o,onSelectItem:y,triggerFn:c})}import{c as xt}from"react/compiler-runtime";import{jsx as fe}from"react/jsx-runtime";import{useLexicalComposerContext as bt}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as Ct}from"lexical";import*as Ae from"react";import{useEffect as Be,useRef as Et,useState as Nt}from"react";import{createPortal as wt}from"react-dom";var X=(t,e,n,o,r=50,a=25)=>{let m=0;if(t&&!t.contains(o)){let{bottom:p,left:c,right:s,top:b}=t.getBoundingClientRect(),y=b+window.scrollY,l=p+window.scrollY;if(n<y-a||n>l+a||e<c-r||e>s+r)return-1;(e<c||e>s)&&(m=e<c?e-c:e-s)}return m};import{$getNodeByKey as ie}from"lexical";function j(t){let e=t.getBoundingClientRect(),n=getComputedStyle(t).getPropertyValue("transform");if(!n||n==="none")return e;let o=n.split(",").pop();return e.y=e.y-Number(o.replace(")","")),e}function re(t){let e=(c,s)=>c?parseFloat(window.getComputedStyle(c)[s]):0,{marginBottom:n,marginTop:o}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),a=e(t.nextElementSibling,"marginTop"),m=Math.max(parseFloat(o),r);return{marginBottom:Math.max(parseFloat(n),a),marginTop:m}}import{$getRoot as ft}from"lexical";function Y(t){return t.getEditorState().read(()=>ft().getChildrenKeys())}var pt=1,gt=-1,Ie=0,D={props:null,result:null};function ht(t,e,n=20){let o=t.x-e.x,r=t.y-e.y;return o*o+r*r<=n*n}function Z(t){let{anchorElem:e,cache_threshold:n=20,editor:o,fuzzy:r=!1,horizontalOffset:a=0,point:{x:m,y:p},startIndex:c=0,useEdgeAsDefault:s=!1,verbose:b=!1}=t;if(n>0&&D.props&&D.result&&D.props.fuzzy===t.fuzzy&&D.props.horizontalOffset===t.horizontalOffset&&D.props.useEdgeAsDefault===t.useEdgeAsDefault&&ht(D.props.point,t.point,n))return D.result;let y=e.getBoundingClientRect(),l=Y(o),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return o.getEditorState().read(()=>{if(s){let[d,f]=[o.getElementByKey(l[0]),o.getElementByKey(l[l.length-1])],[u,x]=[j(d),j(f)];if(u&&x&&(p<u.top?(i.blockElem=d,i.distance=u.top-p,i.blockNode=ie(l[0]),i.foundAtIndex=0):p>x.bottom&&(i.distance=p-x.bottom,i.blockNode=ie(l[l.length-1]),i.blockElem=f,i.foundAtIndex=l.length-1),i?.blockElem))return{blockElem:null,isFoundNodeEmptyParagraph:!1}}let g=c,h=Ie;for(;g>=0&&g<l.length;){let d=l[g],f=o.getElementByKey(d);if(f===null)break;let u=new $(m+a,p),x=Ee.fromDOMRect(j(f)),{marginBottom:C,marginTop:S}=re(f),k=x.generateNewRect({bottom:x.bottom+C,left:y.left,right:y.right,top:x.top-S}),{distance:N,isOnBottomSide:I,isOnTopSide:R}=k.distanceFromPoint(u);if(N===0){i.blockElem=f,i.blockNode=ie(d),i.foundAtIndex=g,i.distance=N,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&N<i.distance&&(i.blockElem=f,i.blockNode=ie(d),i.distance=N,i.foundAtIndex=g);h===Ie&&(R?h=gt:I?h=pt:h=1/0),g+=h}}),D.props=t,D.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function se(t,e){return!!t.closest(`.${e}`)}var yt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Le(t){if(!t||yt.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 le(t,e,n,o=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),a=window.getComputedStyle(t),m=e.getBoundingClientRect(),p=n.getBoundingClientRect(),c;if(r.height<60)c=r.top-m.height/2-p.top+r.height/2-1;else{let y=Le(t)?parseInt(a.lineHeight,10):0;c=r.top+(y-m.height)/2-p.top-1}let b=o;e.style.opacity="1",e.style.transform=`translate(${b}px, ${c}px)`}var Pt="add-block-menu",ae=1/0;function Tt(t){return t===0?1/0:ae>=0&&ae<t?ae:Math.floor(t/2)}function kt(t,e,n){let o=xt(15),r=e.parentElement,{editorConfig:a}=M(),m=a?.admin?.hideGutter?-24:12,p=Et(null),[c,s]=Nt(null),b,y;o[0]!==r||o[1]!==t||o[2]!==e||o[3]!==c?(b=()=>{let d=function(u){let x=u.target;if(!J(x))return;let C=X(r,u.pageX,u.pageY,x);if(C===-1){s(null);return}if(se(x,Pt))return;let S=Y(t),{blockElem:k,blockNode:N,foundAtIndex:I}=Z({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-C,point:new $(u.x,u.y),returnEmptyParagraphs:!0,startIndex:Tt(S.length),useEdgeAsDefault:!1});ae=I,k&&(c?.node!==N||c?.elem!==k)&&s({elem:k,node:N})};return document?.addEventListener("mousemove",d),()=>{document?.removeEventListener("mousemove",d)}},y=[r,e,t,c],o[0]=r,o[1]=t,o[2]=e,o[3]=c,o[4]=b,o[5]=y):(b=o[4],y=o[5]),Be(b,y);let l;o[6]!==e||o[7]!==c||o[8]!==m?(l=[e,c,m],o[6]=e,o[7]=c,o[8]=m,o[9]=l):l=o[9],Be(()=>{p.current&&c?.node&&le(c?.elem,p.current,e,m)},l);let i;o[10]!==c||o[11]!==t?(i=d=>{let f;f=c,f?.node&&(t.update(()=>{let u=!0;if((f.node.getType()!=="paragraph"||f.node.getTextContent()!=="")&&(u=!1),!u){let x=Ct();f.node.insertAfter(x),setTimeout(()=>{f={elem:t.getElementByKey(x.getKey()),node:x},s(f)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),f.node&&"select"in f.node&&typeof f.node.select=="function"&&f.node.select()})},1),setTimeout(()=>{t.dispatchCommand(be,{node:f.node})},2),d.stopPropagation(),d.preventDefault())},o[10]=c,o[11]=t,o[12]=i):i=o[12];let g=i,h;return o[13]!==g?(h=d=>{g(d)},o[13]=g,o[14]=h):h=o[14],wt(fe(Ae.Fragment,{children:fe("button",{className:"icon add-block-menu",onClick:h,ref:p,type:"button",children:fe("div",{className:n?"icon":""})})}),e)}function De(t){let{anchorElem:e}=t,n=e===void 0?document.body:e,[o]=bt();return kt(o,n,o._editable)}import{c as vt}from"react/compiler-runtime";import{jsx as ce,jsxs as Mt}from"react/jsx-runtime";import{useLexicalComposerContext as It}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as _e}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as $e,$getNodeByKey as Lt}from"lexical";import*as Ge from"react";import{useEffect as pe,useRef as ue,useState as je}from"react";import{createPortal as Bt}from"react-dom";function Fe(t,e,n){if(!t.current)return;let{left:o,top:r}=n.getBoundingClientRect(),a=j(e),m=a.width,p=a.height,c=a.top-r,s=a.left-o;t.current.style.border="2px solid green",t.current.style.boxSizing="border-box",t.current.style.height=p+"px",t.current.style.pointerEvents="none",t.current.style.position="absolute",t.current.style.top=c+"px",t.current.style.left=s+"px",t.current.style.width=m+"px",t.current.style.zIndex="1000",t.current.style.opacity="0.5"}var ee=25,Rt=-24,St=!1,U=0;function Oe(t,e,n,o,r,a,m,p,c,s=!1){let{height:b,top:y}=o.getBoundingClientRect(),{top:l,width:i}=m.getBoundingClientRect(),{marginBottom:g,marginTop:h}=re(o),d=y,f=a>=y+b/2+window.scrollY,u=!1;if(r?.elem)if(o!==r?.elem)(f&&r?.elem&&r?.elem===o.nextElementSibling||!f&&r?.elem&&r?.elem===o.previousElementSibling)&&(U++,U<200&&(u=!0));else{U++;let N=r?.boundingBox?.y,I=o.getBoundingClientRect().y;(f===r?.isBelow&&N===I||U<200)&&(u=!1)}if(u)return{isBelow:f,willStayInSamePosition:u};s?d+=b/2:f?d+=b+g/2:d-=h/2;let x=0;s||(f?x=-ee:x=ee);let C=d-l+x,S=Rt-e;n.style.width=`calc(${i}px - ${t})`,n.style.opacity=".4";let k=12;return s?n.style.transform=`translate(${S}px, ${C-ee}px)`:f?(o.style.marginBottom=ee*2+k+"px",n.style.transform=`translate(${S}px, calc(${C}px - 0px))`):(o.style.marginTop=ee*2+k+"px",n.style.transform=`translate(${S}px, calc(${C-ee*2}px - 0px))`),St&&Fe(c,o,m),r.elem.style.opacity="",r?.elem===o?f?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop=""),U=0,{isBelow:f,willStayInSamePosition:u}}var At="draggable-block-menu",ze="application/x-lexical-drag-block",oe=1/0;function He(t){return t===0?1/0:oe>=0&&oe<t?oe:Math.floor(t/2)}function Dt(t,e){let{transform:n}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=n})}function Ke(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Ft(t,e,n){let o=vt(19),r=e.parentElement,a=ue(null),m=ue(null),p=ue(null),c=ue(!1),[s,b]=je(null),[y,l]=je(null),{editorConfig:i}=M(),g=i?.admin?.hideGutter?-44:-8,h,d;o[0]!==r||o[1]!==t||o[2]!==e||o[3]!==s?(h=()=>{let N=function(R){let E=R.target;if(!J(E))return;let v=X(r,R.pageX,R.pageY,E);if(v===-1){b(null);return}if(se(E,At))return;let H=Y(t),{blockElem:B,foundAtIndex:F,isFoundNodeEmptyParagraph:O}=Z({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-v,point:new $(R.x,R.y),startIndex:He(H.length),useEdgeAsDefault:!1,verbose:!1});oe=F,!(!B&&!O)&&s!==B&&b(B)};return document?.addEventListener("mousemove",N),()=>{document?.removeEventListener("mousemove",N)}},d=[r,e,t,s],o[0]=r,o[1]=t,o[2]=e,o[3]=s,o[4]=h,o[5]=d):(h=o[4],d=o[5]),pe(h,d);let f,u;o[6]!==s||o[7]!==e||o[8]!==g?(f=()=>{a.current&&le(s,a.current,e,g)},u=[e,s,g],o[6]=s,o[7]=e,o[8]=g,o[9]=f,o[10]=u):(f=o[9],u=o[10]),pe(f,u);let x=i?.admin?.hideGutter,C;return o[11]!==r||o[12]!==g||o[13]!==e||o[14]!==t||o[15]!==y||o[16]!==s||o[17]!==x?(C=[r,g,e,t,y,s,x],o[11]=r,o[12]=g,o[13]=e,o[14]=t,o[15]=y,o[16]=s,o[17]=x,o[18]=C):C=o[18],pe(()=>{let N=function(E){if(!c.current)return!1;let[v]=_e(E);if(v)return!1;let{pageY:H,target:B}=E;if(!J(B))return!1;let F=X(r,E.pageX,E.pageY,B,100,50),O=Y(t),{blockElem:T,foundAtIndex:K,isFoundNodeEmptyParagraph:L}=Z({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-F,point:new $(E.x,E.y),startIndex:He(O.length),useEdgeAsDefault:!0,verbose:!0});oe=K;let G=m.current;if(T===null||G===null)return!1;if(s!==T){let{isBelow:_,willStayInSamePosition:me}=Oe(i?.admin?.hideGutter?"0px":"3rem",g+(i?.admin?.hideGutter?a?.current?.getBoundingClientRect()?.width??0:-(a?.current?.getBoundingClientRect()?.width??0)),G,T,y,H,e,E,p,L);E.preventDefault(),me||l({boundingBox:T.getBoundingClientRect(),elem:T,isBelow:_})}else Ke(G,y?.elem),l({boundingBox:T.getBoundingClientRect(),elem:T,isBelow:!1});return!0},I=function(E){if(!c.current)return!1;let[v]=_e(E);if(v)return!1;let{dataTransfer:H,pageY:B,target:F}=E,O=H?.getData(ze)||"";return t.update(()=>{let T=Lt(O);if(!T||!J(F))return!1;let K=X(r,E.pageX,E.pageY,F,100,50),{blockElem:L,isFoundNodeEmptyParagraph:G}=Z({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-K,point:new $(E.x,E.y),useEdgeAsDefault:!0});if(!L)return!1;let _=$e(L);if(!_)return!1;if(_===T)return!0;let{height:me,top:ot}=j(L),nt=B>=ot+me/2+window.scrollY;G?(_.insertBefore(T),_.remove()):nt?_.insertAfter(T):_.insertBefore(T),s!==null&&b(null),document.querySelectorAll(".lexical-block-highlighter").forEach(q=>{q.remove()});let rt=t.getElementByKey(T.getKey());setTimeout(()=>{let q=rt.getBoundingClientRect(),P=document.createElement("div");P.className="lexical-block-highlighter",document.documentElement.getAttribute("data-theme")==="dark"?P.style.backgroundColor="white":P.style.backgroundColor="black",P.style.transition="opacity 0.1s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${q.height+8}px`,P.style.width=`${q.width+8}px`,P.style.top=`${q.top+window.scrollY-4}px`,P.style.left=`${q.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},1e3)},3e3)},120)}),!0};return document.addEventListener("dragover",N),document.addEventListener("drop",I),()=>{document.removeEventListener("dragover",N),document.removeEventListener("drop",I)}},C),Bt(Mt(Ge.Fragment,{children:[ce("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:function(){c.current=!1,Ke(m.current,y?.elem)},onDragStart:function(I){let R=I.dataTransfer;if(!R||!s)return;Dt(R,s);let E;E="",t.update(()=>{let v=$e(s);v&&(E=v.getKey())}),c.current=!0,R.setData(ze,E)},ref:a,children:ce("div",{className:n?"icon":""})}),ce("div",{className:"draggable-block-target-line",ref:m}),ce("div",{className:"debug-highlight",ref:p})]}),e)}function We(t){let{anchorElem:e}=t,n=e===void 0?document.body:e,[o]=It();return Ft(o,n,o._editable)}import{c as Ot}from"react/compiler-runtime";import{jsx as Ye}from"react/jsx-runtime";import{ContentEditable as _t}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as $t}from"@payloadcms/ui";import"react";function Ue(t){let e=Ot(3),{className:n}=t,{t:o}=$t(),r;return e[0]!==o||e[1]!==n?(r=Ye(_t,{"aria-placeholder":o("lexical:general:placeholder"),className:n??"ContentEditable__root",placeholder:Ye("p",{className:"editor-placeholder",children:o("lexical:general:placeholder")})}),e[0]=o,e[1]=n,e[2]=r):r=e[2],r}var Qe=t=>{let e=jt(22),{editorConfig:n,editorContainerRef:o,onChange:r}=t,a=M(),[m]=zt(),[p,c]=Je(null),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=u=>{u!==null&&c(u)},e[0]=s):s=e[0];let b=s,y,l;e[1]!==a||e[2]!==m?(y=()=>{if(!a?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}a?.parentEditor?.uuid&&a.parentEditor?.registerChild(a.uuid,a);let u=()=>{a.focusEditor(a)},x=()=>{a.blurEditor(a)},C=m.registerCommand(Vt,()=>(u(),!0),Ve),S=m.registerCommand(Ut,()=>(x(),!0),Ve);return()=>{C(),S(),a.parentEditor?.unregisterChild?.(a.uuid)}},l=[m,a],e[1]=a,e[2]=m,e[3]=y,e[4]=l):(y=e[3],l=e[4]),qe(y,l);let[i,g]=Je(!1),h,d;e[5]!==i?(h=()=>{let u=()=>{let x=window.matchMedia("(max-width: 768px)").matches;x!==i&&g(x)};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},d=[i],e[5]=i,e[6]=h,e[7]=d):(h=e[6],d=e[7]),qe(h,d);let f;if(e[8]!==n.features||e[9]!==r||e[10]!==p||e[11]!==i||e[12]!==m||e[13]!==o){let u;e[15]!==r?(u=(C,S,k)=>{(!k.has("focus")||k.size>1)&&r?.(C,S,k)},e[15]=r,e[16]=u):u=e[16];let x;e[17]!==p||e[18]!==i||e[19]!==m||e[20]!==n?(x=p&&ne(te.Fragment,{children:[!i&&m.isEditable()&&ne(te.Fragment,{children:[w(We,{anchorElem:p}),w(De,{anchorElem:p})]}),n.features.plugins.map(C=>{if(C.position==="floatingAnchorElem"&&!(C.desktopOnly===!0&&i))return w(W,{anchorElem:p,clientProps:C.clientProps,plugin:C},C.key)}),m.isEditable()&&w(te.Fragment,{children:w(Me,{anchorElem:p})})]}),e[17]=p,e[18]=i,e[19]=m,e[20]=n,e[21]=x):x=e[21],f=ne(te.Fragment,{children:[n.features.plugins.map(qt),ne("div",{className:"editor-container",ref:o,children:[n.features.plugins.map(Jt),w(Wt,{ErrorBoundary:Ht,contentEditable:w("div",{className:"editor-scroller",children:w("div",{className:"editor",ref:b,children:w(Ue,{})})})}),w(Gt,{ignoreSelectionChange:!0,onChange:u}),x,m.isEditable()&&ne(te.Fragment,{children:[w(Kt,{}),n?.features?.markdownTransformers?.length>0&&w(we,{})]}),w(Yt,{}),n.features.plugins.map(Qt),n.features.plugins.map(Xt)]}),n.features.plugins.map(Zt)]}),e[8]=n.features,e[9]=r,e[10]=p,e[11]=i,e[12]=m,e[13]=o,e[14]=f}else f=e[14];return f};function qt(t){if(t.position==="aboveContainer")return w(W,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="top")return w(W,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="normal")return w(W,{clientProps:t.clientProps,plugin:t},t.key)}function Xt(t){if(t.position==="bottom")return w(W,{clientProps:t.clientProps,plugin:t},t.key)}function Zt(t){if(t.position==="belowContainer")return w(W,{clientProps:t.clientProps,plugin:t},t.key)}var et=({children:t,providers:e})=>{if(!e?.length)return t;let n=e[0];return e.length>1?z(n,{children:z(et,{providers:e.slice(1),children:t})}):z(n,{children:t})},tt=t=>{let{editorConfig:e,field:n,onChange:o,path:r,readOnly:a,value:m}=t,p=M(),c=Ze.useRef(null),s=Xe(()=>{let y=m;return e?.features?.hooks?.load?.length&&e.features.hooks.load.forEach(l=>{y=l({incomingEditorState:y})}),y},[e,m]),b=Xe(()=>{if(s&&typeof s!="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(s));if(s&&Array.isArray(s)&&!("root"in s))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(s&&"jsonContent"in s)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:a!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:e.lexical.namespace,nodes:[...he({editorConfig:e})],onError:y=>{throw y},theme:e.lexical.theme}},[e,s,a]);return b?z(eo,{initialConfig:b,children:z(ye,{editorConfig:e,editorContainerRef:c,field:n,parentContext:p,children:z(et,{providers:e.features.providers,children:z(Qe,{editorConfig:e,editorContainerRef:c,onChange:o})})})},r):z("p",{children:"Loading..."})};import"./bundled.css";var de="rich-text-lexical",co=t=>{let{descriptionProps:e,editorConfig:n,errorProps:o,field:{name:r,_path:a,admin:{className:m,components:{Description:p,Error:c,Label:s},readOnly:b,style:y,width:l}={},label:i,required:g},field:h,labelProps:d,readOnly:f,validate:u}=t,x=f||b,C=lo((K,L)=>{if(typeof u=="function")return u(K,{...L,props:t,required:g})},[u,g]),{path:S,readOnly:k}=io(),N=ro({path:S??a??r,validate:C}),{formInitializing:I,formProcessing:R,initialValue:E,path:v,setValue:H,showError:B,value:F}=N,O=x||k||R||I,T=[de,"field-type",m,B&&"error",O&&`${de}--read-only`,n?.admin?.hideGutter!==!0?`${de}--show-gutter`:null].filter(Boolean).join(" ");return ge("div",{className:T,style:{...y,width:l},children:[V(oo,{CustomError:c,field:h,path:v,...o||{},alignCaret:"left"}),V(no,{Label:s,field:h,label:i,required:g,...d||{}}),ge("div",{className:`${de}__wrap`,children:[V(ao,{fallbackRender:uo,onReset:()=>{},children:V(tt,{editorConfig:n,field:h,onChange:K=>{let L=K.toJSON();n?.features?.hooks?.save?.length&&n.features.hooks.save.forEach(G=>{L=G({incomingEditorState:L})}),H(L)},path:v,readOnly:O,value:F},JSON.stringify({initialValue:E,path:v}))}),V(to,{Description:p,field:h,...e||{}})]})]},v)};function uo({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[V("p",{children:"Something went wrong:"}),V("pre",{style:{color:"red"},children:t.message})]})}var Tr=so(co);export{Tr as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-63NGLPJB.js.map
|