@payloadcms/richtext-lexical 3.57.0-internal.795616e → 3.57.0-internal.801ab5a
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 +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/client/pendingComponent-WFSCE6LJ.js +2 -0
- package/dist/exports/client/pendingComponent-WFSCE6LJ.js.map +7 -0
- package/dist/features/heading/client/index.d.ts.map +1 -1
- package/dist/features/heading/client/index.js +0 -60
- package/dist/features/heading/client/index.js.map +1 -1
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +0 -1
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/upload/client/index.d.ts.map +1 -1
- package/dist/features/upload/client/index.js +2 -1
- package/dist/features/upload/client/index.js.map +1 -1
- package/dist/features/upload/client/nodes/PendingUploadNode.d.ts +17 -0
- package/dist/features/upload/client/nodes/PendingUploadNode.d.ts.map +1 -0
- package/dist/features/upload/client/nodes/PendingUploadNode.js +57 -0
- package/dist/features/upload/client/nodes/PendingUploadNode.js.map +1 -0
- package/dist/features/upload/client/nodes/UploadNode.d.ts +2 -7
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +3 -27
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/pendingComponent/index.d.ts +7 -0
- package/dist/features/upload/client/pendingComponent/index.d.ts.map +1 -0
- package/dist/features/upload/client/pendingComponent/index.js +14 -0
- package/dist/features/upload/client/pendingComponent/index.js.map +1 -0
- package/dist/features/upload/client/plugin/index.d.ts +6 -0
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js +292 -22
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/index.d.ts.map +1 -1
- package/dist/features/upload/server/index.js +4 -1
- package/dist/features/upload/server/index.js.map +1 -1
- package/dist/features/upload/server/nodes/PendingUploadNode.d.ts +42 -0
- package/dist/features/upload/server/nodes/PendingUploadNode.d.ts.map +1 -0
- package/dist/features/upload/server/nodes/PendingUploadNode.js +92 -0
- package/dist/features/upload/server/nodes/PendingUploadNode.js.map +1 -0
- package/dist/features/upload/server/nodes/UploadNode.d.ts +0 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js +3 -37
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/server/nodes/conversions.d.ts +9 -0
- package/dist/features/upload/server/nodes/conversions.d.ts.map +1 -0
- package/dist/features/upload/server/nodes/conversions.js +53 -0
- package/dist/features/upload/server/nodes/conversions.js.map +1 -0
- package/dist/field/bundled.css +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
3
|
+
import { $applyNodeReplacement } from 'lexical';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { $convertPendingUploadElement } from './conversions.js';
|
|
6
|
+
export class PendingUploadServerNode extends DecoratorBlockNode {
|
|
7
|
+
__data;
|
|
8
|
+
constructor({
|
|
9
|
+
data,
|
|
10
|
+
format,
|
|
11
|
+
key
|
|
12
|
+
}) {
|
|
13
|
+
super(format, key);
|
|
14
|
+
this.__data = data;
|
|
15
|
+
}
|
|
16
|
+
static clone(node) {
|
|
17
|
+
return new this({
|
|
18
|
+
data: node.__data,
|
|
19
|
+
format: node.__format,
|
|
20
|
+
key: node.__key
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
static getType() {
|
|
24
|
+
return 'pendingUpload';
|
|
25
|
+
}
|
|
26
|
+
static importDOM() {
|
|
27
|
+
return {
|
|
28
|
+
img: node => ({
|
|
29
|
+
conversion: domNode => $convertPendingUploadElement(domNode, $createPendingUploadServerNode),
|
|
30
|
+
priority: 0
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
static importJSON(serializedNode) {
|
|
35
|
+
const importedData = {
|
|
36
|
+
formID: serializedNode.formID,
|
|
37
|
+
src: serializedNode.src
|
|
38
|
+
};
|
|
39
|
+
const node = $createPendingUploadServerNode({
|
|
40
|
+
data: importedData
|
|
41
|
+
});
|
|
42
|
+
node.setFormat(serializedNode.format);
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
static isInline() {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
decorate() {
|
|
49
|
+
// @ts-expect-error
|
|
50
|
+
return /*#__PURE__*/_jsx(RawUploadComponent, {
|
|
51
|
+
data: this.__data,
|
|
52
|
+
format: this.__format,
|
|
53
|
+
nodeKey: this.getKey()
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exportDOM() {
|
|
57
|
+
const element = document.createElement('img');
|
|
58
|
+
element.setAttribute('data-lexical-pending-upload-form-id', String(this.__data?.formID));
|
|
59
|
+
return {
|
|
60
|
+
element
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exportJSON() {
|
|
64
|
+
return {
|
|
65
|
+
...super.exportJSON(),
|
|
66
|
+
...this.getData(),
|
|
67
|
+
type: 'pendingUpload',
|
|
68
|
+
version: 1
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
getData() {
|
|
72
|
+
return this.getLatest().__data;
|
|
73
|
+
}
|
|
74
|
+
setData(data) {
|
|
75
|
+
const writable = this.getWritable();
|
|
76
|
+
writable.__data = data;
|
|
77
|
+
}
|
|
78
|
+
updateDOM() {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function $createPendingUploadServerNode({
|
|
83
|
+
data
|
|
84
|
+
}) {
|
|
85
|
+
return $applyNodeReplacement(new PendingUploadServerNode({
|
|
86
|
+
data
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
export function $isPendingUploadServerNode(node) {
|
|
90
|
+
return node instanceof PendingUploadServerNode;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=PendingUploadNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingUploadNode.js","names":["DecoratorBlockNode","$applyNodeReplacement","React","$convertPendingUploadElement","PendingUploadServerNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","domNode","$createPendingUploadServerNode","priority","importJSON","serializedNode","importedData","formID","src","setFormat","isInline","decorate","_jsx","RawUploadComponent","nodeKey","getKey","exportDOM","element","document","createElement","setAttribute","String","exportJSON","getData","type","version","getLatest","setData","writable","getWritable","updateDOM","$isPendingUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/PendingUploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport { $convertPendingUploadElement } from './conversions.js'\n\nexport type PendingUploadData = {\n /**\n * ID that corresponds to the bulk upload form ID\n */\n formID: string\n /**\n * src value of the image dom element\n */\n src: string\n}\n\nexport type SerializedPendingUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'pendingUpload'\n} & Spread<PendingUploadData, SerializedDecoratorBlockNode>\n\nexport class PendingUploadServerNode extends DecoratorBlockNode {\n __data: PendingUploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: PendingUploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: PendingUploadServerNode): PendingUploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'pendingUpload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) =>\n $convertPendingUploadElement(domNode, $createPendingUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedPendingUploadNode): PendingUploadServerNode {\n const importedData: PendingUploadData = {\n formID: serializedNode.formID,\n src: serializedNode.src,\n }\n\n const node = $createPendingUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-pending-upload-form-id', String(this.__data?.formID))\n\n return { element }\n }\n\n override exportJSON(): SerializedPendingUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'pendingUpload',\n version: 1,\n }\n }\n\n getData(): PendingUploadData {\n return this.getLatest().__data\n }\n\n setData(data: PendingUploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createPendingUploadServerNode({\n data,\n}: {\n data: PendingUploadData\n}): PendingUploadServerNode {\n return $applyNodeReplacement(new PendingUploadServerNode({ data }))\n}\n\nexport function $isPendingUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is PendingUploadServerNode {\n return node instanceof PendingUploadServerNode\n}\n"],"mappings":";AAWA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,YAAYC,KAAA,MAAW;AAEvB,SAASC,4BAA4B,QAAQ;AAkB7C,OAAO,MAAMC,uBAAA,SAAgCJ,kBAAA;EAC3CK,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,E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,OAAO;MACL,GAAG,KAAK,CAACA,UAAA,EAAY;MACrB,GAAG,IAAI,CAACC,OAAO,EAAE;MACjBC,IAAA,EAAM;MACNC,OAAA,EAAS;IACX;EACF;EAEAF,QAAA,EAA6B;IAC3B,OAAO,IAAI,CAACG,SAAS,GAAGtC,MAAM;EAChC;EAEAuC,QAAQrC,IAAuB,EAAQ;IACrC,MAAMsC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAASxC,MAAM,GAAGE,IAAA;EACpB;EAESwC,UAAA,EAAmB;IAC1B,OAAO;EACT;AACF;AAEA,OAAO,SAAS5B,+BAA+B;EAC7CZ;AAAI,CAGL;EACC,OAAON,qBAAA,CAAsB,IAAIG,uBAAA,CAAwB;IAAEG;EAAK;AAClE;AAEA,OAAO,SAASyC,2BACdrC,IAAoC;EAEpC,OAAOA,IAAA,YAAgBP,uBAAA;AACzB","ignoreList":[]}
|
|
@@ -38,7 +38,6 @@ export type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonO
|
|
|
38
38
|
value: number | string | TypedUploadCollection[TCollectionSlug];
|
|
39
39
|
};
|
|
40
40
|
}[UploadCollectionSlug];
|
|
41
|
-
export declare function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean;
|
|
42
41
|
export type SerializedUploadNode = {
|
|
43
42
|
children?: never;
|
|
44
43
|
type: 'upload';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EACV,gBAAgB,
|
|
1
|
+
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,O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,EACV,IAAI,EACJ,MAAM,EACN,GAAG,GACJ,EAAE;QACD,IAAI,EAAE,UAAU,CAAA;QAChB,MAAM,CAAC,EAAE,iBAAiB,CAAA;QAC1B,GAAG,CAAC,EAAE,OAAO,CAAA;KACd;WAKe,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;WAQ/C,OAAO,IAAI,MAAM;WAIjB,SAAS,IAAI,gBAAgB,CAAC,gBAAgB,CAAC;WAS/C,UAAU,CAAC,cAAc,EAAE,oBAAoB,GAAG,gBAAgB;IAsBlF,MAAM,CAAC,QAAQ,IAAI,KAAK;IAIf,QAAQ,IAAI,GAAG,CAAC,OAAO;IAIvB,SAAS,IAAI,eAAe;IAQ5B,UAAU,IAAI,oBAAoB;IAS3C,OAAO,IAAI,UAAU;IAIrB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAKtB,SAAS,IAAI,KAAK;CAG5B;AAED,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,GACL,EAAE;IACD,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAA;CAC/D,GAAG,gBAAgB,CAKnB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,gBAAgB,CAE1B"}
|
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
3
2
|
import ObjectID from 'bson-objectid';
|
|
4
3
|
import { $applyNodeReplacement } from 'lexical';
|
|
5
|
-
import
|
|
6
|
-
export function isGoogleDocCheckboxImg(img) {
|
|
7
|
-
return img.parentElement != null && img.parentElement.tagName === 'LI' && img.previousSibling === null && img.getAttribute('aria-roledescription') === 'checkbox';
|
|
8
|
-
}
|
|
9
|
-
function $convertUploadServerElement(domNode) {
|
|
10
|
-
if (domNode.hasAttribute('data-lexical-upload-relation-to') && domNode.hasAttribute('data-lexical-upload-id')) {
|
|
11
|
-
const id = domNode.getAttribute('data-lexical-upload-id');
|
|
12
|
-
const relationTo = domNode.getAttribute('data-lexical-upload-relation-to');
|
|
13
|
-
if (id != null && relationTo != null) {
|
|
14
|
-
const node = $createUploadServerNode({
|
|
15
|
-
data: {
|
|
16
|
-
fields: {},
|
|
17
|
-
relationTo,
|
|
18
|
-
value: id
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
node
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const img = domNode;
|
|
27
|
-
if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
// TODO: Auto-upload functionality here!
|
|
31
|
-
//}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
4
|
+
import { $convertUploadElement } from './conversions.js';
|
|
34
5
|
export class UploadServerNode extends DecoratorBlockNode {
|
|
35
6
|
__data;
|
|
36
7
|
constructor({
|
|
@@ -54,7 +25,7 @@ export class UploadServerNode extends DecoratorBlockNode {
|
|
|
54
25
|
static importDOM() {
|
|
55
26
|
return {
|
|
56
27
|
img: node => ({
|
|
57
|
-
conversion: $
|
|
28
|
+
conversion: domNode => $convertUploadElement(domNode, $createUploadServerNode),
|
|
58
29
|
priority: 0
|
|
59
30
|
})
|
|
60
31
|
};
|
|
@@ -83,12 +54,7 @@ export class UploadServerNode extends DecoratorBlockNode {
|
|
|
83
54
|
return false;
|
|
84
55
|
}
|
|
85
56
|
decorate() {
|
|
86
|
-
|
|
87
|
-
return /*#__PURE__*/_jsx(RawUploadComponent, {
|
|
88
|
-
data: this.__data,
|
|
89
|
-
format: this.__format,
|
|
90
|
-
nodeKey: this.getKey()
|
|
91
|
-
});
|
|
57
|
+
return null;
|
|
92
58
|
}
|
|
93
59
|
exportDOM() {
|
|
94
60
|
const element = document.createElement('img');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.js","names":["DecoratorBlockNode","ObjectID","$applyNodeReplacement","React","isGoogleDocCheckboxImg","img","parentElement","tagName","previousSibling","getAttribute","$convertUploadServerElement","domNode","hasAttribute","id","relationTo","node","$createUploadServerNode","data","fields","value","src","startsWith","UploadServerNode","__data","constructor","format","key","clone","__format","__key","getType","importDOM","conversion","priority","importJSON","serializedNode","version","default","toHexString","importedData","setFormat","isInline","decorate","_jsx","RawUploadComponent","nodeKey","getKey","exportDOM","element","document","createElement","setAttribute","String","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type {\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\n/**\n * UploadDataImproved is a more precise type, and will replace UploadData in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n *\n * @todo Replace UploadData with UploadDataImproved in 4.0\n */\nexport type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nfunction $convertUploadServerElement(domNode: HTMLImageElement): DOMConversionOutput | null {\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createUploadServerNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n const img = domNode\n if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {\n return null\n }\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: $convertUploadServerElement,\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-upload-id', String(this.__data?.value))\n element.setAttribute('data-lexical-upload-relation-to', this.__data?.relationTo)\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n"],"mappings":";AAmBA,SAASA,kBAAkB,QAAQ;AACnC,OAAOC,QAAA,MAAc;AACrB,SAASC,qBAAqB,QAAQ;AACtC,YAAYC,KAAA,M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AC7B,MAAM,EAAEJ,KAAA;IACnE6B,OAAA,CAAQG,YAAY,CAAC,mCAAmC,IAAI,CAAC5B,MAAM,EAAET,UAAA;IAErE,OAAO;MAAEkC;IAAQ;EACnB;EAESK,WAAA,EAAmC;IAC1C,OAAO;MACL,GAAG,KAAK,CAACA,UAAA,EAAY;MACrB,GAAG,IAAI,CAACC,OAAO,EAAE;MACjBC,IAAA,EAAM;MACNnB,OAAA,EAAS;IACX;EACF;EAEAkB,QAAA,EAAsB;IACpB,OAAO,IAAI,CAACE,SAAS,GAAGjC,MAAM;EAChC;EAEAkC,QAAQxC,IAAgB,EAAQ;IAC9B,MAAMyC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAASnC,MAAM,GAAGN,IAAA;EACpB;EAES2C,UAAA,EAAmB;IAC1B,OAAO;EACT;AACF;AAEA,OAAO,SAAS5C,wBAAwB;EACtCC;AAAI,CAGL;EACC,IAAI,CAACA,IAAA,EAAMJ,EAAA,EAAI;IACbI,IAAA,CAAKJ,EAAE,GAAG,IAAIZ,QAAA,CAASoC,OAAO,GAAGC,WAAW;EAC9C;EACA,OAAOpC,qBAAA,CAAsB,IAAIoB,gBAAA,CAAiB;IAAEL,IAAA,EAAMA;EAAmB;AAC/E;AAEA,OAAO,SAAS4C,oBACd9C,IAAoC;EAEpC,OAAOA,IAAA,YAAgBO,gBAAA;AACzB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"UploadNode.js","names":["DecoratorBlockNode","ObjectID","$applyNodeReplacement","$convertUploadElement","UploadServerNode","__data","constructor","data","format","key","clone","node","__format","__key","getType","importDOM","img","conversion","domNode","$createUploadServerNode","priority","importJSON","serializedNode","version","value","id","default","toHexString","importedData","fields","relationTo","setFormat","isInline","decorate","exportDOM","element","document","createElement","setAttribute","String","exportJSON","getData","type","getLatest","setData","writable","getWritable","updateDOM","$isUploadServerNode"],"sources":["../../../../../src/features/upload/server/nodes/UploadNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type {\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\n/**\n * UploadDataImproved is a more precise type, and will replace UploadData in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n *\n * @todo Replace UploadData with UploadDataImproved in 4.0\n */\nexport type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport type SerializedUploadNode = {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n} & Spread<UploadData, SerializedDecoratorBlockNode>\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-upload-id', String(this.__data?.value))\n element.setAttribute('data-lexical-upload-relation-to', this.__data?.relationTo)\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined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,IAAA,EAAMA;EAAmB;AAC/E;AAEA,OAAO,SAASyC,oBACdrC,IAAoC;EAEpC,OAAOA,IAAA,YAAgBP,gBAAA;AACzB","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DOMConversionOutput } from 'lexical';
|
|
2
|
+
import type { $createPendingUploadNode } from '../../client/nodes/PendingUploadNode.js';
|
|
3
|
+
import type { $createUploadNode } from '../../client/nodes/UploadNode.js';
|
|
4
|
+
import type { $createPendingUploadServerNode } from './PendingUploadNode.js';
|
|
5
|
+
import type { $createUploadServerNode } from './UploadNode.js';
|
|
6
|
+
export declare function $convertPendingUploadElement(domNode: HTMLImageElement, $createNode: typeof $createPendingUploadNode | typeof $createPendingUploadServerNode): DOMConversionOutput | null;
|
|
7
|
+
export declare function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean;
|
|
8
|
+
export declare function $convertUploadElement(domNode: HTMLImageElement, $createNode: typeof $createUploadNode | typeof $createUploadServerNode): DOMConversionOutput | null;
|
|
9
|
+
//# sourceMappingURL=conversions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/server/nodes/conversions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AACvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAA;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAE9D,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,OAAO,wBAAwB,GAAG,OAAO,8BAA8B,GACnF,mBAAmB,GAAG,IAAI,CAsB5B;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAOrE;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,OAAO,iBAAiB,GAAG,OAAO,uBAAuB,GACrE,mBAAmB,GAAG,IAAI,CAqB5B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// This file contains functions used to convert dom elements to upload or pending upload lexical nodes. It requires the actual node
|
|
2
|
+
// creation functions to be passed in to stay compatible with both client and server code.
|
|
3
|
+
import ObjectID from 'bson-objectid';
|
|
4
|
+
export function $convertPendingUploadElement(domNode, $createNode) {
|
|
5
|
+
if (domNode.hasAttribute('data-lexical-pending-upload-form-id')) {
|
|
6
|
+
const formID = domNode.getAttribute('data-lexical-pending-upload-form-id');
|
|
7
|
+
if (formID != null) {
|
|
8
|
+
const node = $createNode({
|
|
9
|
+
data: {
|
|
10
|
+
formID,
|
|
11
|
+
src: domNode.getAttribute('src') || ''
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
node
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Create a new pending upload node with a new form ID
|
|
20
|
+
const node = $createNode({
|
|
21
|
+
data: {
|
|
22
|
+
formID: new ObjectID.default().toHexString(),
|
|
23
|
+
src: domNode.getAttribute('src') || ''
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
node
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function isGoogleDocCheckboxImg(img) {
|
|
31
|
+
return img.parentElement != null && img.parentElement.tagName === 'LI' && img.previousSibling === null && img.getAttribute('aria-roledescription') === 'checkbox';
|
|
32
|
+
}
|
|
33
|
+
export function $convertUploadElement(domNode, $createNode) {
|
|
34
|
+
if (domNode.hasAttribute('data-lexical-upload-relation-to') && domNode.hasAttribute('data-lexical-upload-id')) {
|
|
35
|
+
const id = domNode.getAttribute('data-lexical-upload-id');
|
|
36
|
+
const relationTo = domNode.getAttribute('data-lexical-upload-relation-to');
|
|
37
|
+
if (id != null && relationTo != null) {
|
|
38
|
+
const node = $createNode({
|
|
39
|
+
data: {
|
|
40
|
+
fields: {},
|
|
41
|
+
relationTo,
|
|
42
|
+
value: id
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
node
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Auto-upload functionality is handled here by the PendingUploadNode
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=conversions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversions.js","names":["ObjectID","$convertPendingUploadElement","domNode","$createNode","hasAttribute","formID","getAttribute","node","data","src","default","toHexString","isGoogleDocCheckboxImg","img","parentElement","tagName","previousSibling","$convertUploadElement","id","relationTo","fields","value"],"sources":["../../../../../src/features/upload/server/nodes/conversions.ts"],"sourcesContent":["// This file contains functions used to convert dom elements to upload or pending upload lexical nodes. It requires the actual node\n// creation functions to be passed in to stay compatible with both client and server code.\nimport type { DOMConversionOutput } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\n\nimport type { $createPendingUploadNode } from '../../client/nodes/PendingUploadNode.js'\nimport type { $createUploadNode } from '../../client/nodes/UploadNode.js'\nimport type { $createPendingUploadServerNode } from './PendingUploadNode.js'\nimport type { $createUploadServerNode } from './UploadNode.js'\n\nexport function $convertPendingUploadElement(\n domNode: HTMLImageElement,\n $createNode: typeof $createPendingUploadNode | typeof $createPendingUploadServerNode,\n): DOMConversionOutput | null {\n if (domNode.hasAttribute('data-lexical-pending-upload-form-id')) {\n const formID = domNode.getAttribute('data-lexical-pending-upload-form-id')\n\n if (formID != null) {\n const node = $createNode({\n data: {\n formID,\n src: domNode.getAttribute('src') || '',\n },\n })\n return { node }\n }\n }\n // Create a new pending upload node with a new form ID\n const node = $createNode({\n data: {\n formID: new ObjectID.default().toHexString(),\n src: domNode.getAttribute('src') || '',\n },\n })\n return { node }\n}\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nexport function $convertUploadElement(\n domNode: HTMLImageElement,\n $createNode: typeof $createUploadNode | typeof $createUploadServerNode,\n): DOMConversionOutput | null {\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n // Auto-upload functionality is handled here by the PendingUploadNode\n return null\n}\n"],"mappings":"AAAA;AACA;AAGA,OAAOA,QAAA,MAAc;AAOrB,OAAO,SAASC,6BACdC,OAAyB,EACzBC,WAAoF;EAEpF,IAAID,OAAA,CAAQE,YAAY,CAAC,wCAAwC;IAC/D,MAAMC,MAAA,GAASH,OAAA,CAAQI,YAAY,CAAC;IAEpC,IAAID,MAAA,IAAU,MAAM;MAClB,MAAME,IAAA,GAAOJ,WAAA,CAAY;QACvBK,IAAA,EAAM;UACJH,MAAA;UACAI,GAAA,EAAKP,OAAA,CAAQI,YAAY,CAAC,UAAU;QACtC;MACF;MACA,OAAO;QAAEC;MAAK;IAChB;EACF;EACA;EACA,MAAMA,IAAA,GAAOJ,WAAA,CAAY;IACvBK,IAAA,EAAM;MACJH,MAAA,EAAQ,IAAIL,QAAA,CAASU,OAAO,GAAGC,WAAW;MAC1CF,GAAA,EAAKP,OAAA,CAAQI,YAAY,CAAC,UAAU;IACtC;EACF;EACA,OAAO;IAAEC;EAAK;AAChB;AAEA,OAAO,SAASK,uBAAuBC,GAAqB;EAC1D,OACEA,GAAA,CAAIC,aAAa,IAAI,QACr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