@lvce-editor/editor-worker 19.74.3 → 19.74.5
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/editorWorkerMain.js +61 -9
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2369,7 +2369,13 @@ const getHorizontalScrollDimensions = ({
|
|
|
2369
2369
|
};
|
|
2370
2370
|
|
|
2371
2371
|
const defaultThreshold = 500;
|
|
2372
|
+
const simpleAscii = /^[\t -~]*$/;
|
|
2372
2373
|
const getSegments = line => {
|
|
2374
|
+
if (simpleAscii.test(line)) {
|
|
2375
|
+
return Array.from({
|
|
2376
|
+
length: line.length + 1
|
|
2377
|
+
}, (_, index) => index);
|
|
2378
|
+
}
|
|
2373
2379
|
if (typeof Intl.Segmenter === 'function') {
|
|
2374
2380
|
// @ts-ignore
|
|
2375
2381
|
return [...Array.from(new Intl.Segmenter(undefined, {
|
|
@@ -8866,6 +8872,26 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
|
|
|
8866
8872
|
};
|
|
8867
8873
|
};
|
|
8868
8874
|
|
|
8875
|
+
// Mouse positions are replaceable; edits and explicit navigation remain ordered.
|
|
8876
|
+
// Check before starting provider work and again before committing its result.
|
|
8877
|
+
const wrapLatestCommand$1 = (fn, returnState = true) => {
|
|
8878
|
+
const latest = new Map();
|
|
8879
|
+
return async (uid, ...args) => {
|
|
8880
|
+
const token = {};
|
|
8881
|
+
latest.set(uid, token);
|
|
8882
|
+
const command = wrapCommand$1(async editor => {
|
|
8883
|
+
if (latest.get(uid) !== token) return editor;
|
|
8884
|
+
const result = await fn(editor, ...args);
|
|
8885
|
+
return latest.get(uid) === token ? result : editor;
|
|
8886
|
+
}, false, returnState);
|
|
8887
|
+
try {
|
|
8888
|
+
return await command(uid);
|
|
8889
|
+
} finally {
|
|
8890
|
+
if (latest.get(uid) === token) latest.delete(uid);
|
|
8891
|
+
}
|
|
8892
|
+
};
|
|
8893
|
+
};
|
|
8894
|
+
|
|
8869
8895
|
// Optional provider work must not hold the editing queue while another worker responds.
|
|
8870
8896
|
const wrapDeferredCommand$1 = (fn, returnState = true) => {
|
|
8871
8897
|
const apply = wrapCommand$1((editor, snapshot, result) => merge(editor, snapshot, result), false, returnState);
|
|
@@ -19486,6 +19512,9 @@ const wrapFocusCommand = fn => {
|
|
|
19486
19512
|
const wrapDeferredCommand = fn => {
|
|
19487
19513
|
return wrapDeferredCommand$1(fn, false);
|
|
19488
19514
|
};
|
|
19515
|
+
const wrapLatestCommand = fn => {
|
|
19516
|
+
return wrapLatestCommand$1(fn, false);
|
|
19517
|
+
};
|
|
19489
19518
|
|
|
19490
19519
|
const executeViewletCommand = (uid, commandId, ...args) => {
|
|
19491
19520
|
return executeViewletCommand$1(commandMap, uid, commandId, ...args);
|
|
@@ -19496,9 +19525,31 @@ const resize = async (editor, dimensions) => {
|
|
|
19496
19525
|
};
|
|
19497
19526
|
const openCompletionDeferred = wrapDeferredCommand(openCompletion);
|
|
19498
19527
|
const updateAutomaticCompletionDeferred = wrapDeferredCommand(updateAutomaticCompletion);
|
|
19499
|
-
const
|
|
19500
|
-
|
|
19528
|
+
const removeHoverFromEditor = editor => {
|
|
19529
|
+
if (!editor.widgets?.some(widget => widget.id === Hover)) {
|
|
19530
|
+
return editor;
|
|
19531
|
+
}
|
|
19532
|
+
const newEditor = {
|
|
19533
|
+
...editor,
|
|
19534
|
+
additionalFocus: 0,
|
|
19535
|
+
focus: FocusEditorText$1,
|
|
19536
|
+
focused: true,
|
|
19537
|
+
widgetRevision: next(editor.uid),
|
|
19538
|
+
widgets: removeEditorWidget(editor.widgets, Hover)
|
|
19539
|
+
};
|
|
19540
|
+
return newEditor;
|
|
19541
|
+
};
|
|
19542
|
+
const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preservesTypingCoalescing = true) => {
|
|
19543
|
+
const command = wrapCommand(async (editor, ...args) => {
|
|
19544
|
+
const newEditor = await fn(editor, ...args);
|
|
19545
|
+
return shouldDismissHover(...args) ? removeHoverFromEditor(newEditor) : newEditor;
|
|
19546
|
+
}, preservesTypingCoalescing);
|
|
19501
19547
|
return async (uid, ...args) => {
|
|
19548
|
+
const dismissHover = shouldDismissHover(...args);
|
|
19549
|
+
if (dismissHover) {
|
|
19550
|
+
clear$2(uid);
|
|
19551
|
+
clear$3(uid);
|
|
19552
|
+
}
|
|
19502
19553
|
await command(uid, ...args);
|
|
19503
19554
|
const editor = get$8(uid)?.newState;
|
|
19504
19555
|
if (editor && (shouldOpenCompletion(...args) && shouldOpenAutomaticCompletion(editor) || editor.widgets?.some(widget => widget.id === Completion && widget.newState.automatic))) {
|
|
@@ -19506,10 +19557,11 @@ const wrapTypingCommand = (fn, shouldOpenCompletion) => {
|
|
|
19506
19557
|
}
|
|
19507
19558
|
};
|
|
19508
19559
|
};
|
|
19509
|
-
const deleteLeftCommand = wrapTypingCommand(deleteCharacterLeft, () => false);
|
|
19510
|
-
const typeCommand = wrapTypingCommand(type, () => true);
|
|
19511
|
-
const typeWithAutoClosingCommand = wrapTypingCommand(typeWithAutoClosing, () => true);
|
|
19512
|
-
const handleBeforeInputCommand = wrapTypingCommand(handleBeforeInput, inputType => inputType === InsertText);
|
|
19560
|
+
const deleteLeftCommand = wrapTypingCommand(deleteCharacterLeft, () => false, () => false);
|
|
19561
|
+
const typeCommand = wrapTypingCommand(type, () => true, Boolean);
|
|
19562
|
+
const typeWithAutoClosingCommand = wrapTypingCommand(typeWithAutoClosing, () => true, Boolean);
|
|
19563
|
+
const handleBeforeInputCommand = wrapTypingCommand(handleBeforeInput, inputType => inputType === InsertText, (inputType, data) => inputType === InsertText && Boolean(data));
|
|
19564
|
+
const handleBeforeInputFromContentEditableCommand = wrapTypingCommand(handleBeforeInputFromContentEditable, () => false, (data, range) => Boolean(data) && Boolean(range), false);
|
|
19513
19565
|
const commandMap = {
|
|
19514
19566
|
'ActivateByEvent.activateByEvent': activateByEvent,
|
|
19515
19567
|
'CodeGenerator.accept': codeGeneratorAccept,
|
|
@@ -19610,7 +19662,7 @@ const commandMap = {
|
|
|
19610
19662
|
'Editor.goToDefinition': wrapCommand(goToDefinition),
|
|
19611
19663
|
'Editor.goToTypeDefinition': wrapCommand(goToTypeDefinition),
|
|
19612
19664
|
'Editor.handleBeforeInput': handleBeforeInputCommand,
|
|
19613
|
-
'Editor.handleBeforeInputFromContentEditable':
|
|
19665
|
+
'Editor.handleBeforeInputFromContentEditable': handleBeforeInputFromContentEditableCommand,
|
|
19614
19666
|
'Editor.handleBlur': wrapCommand(handleBlur$1),
|
|
19615
19667
|
'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
|
|
19616
19668
|
'Editor.handleContextMenu': wrapCommand(handleContextMenu),
|
|
@@ -19621,8 +19673,8 @@ const commandMap = {
|
|
|
19621
19673
|
'Editor.handleMouseDown': wrapCommand(handleMouseDown),
|
|
19622
19674
|
'Editor.handleMouseEnter': handleMouseEnter,
|
|
19623
19675
|
'Editor.handleMouseLeave': handleMouseLeave,
|
|
19624
|
-
'Editor.handleMouseMove':
|
|
19625
|
-
'Editor.handleMouseMoveWithAltKey':
|
|
19676
|
+
'Editor.handleMouseMove': wrapLatestCommand(handleMouseMove),
|
|
19677
|
+
'Editor.handleMouseMoveWithAltKey': wrapLatestCommand(handleMouseMoveWithAltKey),
|
|
19626
19678
|
'Editor.handleNativeSelectionChange': editorHandleNativeSelectionChange,
|
|
19627
19679
|
'Editor.handlePointerCaptureLost': wrapCommand(handlePointerCaptureLost),
|
|
19628
19680
|
'Editor.handlePointerDown': wrapCommand(handlePointerDown$1),
|