@payloadcms/richtext-lexical 3.66.0-canary.6 → 3.66.0
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-2A2VQXKP.js +2 -0
- package/dist/exports/client/Field-2A2VQXKP.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/component-5IW2M4GH.js +2 -0
- package/dist/exports/client/component-5IW2M4GH.js.map +7 -0
- package/dist/exports/client/index.js +16 -16
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/align/client/index.d.ts.map +1 -1
- package/dist/features/align/client/index.js +69 -17
- package/dist/features/align/client/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 +5 -3
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/lexical/plugins/ClipboardPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/ClipboardPlugin/index.js +35 -17
- package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/exports/client/Field-QUXIGJRC.js +0 -2
- package/dist/exports/client/Field-QUXIGJRC.js.map +0 -7
- package/dist/exports/client/component-5YLBQB5B.js +0 -2
- package/dist/exports/client/component-5YLBQB5B.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/align/client/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/align/client/index.tsx"],"names":[],"mappings":"AA8MA,eAAO,MAAM,kBAAkB,oFAa7B,CAAA"}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
+
import { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
6
|
+
import { $findMatchingParent } from '@lexical/utils';
|
|
7
|
+
import { $getSelection, $isElementNode, $isNodeSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, FORMAT_ELEMENT_COMMAND } from 'lexical';
|
|
8
|
+
import { useEffect } from 'react';
|
|
4
9
|
import { AlignCenterIcon } from '../../../lexical/ui/icons/AlignCenter/index.js';
|
|
5
10
|
import { AlignJustifyIcon } from '../../../lexical/ui/icons/AlignJustify/index.js';
|
|
6
11
|
import { AlignLeftIcon } from '../../../lexical/ui/icons/AlignLeft/index.js';
|
|
7
12
|
import { AlignRightIcon } from '../../../lexical/ui/icons/AlignRight/index.js';
|
|
8
13
|
import { createClientFeature } from '../../../utilities/createClientFeature.js';
|
|
9
14
|
import { toolbarAlignGroupWithItems } from './toolbarAlignGroup.js';
|
|
15
|
+
// DecoratorBlockNode has format, but Lexical forgot
|
|
16
|
+
// to add the getters like ElementNode does.
|
|
17
|
+
const getFormatType = node => {
|
|
18
|
+
if ($isElementNode(node)) {
|
|
19
|
+
return node.getFormatType();
|
|
20
|
+
}
|
|
21
|
+
return node.__format;
|
|
22
|
+
};
|
|
10
23
|
const toolbarGroups = [toolbarAlignGroupWithItems([{
|
|
11
24
|
ChildComponent: AlignLeftIcon,
|
|
12
25
|
isActive: ({
|
|
@@ -16,14 +29,14 @@ const toolbarGroups = [toolbarAlignGroupWithItems([{
|
|
|
16
29
|
return false;
|
|
17
30
|
}
|
|
18
31
|
for (const node of selection.getNodes()) {
|
|
19
|
-
if ($isElementNode(node)) {
|
|
20
|
-
if (
|
|
32
|
+
if ($isElementNode(node) || $isDecoratorBlockNode(node)) {
|
|
33
|
+
if (getFormatType(node) === 'left') {
|
|
21
34
|
continue;
|
|
22
35
|
}
|
|
23
36
|
}
|
|
24
37
|
const parent = node.getParent();
|
|
25
|
-
if ($isElementNode(parent)) {
|
|
26
|
-
if (
|
|
38
|
+
if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {
|
|
39
|
+
if (getFormatType(parent) === 'left') {
|
|
27
40
|
continue;
|
|
28
41
|
}
|
|
29
42
|
}
|
|
@@ -52,14 +65,14 @@ const toolbarGroups = [toolbarAlignGroupWithItems([{
|
|
|
52
65
|
return false;
|
|
53
66
|
}
|
|
54
67
|
for (const node of selection.getNodes()) {
|
|
55
|
-
if ($isElementNode(node)) {
|
|
56
|
-
if (
|
|
68
|
+
if ($isElementNode(node) || $isDecoratorBlockNode(node)) {
|
|
69
|
+
if (getFormatType(node) === 'center') {
|
|
57
70
|
continue;
|
|
58
71
|
}
|
|
59
72
|
}
|
|
60
73
|
const parent = node.getParent();
|
|
61
|
-
if ($isElementNode(parent)) {
|
|
62
|
-
if (
|
|
74
|
+
if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {
|
|
75
|
+
if (getFormatType(parent) === 'center') {
|
|
63
76
|
continue;
|
|
64
77
|
}
|
|
65
78
|
}
|
|
@@ -88,14 +101,14 @@ const toolbarGroups = [toolbarAlignGroupWithItems([{
|
|
|
88
101
|
return false;
|
|
89
102
|
}
|
|
90
103
|
for (const node of selection.getNodes()) {
|
|
91
|
-
if ($isElementNode(node)) {
|
|
92
|
-
if (
|
|
104
|
+
if ($isElementNode(node) || $isDecoratorBlockNode(node)) {
|
|
105
|
+
if (getFormatType(node) === 'right') {
|
|
93
106
|
continue;
|
|
94
107
|
}
|
|
95
108
|
}
|
|
96
109
|
const parent = node.getParent();
|
|
97
|
-
if ($isElementNode(parent)) {
|
|
98
|
-
if (
|
|
110
|
+
if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {
|
|
111
|
+
if (getFormatType(parent) === 'right') {
|
|
99
112
|
continue;
|
|
100
113
|
}
|
|
101
114
|
}
|
|
@@ -124,14 +137,14 @@ const toolbarGroups = [toolbarAlignGroupWithItems([{
|
|
|
124
137
|
return false;
|
|
125
138
|
}
|
|
126
139
|
for (const node of selection.getNodes()) {
|
|
127
|
-
if ($isElementNode(node)) {
|
|
128
|
-
if (
|
|
140
|
+
if ($isElementNode(node) || $isDecoratorBlockNode(node)) {
|
|
141
|
+
if (getFormatType(node) === 'justify') {
|
|
129
142
|
continue;
|
|
130
143
|
}
|
|
131
144
|
}
|
|
132
145
|
const parent = node.getParent();
|
|
133
|
-
if ($isElementNode(parent)) {
|
|
134
|
-
if (
|
|
146
|
+
if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {
|
|
147
|
+
if (getFormatType(parent) === 'justify') {
|
|
135
148
|
continue;
|
|
136
149
|
}
|
|
137
150
|
}
|
|
@@ -152,7 +165,29 @@ const toolbarGroups = [toolbarAlignGroupWithItems([{
|
|
|
152
165
|
},
|
|
153
166
|
order: 4
|
|
154
167
|
}])];
|
|
168
|
+
const AlignPlugin = () => {
|
|
169
|
+
const $ = _c(3);
|
|
170
|
+
const [editor] = useLexicalComposerContext();
|
|
171
|
+
let t0;
|
|
172
|
+
let t1;
|
|
173
|
+
if ($[0] !== editor) {
|
|
174
|
+
t0 = () => editor.registerCommand(FORMAT_ELEMENT_COMMAND, _temp2, COMMAND_PRIORITY_LOW);
|
|
175
|
+
t1 = [editor];
|
|
176
|
+
$[0] = editor;
|
|
177
|
+
$[1] = t0;
|
|
178
|
+
$[2] = t1;
|
|
179
|
+
} else {
|
|
180
|
+
t0 = $[1];
|
|
181
|
+
t1 = $[2];
|
|
182
|
+
}
|
|
183
|
+
useEffect(t0, t1);
|
|
184
|
+
return null;
|
|
185
|
+
};
|
|
155
186
|
export const AlignFeatureClient = createClientFeature({
|
|
187
|
+
plugins: [{
|
|
188
|
+
Component: AlignPlugin,
|
|
189
|
+
position: 'normal'
|
|
190
|
+
}],
|
|
156
191
|
toolbarFixed: {
|
|
157
192
|
groups: toolbarGroups
|
|
158
193
|
},
|
|
@@ -160,4 +195,21 @@ export const AlignFeatureClient = createClientFeature({
|
|
|
160
195
|
groups: toolbarGroups
|
|
161
196
|
}
|
|
162
197
|
});
|
|
198
|
+
function _temp(parentNode) {
|
|
199
|
+
return ($isElementNode(parentNode) || $isDecoratorBlockNode(parentNode)) && !parentNode.isInline();
|
|
200
|
+
}
|
|
201
|
+
function _temp2(format) {
|
|
202
|
+
const selection = $getSelection();
|
|
203
|
+
if (!$isRangeSelection(selection) && !$isNodeSelection(selection)) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
const nodes = selection.getNodes();
|
|
207
|
+
for (const node of nodes) {
|
|
208
|
+
const element = $findMatchingParent(node, _temp);
|
|
209
|
+
if (element !== null) {
|
|
210
|
+
element.setFormat(format);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
163
215
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["$isElementNode","$isRangeSelection","FORMAT_ELEMENT_COMMAND","AlignCenterIcon","AlignJustifyIcon","AlignLeftIcon","AlignRightIcon","createClientFeature","toolbarAlignGroupWithItems","toolbarGroups","ChildComponent","isActive","selection","node","getNodes","getFormatType","parent","getParent","key","label","i18n","t","onSelect","editor","dispatchCommand","order","AlignFeatureClient","toolbarFixed","groups","toolbarInline"],"sources":["../../../../src/features/align/client/index.tsx"],"sourcesContent":["'use client'\n\nimport { $isElementNode, $isRangeSelection, FORMAT_ELEMENT_COMMAND } from 'lexical'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\n\nimport { AlignCenterIcon } from '../../../lexical/ui/icons/AlignCenter/index.js'\nimport { AlignJustifyIcon } from '../../../lexical/ui/icons/AlignJustify/index.js'\nimport { AlignLeftIcon } from '../../../lexical/ui/icons/AlignLeft/index.js'\nimport { AlignRightIcon } from '../../../lexical/ui/icons/AlignRight/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { toolbarAlignGroupWithItems } from './toolbarAlignGroup.js'\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarAlignGroupWithItems([\n {\n ChildComponent: AlignLeftIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node)) {\n if (node.getFormatType() === 'left') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent)) {\n if (parent.getFormatType() === 'left') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignLeft',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignLeftLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left')\n },\n order: 1,\n },\n {\n ChildComponent: AlignCenterIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node)) {\n if (node.getFormatType() === 'center') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent)) {\n if (parent.getFormatType() === 'center') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignCenter',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignCenterLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center')\n },\n order: 2,\n },\n {\n ChildComponent: AlignRightIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node)) {\n if (node.getFormatType() === 'right') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent)) {\n if (parent.getFormatType() === 'right') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignRight',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignRightLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right')\n },\n order: 3,\n },\n {\n ChildComponent: AlignJustifyIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node)) {\n if (node.getFormatType() === 'justify') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent)) {\n if (parent.getFormatType() === 'justify') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignJustify',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignJustifyLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify')\n },\n order: 4,\n },\n ]),\n]\n\nexport const AlignFeatureClient = createClientFeature({\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n})\n"],"mappings":"AAAA;;AAEA,SAASA,cAAc,EAAEC,iBAAiB,EAAEC,sBAAsB,QAAQ;AAI1E,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAE3C,MAAMC,aAAA,GAAgC,CACpCD,0BAAA,CAA2B,CACzB;EACEE,cAAA,EAAgBL,aAAA;EAChBM,QAAA,EAAUA,CAAC;IAAEC;EAAS,CAAE;IACtB,IAAI,CAACX,iBAAA,CAAkBW,SAAA,GAAY;MACjC,OAAO;IACT;IACA,KAAK,MAAMC,IAAA,IAAQD,SAAA,CAAUE,QAAQ,IAAI;MACvC,IAAId,cAAA,CAAea,IAAA,GAAO;QACxB,IAAIA,IAAA,CAAKE,aAAa,OAAO,QAAQ;UACnC;QACF;MACF;MAEA,MAAMC,MAAA,GAASH,IAAA,CAAKI,SAAS;MAC7B,IAAIjB,cAAA,CAAegB,MAAA,GAAS;QAC1B,IAAIA,MAAA,CAAOD,aAAa,OAAO,QAAQ;UACrC;QACF;MACF;MAEA,OAAO;IACT;IACA,OAAO;EACT;EACAG,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAK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,IAAIA,MAAA,CAAOD,aAAa,OAAO,SAAS;UACtC;QACF;MACF;MAEA,OAAO;IACT;IACA,OAAO;EACT;EACAG,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;EAChB;EACAC,QAAA,EAAUA,CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC,eAAe,CAACtB,sBAAA,EAAwB;EACjD;EACAuB,KAAA,EAAO;AACT,GACA;EACEf,cAAA,EAAgBN,gBAAA;EAChBO,QAAA,EAAUA,CAAC;IAAEC;EAAS,CAAE;IACtB,IAAI,CAACX,iBAAA,CAAkBW,SAAA,GAAY;MACjC,OAAO;IACT;IACA,KAAK,MAAMC,IAAA,IAAQD,SAAA,CAAUE,QAAQ,IAAI;MACvC,IAAId,cAAA,CAAea,IAAA,GAAO;QACxB,IAAIA,IAAA,CAAKE,aAAa,OAAO,WAAW;UACtC;QACF;MACF;MAEA,MAAMC,MAAA,GAASH,IAAA,CAAKI,SAAS;MAC7B,IAAIjB,cAAA,CAAegB,MAAA,GAAS;QAC1B,IAAIA,MAAA,CAAOD,aAAa,OAAO,WAAW;UACxC;QACF;MACF;MAEA,OAAO;IACT;IACA,OAAO;EACT;EACAG,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;EAChB;EACAC,QAAA,EAAUA,CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC,eAAe,CAACtB,sBAAA,EAAwB;EACjD;EACAuB,KAAA,EAAO;AACT,EACD,EACF;AAED,OAAO,MAAMC,kBAAA,GAAqBnB,mBAAA,CAAoB;EACpDoB,YAAA,EAAc;IACZC,MAAA,EAAQnB;EACV;EACAoB,aAAA,EAAe;IACbD,MAAA,EAAQnB;EACV;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$isDecoratorBlockNode","$findMatchingParent","$getSelection","$isElementNode","$isNodeSelection","$isRangeSelection","COMMAND_PRIORITY_LOW","FORMAT_ELEMENT_COMMAND","useEffect","AlignCenterIcon","AlignJustifyIcon","AlignLeftIcon","AlignRightIcon","createClientFeature","toolbarAlignGroupWithItems","getFormatType","node","__format","toolbarGroups","ChildComponent","isActive","selection","getNodes","parent","getParent","key","label","i18n","t","onSelect","editor","dispatchCommand","order","AlignPlugin","$","t0","t1","registerCommand","_temp2","AlignFeatureClient","plugins","Component","position","toolbarFixed","groups","toolbarInline","_temp","parentNode","isInline","format","nodes","element","setFormat"],"sources":["../../../../src/features/align/client/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'\nimport type { ElementFormatType, ElementNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'\nimport { $findMatchingParent } from '@lexical/utils'\nimport {\n $getSelection,\n $isElementNode,\n $isNodeSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n FORMAT_ELEMENT_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\n\nimport { AlignCenterIcon } from '../../../lexical/ui/icons/AlignCenter/index.js'\nimport { AlignJustifyIcon } from '../../../lexical/ui/icons/AlignJustify/index.js'\nimport { AlignLeftIcon } from '../../../lexical/ui/icons/AlignLeft/index.js'\nimport { AlignRightIcon } from '../../../lexical/ui/icons/AlignRight/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { toolbarAlignGroupWithItems } from './toolbarAlignGroup.js'\n\n// DecoratorBlockNode has format, but Lexical forgot\n// to add the getters like ElementNode does.\nconst getFormatType = (node: DecoratorBlockNode | ElementNode): ElementFormatType => {\n if ($isElementNode(node)) {\n return node.getFormatType()\n }\n return node.__format\n}\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarAlignGroupWithItems([\n {\n ChildComponent: AlignLeftIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node) || $isDecoratorBlockNode(node)) {\n if (getFormatType(node) === 'left') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {\n if (getFormatType(parent) === 'left') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignLeft',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignLeftLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left')\n },\n order: 1,\n },\n {\n ChildComponent: AlignCenterIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node) || $isDecoratorBlockNode(node)) {\n if (getFormatType(node) === 'center') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {\n if (getFormatType(parent) === 'center') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignCenter',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignCenterLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center')\n },\n order: 2,\n },\n {\n ChildComponent: AlignRightIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node) || $isDecoratorBlockNode(node)) {\n if (getFormatType(node) === 'right') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {\n if (getFormatType(parent) === 'right') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignRight',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignRightLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right')\n },\n order: 3,\n },\n {\n ChildComponent: AlignJustifyIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if ($isElementNode(node) || $isDecoratorBlockNode(node)) {\n if (getFormatType(node) === 'justify') {\n continue\n }\n }\n\n const parent = node.getParent()\n if ($isElementNode(parent) || $isDecoratorBlockNode(parent)) {\n if (getFormatType(parent) === 'justify') {\n continue\n }\n }\n\n return false\n }\n return true\n },\n key: 'alignJustify',\n label: ({ i18n }) => {\n return i18n.t('lexical:align:alignJustifyLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify')\n },\n order: 4,\n },\n ]),\n]\n\nconst AlignPlugin = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n // Just like the default Lexical configuration, but in\n // addition to ElementNode we also set DecoratorBlocks\n return editor.registerCommand(\n FORMAT_ELEMENT_COMMAND,\n (format) => {\n const selection = $getSelection()\n if (!$isRangeSelection(selection) && !$isNodeSelection(selection)) {\n return false\n }\n const nodes = selection.getNodes()\n for (const node of nodes) {\n const element = $findMatchingParent(\n node,\n (parentNode): parentNode is DecoratorBlockNode | ElementNode =>\n ($isElementNode(parentNode) || $isDecoratorBlockNode(parentNode)) &&\n !parentNode.isInline(),\n )\n if (element !== null) {\n element.setFormat(format)\n }\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n }, [editor])\n return null\n}\n\nexport const AlignFeatureClient = createClientFeature({\n plugins: [\n {\n Component: AlignPlugin,\n position: 'normal',\n },\n ],\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n})\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAKA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,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"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/component/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE/D,OAAO,KAA2D,MAAM,OAAO,CAAA;AAG/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AASlE,OAAO,cAAc,CAAA;AAMrB,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/client/component/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE/D,OAAO,KAA2D,MAAM,OAAO,CAAA;AAG/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AASlE,OAAO,cAAc,CAAA;AAMrB,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA4MlD,CAAA"}
|
|
@@ -24,6 +24,7 @@ export const UploadComponent = props => {
|
|
|
24
24
|
relationTo,
|
|
25
25
|
value
|
|
26
26
|
},
|
|
27
|
+
format,
|
|
27
28
|
nodeKey
|
|
28
29
|
} = props;
|
|
29
30
|
if (typeof value === 'object') {
|
|
@@ -90,7 +91,7 @@ export const UploadComponent = props => {
|
|
|
90
91
|
$getNodeByKey(nodeKey)?.remove();
|
|
91
92
|
});
|
|
92
93
|
}, [editor, nodeKey]);
|
|
93
|
-
const updateUpload = useCallback(
|
|
94
|
+
const updateUpload = useCallback(_data => {
|
|
94
95
|
setParams({
|
|
95
96
|
...initialParams,
|
|
96
97
|
cacheBust
|
|
@@ -99,14 +100,14 @@ export const UploadComponent = props => {
|
|
|
99
100
|
closeDocumentDrawer();
|
|
100
101
|
}, [setParams, cacheBust, closeDocumentDrawer]);
|
|
101
102
|
const hasExtraFields = editorConfig?.resolvedFeatureMap?.get('upload')?.sanitizedClientFeatureProps.collections?.[relatedCollection.slug]?.hasExtraFields;
|
|
102
|
-
const onExtraFieldsDrawerSubmit = useCallback((_,
|
|
103
|
+
const onExtraFieldsDrawerSubmit = useCallback((_, data_0) => {
|
|
103
104
|
// Update lexical node (with key nodeKey) with new data
|
|
104
105
|
editor.update(() => {
|
|
105
106
|
const uploadNode = $getNodeByKey(nodeKey);
|
|
106
107
|
if (uploadNode) {
|
|
107
108
|
const newData = {
|
|
108
109
|
...uploadNode.getData(),
|
|
109
|
-
fields:
|
|
110
|
+
fields: data_0
|
|
110
111
|
};
|
|
111
112
|
uploadNode.setData(newData);
|
|
112
113
|
}
|
|
@@ -115,6 +116,7 @@ export const UploadComponent = props => {
|
|
|
115
116
|
const aspectRatio = thumbnailSRC && data?.width && data?.height ? data.width > data.height ? 'landscape' : 'portrait' : 'landscape';
|
|
116
117
|
return /*#__PURE__*/_jsxs("div", {
|
|
117
118
|
className: `${baseClass}__contents ${baseClass}__contents--${aspectRatio}`,
|
|
119
|
+
"data-align": format || undefined,
|
|
118
120
|
"data-filename": data?.filename,
|
|
119
121
|
ref: uploadRef,
|
|
120
122
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","formatDrawerSlug","Thumbnail","useConfig","useEditDepth","usePayloadAPI","useTranslation","$getNodeByKey","isImage","React","useCallback","useId","useReducer","useRef","useState","useEditorConfigContext","FieldsDrawer","useLexicalDocumentDrawer","useLexicalDrawer","INSERT_UPLOAD_WITH_DRAWER_COMMAND","initialParams","depth","UploadComponent","props","className","baseClass","data","fields","relationTo","value","nodeKey","Error","config","routes","api","serverURL","getEntityConfig","uploadRef","uuid","editDepth","editor","editorConfig","fieldProps","schemaPath","isEditable","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","filename","ref","_jsx","fileSrc","mimeType","size","role","buttonStyle","disabled","el","icon","onClick","round","tooltip","dispatchCommand","replace","e","preventDefault","labels","singular","onSave","drawerSlug","drawerTitle","label","featureKey","handleDrawerSubmit","schemaPathSuffix"],"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 { useLexicalEditable } from '@lexical/react/useLexicalEditable'\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 { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport './index.scss'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n className: string\n data: UploadData\n format?: ElementFormatType\n nodeKey: string\n}\n\nexport const UploadComponent: React.FC<ElementProps> = (props) => {\n const {\n className: baseClass,\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: { schemaPath },\n } = useEditorConfigContext()\n const isEditable = useLexicalEditable()\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}__contents ${baseClass}__contents--${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 {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={!isEditable}\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={!isEditable}\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={!isEditable}\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"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,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;AACx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Q,EAAEzD,IAAA;;;QAKxDhB,KAAA,gBAAQwD,IAAA,CAAC5B,cAAA;MAAe8C,MAAA,EAAQpC;SAAmB,MACnDC,cAAA,gBACCiB,IAAA,CAACrE,YAAA;MACCU,IAAA,EAAMC,MAAA;MACN6E,UAAA,EAAYnD,qBAAA;MACZoD,WAAA,EAAa3D,CAAA,CAAE,qBAAqB;QAClC4D,KAAA,EAAO3G,cAAA,CAAemD,iBAAA,CAAkBmD,MAAM,CAACC,QAAQ,EAAEzD,IAAA;MAC3D;MACA8D,UAAA,EAAW;MACXC,kBAAA,EAAoBnC,yBAAA;MACpB9B,UAAA,EAAYA,UAAA;MACZkE,gBAAA,EAAkB3D,iBAAA,CAAkBI;SAEpC;;AAGV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","formatDrawerSlug","Thumbnail","useConfig","useEditDepth","usePayloadAPI","useTranslation","$getNodeByKey","isImage","React","useCallback","useId","useReducer","useRef","useState","useEditorConfigContext","FieldsDrawer","useLexicalDocumentDrawer","useLexicalDrawer","INSERT_UPLOAD_WITH_DRAWER_COMMAND","initialParams","depth","UploadComponent","props","className","baseClass","data","fields","relationTo","value","format","nodeKey","Error","config","routes","api","serverURL","getEntityConfig","uploadRef","uuid","editDepth","editor","editorConfig","fieldProps","schemaPath","isEditable","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","collectionSlug","componentID","extraFieldsDrawerSlug","slug","toggleDrawer","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","update","remove","updateUpload","_data","hasExtraFields","resolvedFeatureMap","get","sanitizedClientFeatureProps","collections","onExtraFieldsDrawerSubmit","_","uploadNode","newData","getData","setData","aspectRatio","width","height","_jsxs","undefined","filename","ref","_jsx","fileSrc","mimeType","size","role","buttonStyle","disabled","el","icon","onClick","round","tooltip","dispatchCommand","replace","e","preventDefault","labels","singular","onSave","drawerSlug","drawerTitle","label","featureKey","handleDrawerSubmit","schemaPathSuffix"],"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 { useLexicalEditable } from '@lexical/react/useLexicalEditable'\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 { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport './index.scss'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n className: string\n data: UploadData\n format?: ElementFormatType\n nodeKey: string\n}\n\nexport const UploadComponent: React.FC<ElementProps> = (props) => {\n const {\n className: baseClass,\n data: { fields, relationTo, value },\n format,\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: { schemaPath },\n } = useEditorConfigContext()\n const isEditable = useLexicalEditable()\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}__contents ${baseClass}__contents--${aspectRatio}`}\n data-align={format || undefined}\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 {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={!isEditable}\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={!isEditable}\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={!isEditable}\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"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,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,iCAAiC,QAAQ;AAGlD,MAAMC,aAAA,GAAgB;EACpBC,KAAA,EAAO;AACT;AASA,OAAO,MAAMC,eAAA,GAA2CC,KAAA;EACtD,MAAM;IACJC,SAAA,EAAWC,SAAS;IACpBC,IAAA,EAAM;MAAEC,MAAM;MAAEC,UAAU;MAAEC;IAAK,CAAE;IACnCC,MAAM;IACNC;EAAO,CACR,GAAGR,KAAA;EAEJ,IAAI,OAAOM,KAAA,KAAU,UAAU;IAC7B,MAAM,IAAIG,KAAA,CACR;EAEJ;EAEA,MAAM;IACJC,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC;M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