@payloadcms/richtext-lexical 3.57.0-internal.266049e → 3.57.0-internal.2988185
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-BJACUMFU.js → Field-PKJPWZJL.js} +2 -2
- package/dist/exports/client/Field-PKJPWZJL.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-SEPPJCZ6.js → chunk-YCH4JNUH.js} +2 -2
- package/dist/exports/client/component-3PENNOM3.js +2 -0
- package/dist/exports/client/component-3PENNOM3.js.map +7 -0
- package/dist/exports/client/index.d.ts +0 -2
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -35
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/align/server/i18n.d.ts.map +1 -1
- package/dist/features/align/server/i18n.js +0 -6
- package/dist/features/align/server/i18n.js.map +1 -1
- package/dist/features/blockquote/server/i18n.d.ts.map +1 -1
- package/dist/features/blockquote/server/i18n.js +0 -3
- package/dist/features/blockquote/server/i18n.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +0 -5
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts +17 -0
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdownTransformer.js +144 -0
- package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/server/i18n.d.ts.map +1 -1
- package/dist/features/blocks/server/i18n.js +0 -9
- package/dist/features/blocks/server/i18n.js.map +1 -1
- package/dist/features/blocks/server/index.js +1 -1
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/{markdown/markdownTransformer.js → markdownTransformer.js} +48 -6
- package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
- package/dist/features/heading/server/i18n.d.ts.map +1 -1
- package/dist/features/heading/server/i18n.js +0 -3
- package/dist/features/heading/server/i18n.js.map +1 -1
- package/dist/features/horizontalRule/server/i18n.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/i18n.js +0 -3
- package/dist/features/horizontalRule/server/i18n.js.map +1 -1
- package/dist/features/indent/server/i18n.d.ts.map +1 -1
- package/dist/features/indent/server/i18n.js +0 -4
- package/dist/features/indent/server/i18n.js.map +1 -1
- package/dist/features/link/server/i18n.d.ts.map +1 -1
- package/dist/features/link/server/i18n.js +0 -4
- package/dist/features/link/server/i18n.js.map +1 -1
- package/dist/features/lists/checklist/server/i18n.d.ts.map +1 -1
- package/dist/features/lists/checklist/server/i18n.js +0 -3
- package/dist/features/lists/checklist/server/i18n.js.map +1 -1
- package/dist/features/lists/orderedList/server/i18n.d.ts.map +1 -1
- package/dist/features/lists/orderedList/server/i18n.js +0 -3
- package/dist/features/lists/orderedList/server/i18n.js.map +1 -1
- package/dist/features/lists/unorderedList/server/i18n.d.ts.map +1 -1
- package/dist/features/lists/unorderedList/server/i18n.js +0 -3
- package/dist/features/lists/unorderedList/server/i18n.js.map +1 -1
- package/dist/features/paragraph/server/i18n.d.ts.map +1 -1
- package/dist/features/paragraph/server/i18n.js +0 -4
- package/dist/features/paragraph/server/i18n.js.map +1 -1
- package/dist/features/relationship/server/i18n.d.ts.map +1 -1
- package/dist/features/relationship/server/i18n.js +0 -3
- package/dist/features/relationship/server/i18n.js.map +1 -1
- package/dist/features/textState/i18n.d.ts.map +1 -1
- package/dist/features/textState/i18n.js +0 -3
- package/dist/features/textState/i18n.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts +0 -2
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +24 -28
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +7 -2
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +27 -9
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts +0 -6
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js +23 -306
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/i18n.d.ts.map +1 -1
- package/dist/features/upload/server/i18n.js +0 -3
- package/dist/features/upload/server/i18n.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -16
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js +39 -12
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +1 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +0 -6
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-BJACUMFU.js.map +0 -7
- package/dist/exports/client/component-VDJI45F2.js +0 -2
- package/dist/exports/client/component-VDJI45F2.js.map +0 -7
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +0 -6
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +0 -24
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +0 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +0 -6
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +0 -20
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +0 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +0 -12
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js +0 -348
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component.d.ts +0 -53
- package/dist/features/blocks/premade/CodeBlock/Component.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component.js +0 -68
- package/dist/features/blocks/premade/CodeBlock/Component.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts +0 -7
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converter.js +0 -46
- package/dist/features/blocks/premade/CodeBlock/converter.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +0 -2
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converterClient.js +0 -4
- package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/index.d.ts +0 -7
- package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/index.js +0 -39
- package/dist/features/blocks/premade/CodeBlock/index.js.map +0 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +0 -6
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +0 -27
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +0 -1
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +0 -7
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +0 -22
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +0 -1
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +0 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +0 -15
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +0 -1
- package/dist/features/upload/client/component/pending/index.d.ts +0 -3
- package/dist/features/upload/client/component/pending/index.d.ts.map +0 -1
- package/dist/features/upload/client/component/pending/index.js +0 -14
- package/dist/features/upload/client/component/pending/index.js.map +0 -1
- package/dist/features/upload/server/nodes/conversions.d.ts +0 -6
- package/dist/features/upload/server/nodes/conversions.d.ts.map +0 -1
- package/dist/features/upload/server/nodes/conversions.js +0 -53
- package/dist/features/upload/server/nodes/conversions.js.map +0 -1
- /package/dist/exports/client/{chunk-SEPPJCZ6.js.map → chunk-YCH4JNUH.js.map} +0 -0
- /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.d.ts → linesFromMatchToContentAndPropsString.d.ts} +0 -0
- /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.js → linesFromMatchToContentAndPropsString.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/features/textState/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAEhE,eAAO,MAAM,IAAI,EAAE,OAAO,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/features/textState/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAEhE,eAAO,MAAM,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAoC1C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":["i18n","ar","defaultStyle","az","bg","cs","da","de","en","es","et","fa","fr","he","hr","hu","it","ja","ko","my","nb","nl","pl","pt","ro","rs","ru","sk","sl","sv","
|
|
1
|
+
{"version":3,"file":"i18n.js","names":["i18n","ar","defaultStyle","az","bg","cs","da","de","en","es","et","fa","fr","he","hr","hu","it","ja","ko","my","nb","nl","pl","pt","ro","rs","ru","sk","sl","sv","th","tr","uk","vi","zh"],"sources":["../../../src/features/textState/i18n.ts"],"sourcesContent":["import type { GenericLanguages } from '@payloadcms/translations'\n\nexport const i18n: Partial<GenericLanguages> = {\n ar: { defaultStyle: 'النمط الافتراضي' },\n az: { defaultStyle: 'Defolt üslub' },\n bg: { defaultStyle: 'Стандартен стил' },\n cs: { defaultStyle: 'Výchozí styl' },\n da: { defaultStyle: 'Standardstil' },\n de: { defaultStyle: 'Standardstil' },\n en: { defaultStyle: 'Default style' },\n es: { defaultStyle: 'Estilo predeterminado' },\n et: { defaultStyle: 'Vaikimisi stiil' },\n fa: { defaultStyle: 'سبک پیشفرض' },\n fr: { defaultStyle: 'Style par défaut' },\n he: { defaultStyle: 'סגנון ברירת מחדל' },\n hr: { defaultStyle: 'Zadani stil' },\n hu: { defaultStyle: 'Alapértelmezett stílus' },\n it: { defaultStyle: 'Stile predefinito' },\n ja: { defaultStyle: 'デフォルトスタイル' },\n ko: { defaultStyle: '기본 스타일' },\n my: { defaultStyle: 'Gaya lalai' },\n nb: { defaultStyle: 'Standardstil' },\n nl: { defaultStyle: 'Standaardstijl' },\n pl: { defaultStyle: 'Domyślny styl' },\n pt: { defaultStyle: 'Estilo padrão' },\n ro: { defaultStyle: 'Stil implicit' },\n rs: { defaultStyle: 'Подразумевани стил' },\n 'rs-latin': { defaultStyle: 'Podrazumevani stil' },\n ru: { defaultStyle: 'Стиль по умолчанию' },\n sk: { defaultStyle: 'Predvolený štýl' },\n sl: { defaultStyle: 'Privzeti slog' },\n sv: { defaultStyle: 'Standardstil' },\n th: { defaultStyle: 'สไตล์เริ่มต้น' },\n tr: { defaultStyle: 'Varsayılan stil' },\n uk: { defaultStyle: 'Стиль за замовчуванням' },\n vi: { defaultStyle: 'Kiểu mặc định' },\n zh: { defaultStyle: '默认样式' },\n 'zh-TW': { defaultStyle: '預設樣式' },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,IAAA,GAAkC;EAC7CC,EAAA,EAAI;IAAEC,YAAA,EAAc;EAAkB;EACtCC,EAAA,EAAI;IAAED,YAAA,EAAc;EAAe;EACnCE,EAAA,EAAI;IAAEF,YAAA,EAAc;EAAkB;EACtCG,EAAA,EAAI;IAAEH,YAAA,EAAc;EAAe;EACnCI,EAAA,EAAI;IAAEJ,YAAA,EAAc;EAAe;EACnCK,EAAA,EAAI;IAAEL,YAAA,EAAc;EAAe;EACnCM,EAAA,EAAI;IAAEN,YAAA,EAAc;EAAgB;EACpCO,EAAA,EAAI;IAAEP,YAAA,EAAc;EAAwB;EAC5CQ,EAAA,EAAI;IAAER,YAAA,EAAc;EAAkB;EACtCS,EAAA,EAAI;IAAET,YAAA,EAAc;EAAc;EAClCU,EAAA,EAAI;IAAEV,YAAA,EAAc;EAAmB;EACvCW,EAAA,EAAI;IAAEX,YAAA,EAAc;EAAmB;EACvCY,EAAA,EAAI;IAAEZ,YAAA,EAAc;EAAc;EAClCa,EAAA,EAAI;IAAEb,YAAA,EAAc;EAAyB;EAC7Cc,EAAA,EAAI;IAAEd,YAAA,EAAc;EAAoB;EACxCe,EAAA,EAAI;IAAEf,YAAA,EAAc;EAAY;EAChCgB,EAAA,EAAI;IAAEhB,YAAA,EAAc;EAAS;EAC7BiB,EAAA,EAAI;IAAEjB,YAAA,EAAc;EAAa;EACjCkB,EAAA,EAAI;IAAElB,YAAA,EAAc;EAAe;EACnCmB,EAAA,EAAI;IAAEnB,YAAA,EAAc;EAAiB;EACrCoB,EAAA,EAAI;IAAEpB,YAAA,EAAc;EAAgB;EACpCqB,EAAA,EAAI;IAAErB,YAAA,EAAc;EAAgB;EACpCsB,EAAA,EAAI;IAAEtB,YAAA,EAAc;EAAgB;EACpCuB,EAAA,EAAI;IAAEvB,YAAA,EAAc;EAAqB;EACzC,YAAY;IAAEA,YAAA,EAAc;EAAqB;EACjDwB,EAAA,EAAI;IAAExB,YAAA,EAAc;EAAqB;EACzCyB,EAAA,EAAI;IAAEzB,YAAA,EAAc;EAAkB;EACtC0B,EAAA,EAAI;IAAE1B,YAAA,EAAc;EAAgB;EACpC2B,EAAA,EAAI;IAAE3B,YAAA,EAAc;EAAe;EACnC4B,EAAA,EAAI;IAAE5B,YAAA,EAAc;EAAgB;EACpC6B,EAAA,EAAI;IAAE7B,YAAA,EAAc;EAAkB;EACtC8B,EAAA,EAAI;IAAE9B,YAAA,EAAc;EAAyB;EAC7C+B,EAAA,EAAI;IAAE/B,YAAA,EAAc;EAAgB;EACpCgC,EAAA,EAAI;IAAEhC,YAAA,EAAc;EAAO;EAC3B,SAAS;IAAEA,YAAA,EAAc;EAAO;AAClC","ignoreList":[]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { type ElementFormatType } from 'lexical';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import type { UploadData } from '../../server/nodes/UploadNode.js';
|
|
4
3
|
import './index.scss';
|
|
5
4
|
export type ElementProps = {
|
|
6
5
|
data: UploadData;
|
|
7
|
-
format?: ElementFormatType;
|
|
8
6
|
nodeKey: string;
|
|
9
7
|
};
|
|
10
8
|
export declare const UploadComponent: (props: ElementProps) => React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/component/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/component/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA2D,MAAM,OAAO,CAAA;AAG/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAUlE,OAAO,cAAc,CAAA;AAQrB,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AA0LD,eAAO,MAAM,eAAe,UAAW,YAAY,KAAG,KAAK,CAAC,SAM3D,CAAA"}
|
|
@@ -112,35 +112,37 @@ const Component = props => {
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
}, [editor, nodeKey]);
|
|
115
|
-
const aspectRatio = thumbnailSRC && data?.width && data?.height ? data.width > data.height ? 'landscape' : 'portrait' : 'landscape';
|
|
116
115
|
return /*#__PURE__*/_jsxs("div", {
|
|
117
|
-
className:
|
|
118
|
-
|
|
116
|
+
className: baseClass,
|
|
117
|
+
contentEditable: false,
|
|
119
118
|
ref: uploadRef,
|
|
120
119
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
121
120
|
className: `${baseClass}__card`,
|
|
122
121
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
123
|
-
className: `${baseClass}
|
|
124
|
-
children: [/*#__PURE__*/_jsx(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}),
|
|
131
|
-
className: `${baseClass}
|
|
132
|
-
children: /*#__PURE__*/
|
|
122
|
+
className: `${baseClass}__topRow`,
|
|
123
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
124
|
+
className: `${baseClass}__thumbnail`,
|
|
125
|
+
children: /*#__PURE__*/_jsx(Thumbnail, {
|
|
126
|
+
collectionSlug: relationTo,
|
|
127
|
+
fileSrc: isImage(data?.mimeType) ? thumbnailSRC : null
|
|
128
|
+
})
|
|
129
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
130
|
+
className: `${baseClass}__topRowRightPanel`,
|
|
131
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
132
|
+
className: `${baseClass}__collectionLabel`,
|
|
133
|
+
children: getTranslation(relatedCollection.labels.singular, i18n)
|
|
134
|
+
}), editor.isEditable() && /*#__PURE__*/_jsxs("div", {
|
|
133
135
|
className: `${baseClass}__actions`,
|
|
134
|
-
role: "toolbar",
|
|
135
136
|
children: [hasExtraFields ? /*#__PURE__*/_jsx(Button, {
|
|
136
137
|
buttonStyle: "icon-label",
|
|
137
138
|
className: `${baseClass}__upload-drawer-toggler`,
|
|
138
139
|
disabled: readOnly,
|
|
139
140
|
el: "button",
|
|
140
141
|
icon: "edit",
|
|
141
|
-
onClick:
|
|
142
|
+
onClick: () => {
|
|
143
|
+
toggleDrawer();
|
|
144
|
+
},
|
|
142
145
|
round: true,
|
|
143
|
-
size: "medium",
|
|
144
146
|
tooltip: t('fields:editRelationship')
|
|
145
147
|
}) : null, /*#__PURE__*/_jsx(Button, {
|
|
146
148
|
buttonStyle: "icon-label",
|
|
@@ -156,7 +158,6 @@ const Component = props => {
|
|
|
156
158
|
});
|
|
157
159
|
},
|
|
158
160
|
round: true,
|
|
159
|
-
size: "medium",
|
|
160
161
|
tooltip: t('fields:swapUpload')
|
|
161
162
|
}), /*#__PURE__*/_jsx(Button, {
|
|
162
163
|
buttonStyle: "icon-label",
|
|
@@ -168,23 +169,18 @@ const Component = props => {
|
|
|
168
169
|
removeUpload();
|
|
169
170
|
},
|
|
170
171
|
round: true,
|
|
171
|
-
size: "medium",
|
|
172
172
|
tooltip: t('fields:removeUpload')
|
|
173
173
|
})]
|
|
174
|
-
})
|
|
174
|
+
})]
|
|
175
175
|
})]
|
|
176
|
-
}), /*#__PURE__*/
|
|
177
|
-
className: `${baseClass}
|
|
178
|
-
children:
|
|
176
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
177
|
+
className: `${baseClass}__bottomRow`,
|
|
178
|
+
children: /*#__PURE__*/_jsx(DocumentDrawerToggler, {
|
|
179
179
|
className: `${baseClass}__doc-drawer-toggler`,
|
|
180
180
|
children: /*#__PURE__*/_jsx("strong", {
|
|
181
|
-
|
|
182
|
-
children: data?.filename || t('general:untitled')
|
|
181
|
+
children: data?.filename
|
|
183
182
|
})
|
|
184
|
-
})
|
|
185
|
-
className: `${baseClass}__collectionLabel`,
|
|
186
|
-
children: getTranslation(relatedCollection.labels.singular, i18n)
|
|
187
|
-
})]
|
|
183
|
+
})
|
|
188
184
|
})]
|
|
189
185
|
}), value ? /*#__PURE__*/_jsx(DocumentDrawer, {
|
|
190
186
|
onSave: updateUpload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","getTranslation","Button","formatDrawerSlug","Thumbnail","useConfig","useEditDepth","usePayloadAPI","useTranslation","$getNodeByKey","isImage","React","useCallback","useId","useReducer","useRef","useState","useEditorConfigContext","FieldsDrawer","useLexicalDocumentDrawer","useLexicalDrawer","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","Error","config","routes","api","serverURL","getEntityConfig","uploadRef","uuid","editDepth","editor","editorConfig","fieldProps","readOnly","schemaPath","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","collectionSlug","componentID","extraFieldsDrawerSlug","slug","toggleDrawer","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","update","remove","updateUpload","hasExtraFields","resolvedFeatureMap","get","sanitizedClientFeatureProps","collections","onExtraFieldsDrawerSubmit","_","uploadNode","newData","getData","setData","aspectRatio","width","height","_jsxs","className","filename","ref","_jsx","fileSrc","mimeType","size","isEditable","role","buttonStyle","disabled","el","icon","onClick","round","tooltip","dispatchCommand","replace","e","preventDefault","labels","singular","onSave","drawerSlug","drawerTitle","label","featureKey","handleDrawerSubmit","schemaPathSuffix","UploadComponent","uploads"],"sources":["../../../../../src/features/upload/client/component/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, Data, FormState, JsonObject } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n formatDrawerSlug,\n Thumbnail,\n useConfig,\n useEditDepth,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { $getNodeByKey, type ElementFormatType } from 'lexical'\nimport { isImage } from 'payload/shared'\nimport React, { useCallback, useId, useReducer, useRef, useState } from 'react'\n\nimport type { BaseClientFeatureProps } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\nimport type { UploadNode } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { EnabledRelationshipsCondition } from '../../../relationship/client/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n format?: ElementFormatType\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.',\n )\n }\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n const [editor] = useLexicalComposerContext()\n\n const {\n editorConfig,\n fieldProps: { readOnly, schemaPath },\n } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection] = useState<ClientCollectionConfig>(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const componentID = useId()\n\n const extraFieldsDrawerSlug = formatDrawerSlug({\n slug: `lexical-upload-drawer-` + uuid + componentID, // There can be multiple upload components, each with their own drawer, in one single editor => separate them by componentID\n depth: editDepth,\n })\n\n // Need to use hook to initialize useEffect that restores cursor position\n const { toggleDrawer } = useLexicalDrawer(extraFieldsDrawerSlug, true)\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (data: Data) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n dispatchCacheBust()\n closeDocumentDrawer()\n },\n [setParams, cacheBust, closeDocumentDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as BaseClientFeatureProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n const onExtraFieldsDrawerSubmit = useCallback(\n (_: FormState, data: JsonObject) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: null | UploadNode = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n },\n [editor, nodeKey],\n )\n\n const aspectRatio =\n thumbnailSRC && data?.width && data?.height\n ? data.width > data.height\n ? 'landscape'\n : 'portrait'\n : 'landscape'\n\n return (\n <div\n className={`${baseClass} ${baseClass}--${aspectRatio}`}\n data-filename={data?.filename}\n ref={uploadRef}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__media`}>\n <Thumbnail\n collectionSlug={relationTo}\n fileSrc={isImage(data?.mimeType) ? thumbnailSRC : null}\n height={data?.height}\n size=\"none\"\n width={data?.width}\n />\n\n {editor.isEditable() && (\n <div className={`${baseClass}__overlay ${baseClass}__floater`}>\n <div className={`${baseClass}__actions`} role=\"toolbar\">\n {hasExtraFields ? (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={toggleDrawer}\n round\n size=\"medium\"\n tooltip={t('fields:editRelationship')}\n />\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swap-drawer-toggler`}\n disabled={readOnly}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n size=\"medium\"\n tooltip={t('fields:swapUpload')}\n />\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n size=\"medium\"\n tooltip={t('fields:removeUpload')}\n />\n </div>\n </div>\n )}\n </div>\n\n <div className={`${baseClass}__metaOverlay ${baseClass}__floater`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong className={`${baseClass}__filename`}>\n {data?.filename || t('general:untitled')}\n </strong>\n </DocumentDrawerToggler>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n </div>\n </div>\n\n {value ? <DocumentDrawer onSave={updateUpload} /> : null}\n {hasExtraFields ? (\n <FieldsDrawer\n data={fields}\n drawerSlug={extraFieldsDrawerSlug}\n drawerTitle={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n featureKey=\"upload\"\n handleDrawerSubmit={onExtraFieldsDrawerSubmit}\n schemaPath={schemaPath}\n schemaPathSuffix={relatedCollection.slug}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,gBAAgB,EAChBC,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,aAAa,EACbC,cAAc,QACT;AACP,SAASC,aAAa,QAAgC;AACtD,SAASC,OAAO,QAAQ;AACxB,OAAOC,KAAA,IAASC,WAAW,EAAEC,KAAK,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAOxE,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAC7B,SAASC,wBAAwB,QAAQ;AACzC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,6BAA6B,QAAQ;AAC9C,SAASC,iCAAiC,QAAQ;AAGlD,MAAMC,SAAA,GAAY;AAElB,MAAMC,aAAA,GAAgB;EACpBC,KAAA,EAAO;AACT;AAQA,MAAMC,SAAA,GAAqCC,KAAA;EACzC,MAAM;IACJC,IAAA,EAAM;MAAEC,MAAM;MAAEC,UAAU;MAAEC;IAAK,CAAE;IACnCC;EAAO,CACR,GAAGL,KAAA;EAEJ,IAAI,OAAOI,KAAA,KAAU,UAAU;IAC7B,MAAM,IAAIE,KAAA,CACR;EAEJ;EAEA,MAAM;IACJC,MAAA,EA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,IAAA,CAAC9D,SAAA;MAAW,GAAGC;;;AAGrB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","getTranslation","Button","formatDrawerSlug","Thumbnail","useConfig","useEditDepth","usePayloadAPI","useTranslation","$getNodeByKey","isImage","React","useCallback","useId","useReducer","useRef","useState","useEditorConfigContext","FieldsDrawer","useLexicalDocumentDrawer","useLexicalDrawer","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","Error","config","routes","api","serverURL","getEntityConfig","uploadRef","uuid","editDepth","editor","editorConfig","fieldProps","readOnly","schemaPath","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","collectionSlug","componentID","extraFieldsDrawerSlug","slug","toggleDrawer","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","update","remove","updateUpload","hasExtraFields","resolvedFeatureMap","get","sanitizedClientFeatureProps","collections","onExtraFieldsDrawerSubmit","_","uploadNode","newData","getData","setData","_jsxs","className","contentEditable","ref","_jsx","fileSrc","mimeType","labels","singular","isEditable","buttonStyle","disabled","el","icon","onClick","round","tooltip","dispatchCommand","replace","e","preventDefault","filename","onSave","drawerSlug","drawerTitle","label","featureKey","handleDrawerSubmit","schemaPathSuffix","UploadComponent","uploads"],"sources":["../../../../../src/features/upload/client/component/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, Data, FormState, JsonObject } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n formatDrawerSlug,\n Thumbnail,\n useConfig,\n useEditDepth,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport { isImage } from 'payload/shared'\nimport React, { useCallback, useId, useReducer, useRef, useState } from 'react'\n\nimport type { BaseClientFeatureProps } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\nimport type { UploadNode } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { EnabledRelationshipsCondition } from '../../../relationship/client/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.',\n )\n }\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n const [editor] = useLexicalComposerContext()\n\n const {\n editorConfig,\n fieldProps: { readOnly, schemaPath },\n } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection] = useState<ClientCollectionConfig>(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const componentID = useId()\n\n const extraFieldsDrawerSlug = formatDrawerSlug({\n slug: `lexical-upload-drawer-` + uuid + componentID, // There can be multiple upload components, each with their own drawer, in one single editor => separate them by componentID\n depth: editDepth,\n })\n\n // Need to use hook to initialize useEffect that restores cursor position\n const { toggleDrawer } = useLexicalDrawer(extraFieldsDrawerSlug, true)\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (data: Data) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n dispatchCacheBust()\n closeDocumentDrawer()\n },\n [setParams, cacheBust, closeDocumentDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as BaseClientFeatureProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n const onExtraFieldsDrawerSubmit = useCallback(\n (_: FormState, data: JsonObject) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: null | UploadNode = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n },\n [editor, nodeKey],\n )\n\n return (\n <div className={baseClass} contentEditable={false} ref={uploadRef}>\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n <div className={`${baseClass}__thumbnail`}>\n <Thumbnail\n collectionSlug={relationTo}\n fileSrc={isImage(data?.mimeType) ? thumbnailSRC : null}\n />\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swap-drawer-toggler`}\n disabled={readOnly}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value ? <DocumentDrawer onSave={updateUpload} /> : null}\n {hasExtraFields ? (\n <FieldsDrawer\n data={fields}\n drawerSlug={extraFieldsDrawerSlug}\n drawerTitle={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n featureKey=\"upload\"\n handleDrawerSubmit={onExtraFieldsDrawerSubmit}\n schemaPath={schemaPath}\n schemaPathSuffix={relatedCollection.slug}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,gBAAgB,EAChBC,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,aAAa,EACbC,cAAc,QACT;AACP,SAASC,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C,yBAAA;MACpB7B,UAAA,EAAYA,UAAA;MACZ+D,gBAAA,EAAkBzD,iBAAA,CAAkBI;SAEpC;;AAGV;AAEA,OAAO,MAAMsD,eAAA,GAAmBnF,KAAA;EAC9B,oBACE0D,IAAA,CAAChE,6BAAA;IAA+B,GAAGM,KAAK;IAAEoF,OAAO;cAC/C,aAAA1B,IAAA,CAAC3D,SAAA;MAAW,GAAGC;;;AAGrB","ignoreList":[]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
2
|
+
import type { DOMConversionMap, LexicalNode, Spread } from 'lexical';
|
|
2
3
|
import type { JSX } from 'react';
|
|
3
|
-
import type {
|
|
4
|
+
import type { UploadData } from '../../server/nodes/UploadNode.js';
|
|
4
5
|
import { UploadServerNode } from '../../server/nodes/UploadNode.js';
|
|
6
|
+
export type SerializedUploadNode = {
|
|
7
|
+
children?: never;
|
|
8
|
+
type: 'upload';
|
|
9
|
+
} & Spread<UploadData, SerializedDecoratorBlockNode>;
|
|
5
10
|
export declare class UploadNode extends UploadServerNode {
|
|
6
11
|
static clone(node: UploadServerNode): UploadServerNode;
|
|
7
12
|
static getType(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/nodes/UploadNode.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"UploadNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/nodes/UploadNode.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EAAE,gBAAgB,EAAuB,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAMhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAElE,OAAO,EAA0B,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAkC3F,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,IAAI,EAAE,QAAQ,CAAA;CACf,GAAG,MAAM,CAAC,UAAU,EAAE,4BAA4B,CAAC,CAAA;AAEpD,qBAAa,UAAW,SAAQ,gBAAgB;WAC9B,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB;WAI/C,OAAO,IAAI,MAAM;WAIjB,SAAS,IAAI,gBAAgB,CAAC,gBAAgB,CAAC;WAS/C,UAAU,CAAC,cAAc,EAAE,oBAAoB,GAAG,UAAU;IAsBnE,QAAQ,IAAI,GAAG,CAAC,OAAO;IAIvB,UAAU,IAAI,oBAAoB;CAG5C;AAED,wBAAgB,iBAAiB,CAAC,EAChC,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,UAAU,CAKb;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,UAAU,CAEtF"}
|
|
@@ -4,12 +4,35 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import ObjectID from 'bson-objectid';
|
|
5
5
|
import { $applyNodeReplacement } from 'lexical';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import {
|
|
8
|
-
import { UploadServerNode } from '../../server/nodes/UploadNode.js';
|
|
9
|
-
import { PendingUploadComponent } from '../component/pending/index.js';
|
|
7
|
+
import { isGoogleDocCheckboxImg, UploadServerNode } from '../../server/nodes/UploadNode.js';
|
|
10
8
|
const RawUploadComponent = /*#__PURE__*/React.lazy(() => import('../../client/component/index.js').then(module => ({
|
|
11
9
|
default: module.UploadComponent
|
|
12
10
|
})));
|
|
11
|
+
function $convertUploadElement(domNode) {
|
|
12
|
+
if (domNode.hasAttribute('data-lexical-upload-relation-to') && domNode.hasAttribute('data-lexical-upload-id')) {
|
|
13
|
+
const id = domNode.getAttribute('data-lexical-upload-id');
|
|
14
|
+
const relationTo = domNode.getAttribute('data-lexical-upload-relation-to');
|
|
15
|
+
if (id != null && relationTo != null) {
|
|
16
|
+
const node = $createUploadNode({
|
|
17
|
+
data: {
|
|
18
|
+
fields: {},
|
|
19
|
+
relationTo,
|
|
20
|
+
value: id
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
node
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const img = domNode;
|
|
29
|
+
if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
// TODO: Auto-upload functionality here!
|
|
33
|
+
//}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
13
36
|
export class UploadNode extends UploadServerNode {
|
|
14
37
|
static clone(node) {
|
|
15
38
|
return super.clone(node);
|
|
@@ -20,7 +43,7 @@ export class UploadNode extends UploadServerNode {
|
|
|
20
43
|
static importDOM() {
|
|
21
44
|
return {
|
|
22
45
|
img: node => ({
|
|
23
|
-
conversion:
|
|
46
|
+
conversion: $convertUploadElement,
|
|
24
47
|
priority: 0
|
|
25
48
|
})
|
|
26
49
|
};
|
|
@@ -36,7 +59,6 @@ export class UploadNode extends UploadServerNode {
|
|
|
36
59
|
const importedData = {
|
|
37
60
|
id: serializedNode.id,
|
|
38
61
|
fields: serializedNode.fields,
|
|
39
|
-
pending: serializedNode.pending,
|
|
40
62
|
relationTo: serializedNode.relationTo,
|
|
41
63
|
value: serializedNode.value
|
|
42
64
|
};
|
|
@@ -47,12 +69,8 @@ export class UploadNode extends UploadServerNode {
|
|
|
47
69
|
return node;
|
|
48
70
|
}
|
|
49
71
|
decorate() {
|
|
50
|
-
if (this.__data.pending) {
|
|
51
|
-
return /*#__PURE__*/_jsx(PendingUploadComponent, {});
|
|
52
|
-
}
|
|
53
72
|
return /*#__PURE__*/_jsx(RawUploadComponent, {
|
|
54
73
|
data: this.__data,
|
|
55
|
-
format: this.__format,
|
|
56
74
|
nodeKey: this.getKey()
|
|
57
75
|
});
|
|
58
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadNode.js","names":["ObjectID","$applyNodeReplacement","React","
|
|
1
|
+
{"version":3,"file":"UploadNode.js","names":["ObjectID","$applyNodeReplacement","React","isGoogleDocCheckboxImg","UploadServerNode","RawUploadComponent","lazy","then","module","default","UploadComponent","$convertUploadElement","domNode","hasAttribute","id","getAttribute","relationTo","node","$createUploadNode","data","fields","value","img","src","startsWith","UploadNode","clone","getType","importDOM","conversion","priority","importJSON","serializedNode","version","toHexString","importedData","setFormat","format","decorate","_jsx","__data","nodeKey","getKey","exportJSON","$isUploadNode"],"sources":["../../../../../src/features/upload/client/nodes/UploadNode.tsx"],"sourcesContent":["'use client'\nimport type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { DOMConversionMap, DOMConversionOutput, LexicalNode, Spread } from 'lexical'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\n\nimport { isGoogleDocCheckboxImg, UploadServerNode } from '../../server/nodes/UploadNode.js'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../../client/component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nfunction $convertUploadElement(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 = $createUploadNode({\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 UploadNode extends UploadServerNode {\n static override clone(node: UploadServerNode): UploadServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: $convertUploadElement,\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadNode {\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 = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n override decorate(): JSX.Element {\n return <RawUploadComponent data={this.__data} nodeKey={this.getKey()} />\n }\n\n override exportJSON(): SerializedUploadNode {\n return super.exportJSON()\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n"],"mappings":"AAAA;;;AAKA,OAAO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@ import type { PluginComponent } from '../../../typesClient.js';
|
|
|
3
3
|
import type { UploadData } from '../../server/nodes/UploadNode.js';
|
|
4
4
|
import type { UploadFeaturePropsClient } from '../index.js';
|
|
5
5
|
export type InsertUploadPayload = Readonly<Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>>;
|
|
6
|
-
declare global {
|
|
7
|
-
interface DragEvent {
|
|
8
|
-
rangeOffset?: number;
|
|
9
|
-
rangeParent?: Node;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
6
|
export declare const INSERT_UPLOAD_COMMAND: LexicalCommand<InsertUploadPayload>;
|
|
13
7
|
export declare const UploadPlugin: PluginComponent<UploadFeaturePropsClient>;
|
|
14
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/plugin/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAe7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAK3D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AAEpG,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAC9B,CAAA;AAExC,eAAO,MAAM,YAAY,EAAE,eAAe,CAAC,wBAAwB,CAgDlE,CAAA"}
|