@payloadcms/richtext-lexical 3.0.0-beta.90 → 3.0.0-beta.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-SUWHJ4HF.js +2 -0
- package/dist/exports/client/Field-SUWHJ4HF.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js +2 -0
- package/dist/exports/client/RelationshipComponent-EZORSGUZ.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-NI6Z4GBD.js → chunk-OLSILJA6.js} +1 -1
- package/dist/exports/client/{chunk-NI6Z4GBD.js.map → chunk-OLSILJA6.js.map} +1 -1
- package/dist/exports/client/{chunk-G5DTIOPI.js → chunk-TD7O23AB.js} +2 -2
- package/dist/exports/client/{chunk-G5DTIOPI.js.map → chunk-TD7O23AB.js.map} +2 -2
- package/dist/exports/client/{chunk-LGUXX2QH.js → chunk-UJDWBQ2K.js} +2 -2
- package/dist/exports/client/{chunk-LGUXX2QH.js.map → chunk-UJDWBQ2K.js.map} +2 -2
- package/dist/exports/client/{chunk-OKMIHD2R.js → chunk-YL453UOS.js} +2 -2
- package/dist/exports/client/chunk-YSI2QILQ.js +2 -0
- package/dist/exports/client/{chunk-TO2W7Q2G.js.map → chunk-YSI2QILQ.js.map} +2 -2
- package/dist/exports/client/component-2YLEVOFH.js +2 -0
- package/dist/exports/client/component-2YLEVOFH.js.map +7 -0
- package/dist/exports/client/{component-LCAAX56T.js → component-7RAP75FW.js} +2 -2
- package/dist/exports/client/{componentInline-72VZAAHP.js → componentInline-YSHGRL2J.js} +2 -2
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/debug/testRecorder/client/plugin/index.js +187 -363
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +234 -470
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -16
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +59 -123
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +5 -3
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/server/baseFields.d.ts.map +1 -1
- package/dist/features/link/server/baseFields.js +12 -2
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +8 -5
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +6 -4
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +53 -94
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +3 -0
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +9 -7
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -19
- package/dist/index.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -109
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +96 -135
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +114 -139
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +7 -25
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +4 -6
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/ui/icons/Caret/index.svg +2 -2
- package/dist/lexical/utils/setFloatingElemPosition.js +1 -1
- package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/lexical/utils/url.d.ts +5 -0
- package/dist/lexical/utils/url.d.ts.map +1 -1
- package/dist/lexical/utils/url.js +7 -0
- package/dist/lexical/utils/url.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js +16 -1
- package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
- package/package.json +13 -13
- package/dist/exports/client/Field-63NGLPJB.js +0 -2
- package/dist/exports/client/Field-63NGLPJB.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-3QWBV4GT.js +0 -2
- package/dist/exports/client/RelationshipComponent-3QWBV4GT.js.map +0 -7
- package/dist/exports/client/chunk-TO2W7Q2G.js +0 -2
- package/dist/exports/client/component-3OFD6Q4Z.js +0 -2
- package/dist/exports/client/component-3OFD6Q4Z.js.map +0 -7
- /package/dist/exports/client/{chunk-OKMIHD2R.js.map → chunk-YL453UOS.js.map} +0 -0
- /package/dist/exports/client/{component-LCAAX56T.js.map → component-7RAP75FW.js.map} +0 -0
- /package/dist/exports/client/{componentInline-72VZAAHP.js.map → componentInline-YSHGRL2J.js.map} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { c as _c } from "react/compiler-runtime";
|
|
4
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
6
5
|
import { $createParagraphNode, $createTextNode, $getRoot } from 'lexical';
|
|
@@ -126,39 +125,23 @@ function getPathFromNodeToEditor(node, rootElement) {
|
|
|
126
125
|
}
|
|
127
126
|
const keyPresses = new Set(['Enter', 'Backspace', 'Delete', 'Escape', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']);
|
|
128
127
|
function useTestRecorder(editor) {
|
|
129
|
-
const
|
|
130
|
-
let t0;
|
|
131
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
132
|
-
t0 = [];
|
|
133
|
-
$[0] = t0;
|
|
134
|
-
} else {
|
|
135
|
-
t0 = $[0];
|
|
136
|
-
}
|
|
137
|
-
const [steps, setSteps] = useState(t0);
|
|
128
|
+
const [steps, setSteps] = useState([]);
|
|
138
129
|
const [isRecording, setIsRecording] = useState(false);
|
|
139
|
-
const [, setCurrentInnerHTML] = useState(
|
|
140
|
-
const [templatedTest, setTemplatedTest] = useState(
|
|
130
|
+
const [, setCurrentInnerHTML] = useState('');
|
|
131
|
+
const [templatedTest, setTemplatedTest] = useState('');
|
|
141
132
|
const previousSelectionRef = useRef(null);
|
|
142
133
|
const skipNextSelectionChangeRef = useRef(false);
|
|
143
134
|
const preRef = useRef(null);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if ($[3] !== editor || $[4] !== steps) {
|
|
155
|
-
t2 = () => {
|
|
156
|
-
const rootElement = editor.getRootElement();
|
|
157
|
-
const browserSelection = window.getSelection();
|
|
158
|
-
if (rootElement == null || browserSelection == null || browserSelection.anchorNode == null || browserSelection.focusNode == null || !rootElement.contains(browserSelection.anchorNode) || !rootElement.contains(browserSelection.focusNode)) {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
return `
|
|
135
|
+
const getCurrentEditor = useCallback(() => {
|
|
136
|
+
return editor;
|
|
137
|
+
}, [editor]);
|
|
138
|
+
const generateTestContent = useCallback(() => {
|
|
139
|
+
const rootElement = editor.getRootElement();
|
|
140
|
+
const browserSelection = window.getSelection();
|
|
141
|
+
if (rootElement == null || browserSelection == null || browserSelection.anchorNode == null || browserSelection.focusNode == null || !rootElement.contains(browserSelection.anchorNode) || !rootElement.contains(browserSelection.focusNode)) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
return `
|
|
162
145
|
import {
|
|
163
146
|
initializeE2E,
|
|
164
147
|
assertHTMLSnapshot,
|
|
@@ -179,126 +162,82 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
179
162
|
});
|
|
180
163
|
});
|
|
181
164
|
`;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
165
|
+
}, [editor, steps]);
|
|
166
|
+
// just a wrapper around inserting new actions so that we can
|
|
167
|
+
// coalesce some actions like insertText/moveNativeSelection
|
|
168
|
+
const pushStep = useCallback((name, value) => {
|
|
169
|
+
setSteps(currentSteps => {
|
|
170
|
+
// trying to group steps
|
|
171
|
+
const currentIndex = steps.length - 1;
|
|
172
|
+
const lastStep = steps[currentIndex];
|
|
173
|
+
if (lastStep) {
|
|
174
|
+
if (lastStep.name === name) {
|
|
175
|
+
if (name === 'type') {
|
|
176
|
+
// for typing events we just append the text
|
|
177
|
+
return [...steps.slice(0, currentIndex), {
|
|
178
|
+
...lastStep,
|
|
179
|
+
value: lastStep.value + value
|
|
180
|
+
}];
|
|
181
|
+
} else {
|
|
182
|
+
// for other events we bump the counter if their values are the same
|
|
183
|
+
if (lastStep.value === value) {
|
|
199
184
|
return [...steps.slice(0, currentIndex), {
|
|
200
185
|
...lastStep,
|
|
201
|
-
|
|
186
|
+
count: lastStep.count + 1
|
|
202
187
|
}];
|
|
203
|
-
} else {
|
|
204
|
-
if (lastStep.value === value) {
|
|
205
|
-
return [...steps.slice(0, currentIndex), {
|
|
206
|
-
...lastStep,
|
|
207
|
-
count: lastStep.count + 1
|
|
208
|
-
}];
|
|
209
|
-
}
|
|
210
188
|
}
|
|
211
189
|
}
|
|
212
190
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
191
|
+
}
|
|
192
|
+
// could not group, just append a new one
|
|
193
|
+
return [...currentSteps, {
|
|
194
|
+
name,
|
|
195
|
+
count: 1,
|
|
196
|
+
value
|
|
197
|
+
}];
|
|
198
|
+
});
|
|
199
|
+
}, [steps, setSteps]);
|
|
200
|
+
useLayoutEffect(() => {
|
|
201
|
+
const onKeyDown = event => {
|
|
202
|
+
if (!isRecording) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const key = event.key;
|
|
206
|
+
if (isSelectAll(event)) {
|
|
207
|
+
pushStep('selectAll', '');
|
|
208
|
+
} else if (keyPresses.has(key)) {
|
|
209
|
+
pushStep('press', event.key);
|
|
210
|
+
} else if ([...key].length > 1) {
|
|
211
|
+
pushStep('keydown', event.key);
|
|
212
|
+
} else {
|
|
213
|
+
pushStep('type', event.key);
|
|
214
|
+
}
|
|
219
215
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if ($[8] !== isRecording || $[9] !== pushStep || $[10] !== editor) {
|
|
229
|
-
t4 = () => {
|
|
230
|
-
const onKeyDown = event => {
|
|
231
|
-
if (!isRecording) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const key = event.key;
|
|
235
|
-
if (isSelectAll(event)) {
|
|
236
|
-
pushStep("selectAll", "");
|
|
237
|
-
} else {
|
|
238
|
-
if (keyPresses.has(key)) {
|
|
239
|
-
pushStep("press", event.key);
|
|
240
|
-
} else {
|
|
241
|
-
if ([...key].length > 1) {
|
|
242
|
-
pushStep("keydown", event.key);
|
|
243
|
-
} else {
|
|
244
|
-
pushStep("type", event.key);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
const onKeyUp = event_0 => {
|
|
250
|
-
if (!isRecording) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const key_0 = event_0.key;
|
|
254
|
-
if (!keyPresses.has(key_0) && [...key_0].length > 1) {
|
|
255
|
-
pushStep("keyup", event_0.key);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
return editor.registerRootListener((rootElement_0, prevRootElement) => {
|
|
259
|
-
if (prevRootElement !== null) {
|
|
260
|
-
prevRootElement.removeEventListener("keydown", onKeyDown);
|
|
261
|
-
prevRootElement.removeEventListener("keyup", onKeyUp);
|
|
262
|
-
}
|
|
263
|
-
if (rootElement_0 !== null) {
|
|
264
|
-
rootElement_0.addEventListener("keydown", onKeyDown);
|
|
265
|
-
rootElement_0.addEventListener("keyup", onKeyUp);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
216
|
+
const onKeyUp = event_0 => {
|
|
217
|
+
if (!isRecording) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const key_0 = event_0.key;
|
|
221
|
+
if (!keyPresses.has(key_0) && [...key_0].length > 1) {
|
|
222
|
+
pushStep('keyup', event_0.key);
|
|
223
|
+
}
|
|
268
224
|
};
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
let t6;
|
|
281
|
-
if ($[13] !== generateTestContent) {
|
|
282
|
-
t6 = [generateTestContent];
|
|
283
|
-
$[13] = generateTestContent;
|
|
284
|
-
$[14] = t6;
|
|
285
|
-
} else {
|
|
286
|
-
t6 = $[14];
|
|
287
|
-
}
|
|
225
|
+
return editor.registerRootListener((rootElement_0, prevRootElement) => {
|
|
226
|
+
if (prevRootElement !== null) {
|
|
227
|
+
prevRootElement.removeEventListener('keydown', onKeyDown);
|
|
228
|
+
prevRootElement.removeEventListener('keyup', onKeyUp);
|
|
229
|
+
}
|
|
230
|
+
if (rootElement_0 !== null) {
|
|
231
|
+
rootElement_0.addEventListener('keydown', onKeyDown);
|
|
232
|
+
rootElement_0.addEventListener('keyup', onKeyUp);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}, [editor, isRecording, pushStep]);
|
|
288
236
|
useLayoutEffect(() => {
|
|
289
237
|
if (preRef.current) {
|
|
290
238
|
preRef.current.scrollTo(0, preRef.current.scrollHeight);
|
|
291
239
|
}
|
|
292
|
-
},
|
|
293
|
-
let t7;
|
|
294
|
-
if ($[15] !== generateTestContent || $[16] !== steps) {
|
|
295
|
-
t7 = [generateTestContent, steps];
|
|
296
|
-
$[15] = generateTestContent;
|
|
297
|
-
$[16] = steps;
|
|
298
|
-
$[17] = t7;
|
|
299
|
-
} else {
|
|
300
|
-
t7 = $[17];
|
|
301
|
-
}
|
|
240
|
+
}, [generateTestContent]);
|
|
302
241
|
useEffect(() => {
|
|
303
242
|
if (steps) {
|
|
304
243
|
const testContent = generateTestContent();
|
|
@@ -309,213 +248,117 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
309
248
|
preRef.current.scrollTo(0, preRef.current.scrollHeight);
|
|
310
249
|
}
|
|
311
250
|
}
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
dirtyLeaves,
|
|
320
|
-
editorState
|
|
321
|
-
} = t9;
|
|
322
|
-
if (!isRecording) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
const currentSelection = editorState._selection;
|
|
326
|
-
const previousSelection = previousSelectionRef.current;
|
|
327
|
-
const skipNextSelectionChange = skipNextSelectionChangeRef.current;
|
|
328
|
-
if (previousSelection !== currentSelection) {
|
|
329
|
-
if (dirtyLeaves.size === 0 && dirtyElements.size === 0 && !skipNextSelectionChange) {
|
|
330
|
-
const browserSelection_0 = window.getSelection();
|
|
331
|
-
if (browserSelection_0 && (browserSelection_0.anchorNode == null || browserSelection_0.focusNode == null)) {
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
previousSelectionRef.current = currentSelection;
|
|
336
|
-
}
|
|
337
|
-
skipNextSelectionChangeRef.current = false;
|
|
338
|
-
const testContent_0 = generateTestContent();
|
|
339
|
-
if (testContent_0 !== null) {
|
|
340
|
-
setTemplatedTest(testContent_0);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
return removeUpdateListener;
|
|
344
|
-
};
|
|
345
|
-
$[18] = editor;
|
|
346
|
-
$[19] = isRecording;
|
|
347
|
-
$[20] = generateTestContent;
|
|
348
|
-
$[21] = t8;
|
|
349
|
-
} else {
|
|
350
|
-
t8 = $[21];
|
|
351
|
-
}
|
|
352
|
-
let t9;
|
|
353
|
-
if ($[22] !== editor || $[23] !== generateTestContent || $[24] !== isRecording || $[25] !== pushStep) {
|
|
354
|
-
t9 = [editor, generateTestContent, isRecording, pushStep];
|
|
355
|
-
$[22] = editor;
|
|
356
|
-
$[23] = generateTestContent;
|
|
357
|
-
$[24] = isRecording;
|
|
358
|
-
$[25] = pushStep;
|
|
359
|
-
$[26] = t9;
|
|
360
|
-
} else {
|
|
361
|
-
t9 = $[26];
|
|
362
|
-
}
|
|
363
|
-
useEffect(t8, t9);
|
|
364
|
-
let t10;
|
|
365
|
-
if ($[27] !== isRecording || $[28] !== editor || $[29] !== setCurrentInnerHTML) {
|
|
366
|
-
t10 = () => {
|
|
251
|
+
}, [generateTestContent, steps]);
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
const removeUpdateListener = editor.registerUpdateListener(({
|
|
254
|
+
dirtyElements,
|
|
255
|
+
dirtyLeaves,
|
|
256
|
+
editorState
|
|
257
|
+
}) => {
|
|
367
258
|
if (!isRecording) {
|
|
368
259
|
return;
|
|
369
260
|
}
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
261
|
+
const currentSelection = editorState._selection;
|
|
262
|
+
const previousSelection = previousSelectionRef.current;
|
|
263
|
+
const skipNextSelectionChange = skipNextSelectionChangeRef.current;
|
|
264
|
+
if (previousSelection !== currentSelection) {
|
|
265
|
+
if (dirtyLeaves.size === 0 && dirtyElements.size === 0 && !skipNextSelectionChange) {
|
|
266
|
+
const browserSelection_0 = window.getSelection();
|
|
267
|
+
if (browserSelection_0 && (browserSelection_0.anchorNode == null || browserSelection_0.focusNode == null)) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
374
270
|
}
|
|
375
|
-
|
|
376
|
-
return removeUpdateListener_0;
|
|
377
|
-
};
|
|
378
|
-
$[27] = isRecording;
|
|
379
|
-
$[28] = editor;
|
|
380
|
-
$[29] = setCurrentInnerHTML;
|
|
381
|
-
$[30] = t10;
|
|
382
|
-
} else {
|
|
383
|
-
t10 = $[30];
|
|
384
|
-
}
|
|
385
|
-
let t11;
|
|
386
|
-
if ($[31] !== editor || $[32] !== isRecording) {
|
|
387
|
-
t11 = [editor, isRecording];
|
|
388
|
-
$[31] = editor;
|
|
389
|
-
$[32] = isRecording;
|
|
390
|
-
$[33] = t11;
|
|
391
|
-
} else {
|
|
392
|
-
t11 = $[33];
|
|
393
|
-
}
|
|
394
|
-
useEffect(t10, t11);
|
|
395
|
-
let t12;
|
|
396
|
-
if ($[34] !== isRecording) {
|
|
397
|
-
t12 = currentEditor => {
|
|
398
|
-
if (!isRecording) {
|
|
399
|
-
currentEditor.update(() => {
|
|
400
|
-
const root = $getRoot();
|
|
401
|
-
root.clear();
|
|
402
|
-
const text = $createTextNode();
|
|
403
|
-
root.append($createParagraphNode().append(text));
|
|
404
|
-
text.select();
|
|
405
|
-
});
|
|
406
|
-
setSteps([]);
|
|
271
|
+
previousSelectionRef.current = currentSelection;
|
|
407
272
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
} else {
|
|
413
|
-
t12 = $[35];
|
|
414
|
-
}
|
|
415
|
-
const toggleEditorSelection = t12;
|
|
416
|
-
let t13;
|
|
417
|
-
if ($[36] !== isRecording || $[37] !== getCurrentEditor || $[38] !== pushStep) {
|
|
418
|
-
t13 = () => {
|
|
419
|
-
if (!isRecording) {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
const browserSelection_1 = window.getSelection();
|
|
423
|
-
if (browserSelection_1 === null || browserSelection_1.anchorNode == null || browserSelection_1.focusNode == null) {
|
|
424
|
-
return;
|
|
273
|
+
skipNextSelectionChangeRef.current = false;
|
|
274
|
+
const testContent_0 = generateTestContent();
|
|
275
|
+
if (testContent_0 !== null) {
|
|
276
|
+
setTemplatedTest(testContent_0);
|
|
425
277
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
if (focusNode !== null) {
|
|
439
|
-
focusPath = getPathFromNodeToEditor(focusNode, rootElement_2);
|
|
278
|
+
});
|
|
279
|
+
return removeUpdateListener;
|
|
280
|
+
}, [editor, generateTestContent, isRecording, pushStep]);
|
|
281
|
+
// save innerHTML
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
if (!isRecording) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const removeUpdateListener_0 = editor.registerUpdateListener(() => {
|
|
287
|
+
const rootElement_1 = editor.getRootElement();
|
|
288
|
+
if (rootElement_1 !== null) {
|
|
289
|
+
setCurrentInnerHTML(rootElement_1?.innerHTML);
|
|
440
290
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
291
|
+
});
|
|
292
|
+
return removeUpdateListener_0;
|
|
293
|
+
}, [editor, isRecording]);
|
|
294
|
+
// clear editor and start recording
|
|
295
|
+
const toggleEditorSelection = useCallback(currentEditor => {
|
|
296
|
+
if (!isRecording) {
|
|
297
|
+
currentEditor.update(() => {
|
|
298
|
+
const root = $getRoot();
|
|
299
|
+
root.clear();
|
|
300
|
+
const text = $createTextNode();
|
|
301
|
+
root.append($createParagraphNode().append(text));
|
|
302
|
+
text.select();
|
|
448
303
|
});
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
304
|
+
setSteps([]);
|
|
305
|
+
}
|
|
306
|
+
setIsRecording(currentIsRecording => !currentIsRecording);
|
|
307
|
+
}, [isRecording]);
|
|
308
|
+
const onSnapshotClick = useCallback(() => {
|
|
309
|
+
if (!isRecording) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const browserSelection_1 = window.getSelection();
|
|
313
|
+
if (browserSelection_1 === null || browserSelection_1.anchorNode == null || browserSelection_1.focusNode == null) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const {
|
|
317
|
+
anchorNode,
|
|
318
|
+
anchorOffset,
|
|
319
|
+
focusNode,
|
|
320
|
+
focusOffset
|
|
321
|
+
} = sanitizeSelection(browserSelection_1);
|
|
322
|
+
const rootElement_2 = getCurrentEditor().getRootElement();
|
|
323
|
+
let anchorPath;
|
|
324
|
+
if (anchorNode !== null) {
|
|
325
|
+
anchorPath = getPathFromNodeToEditor(anchorNode, rootElement_2);
|
|
326
|
+
}
|
|
327
|
+
let focusPath;
|
|
328
|
+
if (focusNode !== null) {
|
|
329
|
+
focusPath = getPathFromNodeToEditor(focusNode, rootElement_2);
|
|
330
|
+
}
|
|
331
|
+
pushStep('snapshot', {
|
|
332
|
+
anchorNode,
|
|
333
|
+
anchorOffset,
|
|
334
|
+
anchorPath,
|
|
335
|
+
focusNode,
|
|
336
|
+
focusOffset,
|
|
337
|
+
focusPath
|
|
338
|
+
});
|
|
339
|
+
}, [pushStep, isRecording, getCurrentEditor]);
|
|
340
|
+
const onCopyClick = useCallback(() => {
|
|
341
|
+
copy(generateTestContent());
|
|
342
|
+
}, [generateTestContent]);
|
|
343
|
+
const onDownloadClick = useCallback(() => {
|
|
344
|
+
download('test.js', generateTestContent());
|
|
345
|
+
}, [generateTestContent]);
|
|
346
|
+
const button = /*#__PURE__*/_jsx("button", {
|
|
347
|
+
className: `editor-dev-button ${isRecording ? 'active' : ''}`,
|
|
348
|
+
id: "test-recorder-button",
|
|
349
|
+
onClick: e => {
|
|
484
350
|
toggleEditorSelection(getCurrentEditor());
|
|
485
351
|
e.preventDefault();
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
const t18 = isRecording ? "Disable test recorder" : "Enable test recorder";
|
|
494
|
-
const t19 = isRecording ? "Disable test recorder" : "Enable test recorder";
|
|
495
|
-
let t20;
|
|
496
|
-
if ($[47] !== t16 || $[48] !== t17 || $[49] !== t18 || $[50] !== t19) {
|
|
497
|
-
t20 = _jsx("button", {
|
|
498
|
-
className: t16,
|
|
499
|
-
id: "test-recorder-button",
|
|
500
|
-
onClick: t17,
|
|
501
|
-
title: t18,
|
|
502
|
-
type: "button",
|
|
503
|
-
children: t19
|
|
504
|
-
});
|
|
505
|
-
$[47] = t16;
|
|
506
|
-
$[48] = t17;
|
|
507
|
-
$[49] = t18;
|
|
508
|
-
$[50] = t19;
|
|
509
|
-
$[51] = t20;
|
|
510
|
-
} else {
|
|
511
|
-
t20 = $[51];
|
|
512
|
-
}
|
|
513
|
-
const button = t20;
|
|
514
|
-
const output = isRecording ? _jsxs("div", {
|
|
352
|
+
},
|
|
353
|
+
title: isRecording ? 'Disable test recorder' : 'Enable test recorder',
|
|
354
|
+
type: "button",
|
|
355
|
+
children: isRecording ? 'Disable test recorder' : 'Enable test recorder'
|
|
356
|
+
});
|
|
357
|
+
const output = isRecording ? /*#__PURE__*/_jsxs("div", {
|
|
515
358
|
className: "test-recorder-output",
|
|
516
|
-
children: [_jsxs("div", {
|
|
359
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
517
360
|
className: "test-recorder-toolbar",
|
|
518
|
-
children: [_jsx("button", {
|
|
361
|
+
children: [/*#__PURE__*/_jsx("button", {
|
|
519
362
|
className: "test-recorder-button",
|
|
520
363
|
id: "test-recorder-button-snapshot",
|
|
521
364
|
onClick: e_0 => {
|
|
@@ -525,7 +368,7 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
525
368
|
title: "Insert snapshot",
|
|
526
369
|
type: "button",
|
|
527
370
|
children: "Insert Snapshot"
|
|
528
|
-
}), _jsx("button", {
|
|
371
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
529
372
|
className: "test-recorder-button",
|
|
530
373
|
id: "test-recorder-button-copy",
|
|
531
374
|
onClick: e_1 => {
|
|
@@ -535,7 +378,7 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
535
378
|
title: "Copy to clipboard",
|
|
536
379
|
type: "button",
|
|
537
380
|
children: "Copy"
|
|
538
|
-
}), _jsx("button", {
|
|
381
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
539
382
|
className: "test-recorder-button",
|
|
540
383
|
id: "test-recorder-button-download",
|
|
541
384
|
onClick: e_2 => {
|
|
@@ -546,42 +389,23 @@ ${steps.map(formatStep).join(`\n`)}
|
|
|
546
389
|
type: "button",
|
|
547
390
|
children: "Download"
|
|
548
391
|
})]
|
|
549
|
-
}), _jsx("pre", {
|
|
392
|
+
}), /*#__PURE__*/_jsx("pre", {
|
|
550
393
|
id: "test-recorder",
|
|
551
394
|
ref: preRef,
|
|
552
395
|
children: templatedTest
|
|
553
396
|
})]
|
|
554
397
|
}) : null;
|
|
555
|
-
|
|
556
|
-
if ($[52] !== button || $[53] !== output) {
|
|
557
|
-
t21 = [button, output];
|
|
558
|
-
$[52] = button;
|
|
559
|
-
$[53] = output;
|
|
560
|
-
$[54] = t21;
|
|
561
|
-
} else {
|
|
562
|
-
t21 = $[54];
|
|
563
|
-
}
|
|
564
|
-
return t21;
|
|
398
|
+
return [button, output];
|
|
565
399
|
}
|
|
566
400
|
export const TestRecorderPlugin = () => {
|
|
567
|
-
const $ = _c(3);
|
|
568
401
|
const [editor] = useLexicalComposerContext();
|
|
569
402
|
const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor);
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
})]
|
|
578
|
-
});
|
|
579
|
-
$[0] = testRecorderButton;
|
|
580
|
-
$[1] = testRecorderOutput;
|
|
581
|
-
$[2] = t0;
|
|
582
|
-
} else {
|
|
583
|
-
t0 = $[2];
|
|
584
|
-
}
|
|
585
|
-
return t0;
|
|
403
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
404
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
405
|
+
children: "HI"
|
|
406
|
+
}), testRecorderButton, testRecorderOutput, /*#__PURE__*/_jsx("p", {
|
|
407
|
+
children: "DONE"
|
|
408
|
+
})]
|
|
409
|
+
});
|
|
586
410
|
};
|
|
587
411
|
//# sourceMappingURL=index.js.map
|