@lvce-editor/editor-worker 18.14.0 → 18.16.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/editorWorkerMain.js +42 -20
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -6132,7 +6132,17 @@ const handleTripleClick = (editor, modifier, x, y) => {
|
|
|
6132
6132
|
return selectLine(editor);
|
|
6133
6133
|
};
|
|
6134
6134
|
|
|
6135
|
-
const
|
|
6135
|
+
const getModifier = (altKey, ctrlKey) => {
|
|
6136
|
+
if (altKey) {
|
|
6137
|
+
return Alt;
|
|
6138
|
+
}
|
|
6139
|
+
if (ctrlKey) {
|
|
6140
|
+
return Ctrl;
|
|
6141
|
+
}
|
|
6142
|
+
return 0;
|
|
6143
|
+
};
|
|
6144
|
+
const handleMouseDown = (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6145
|
+
const modifier = getModifier(altKey, ctrlKey);
|
|
6136
6146
|
switch (detail) {
|
|
6137
6147
|
case Double:
|
|
6138
6148
|
return handleDoubleClick(state, modifier, x, y);
|
|
@@ -6341,20 +6351,8 @@ const handlePointerCaptureLost = editor => {
|
|
|
6341
6351
|
return editor;
|
|
6342
6352
|
};
|
|
6343
6353
|
|
|
6344
|
-
const handlePointerDown$1 =
|
|
6345
|
-
|
|
6346
|
-
const clickDetail = Single; // TODO
|
|
6347
|
-
// console.log({ detail })
|
|
6348
|
-
switch (clickDetail) {
|
|
6349
|
-
case Double:
|
|
6350
|
-
return handleDoubleClick(state, modifier, x, y);
|
|
6351
|
-
case Single:
|
|
6352
|
-
return handleSingleClick(state, modifier, x, y);
|
|
6353
|
-
case Triple:
|
|
6354
|
-
return handleTripleClick(state, modifier, x, y);
|
|
6355
|
-
default:
|
|
6356
|
-
return state;
|
|
6357
|
-
}
|
|
6354
|
+
const handlePointerDown$1 = state => {
|
|
6355
|
+
return state;
|
|
6358
6356
|
};
|
|
6359
6357
|
|
|
6360
6358
|
const moveRectangleSelection = (editor, position) => {
|
|
@@ -9560,6 +9558,7 @@ const HandleCompositionUpdate = 12;
|
|
|
9560
9558
|
const HandleContextMenu = 13;
|
|
9561
9559
|
const HandleCut = 14;
|
|
9562
9560
|
const HandleFocus = 15;
|
|
9561
|
+
const HandleMouseDown = 18;
|
|
9563
9562
|
const HandleMouseMove = 19;
|
|
9564
9563
|
const HandlePaste = 20;
|
|
9565
9564
|
const HandlePointerDown = 21;
|
|
@@ -9900,16 +9899,35 @@ const unsetAdditionalFocus = async focusKey => {
|
|
|
9900
9899
|
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
9901
9900
|
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
9902
9901
|
};
|
|
9902
|
+
const shouldUpdateVisibleTextData = (oldState, newState) => {
|
|
9903
|
+
if (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences) {
|
|
9904
|
+
return false;
|
|
9905
|
+
}
|
|
9906
|
+
return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.debugEnabled !== newState.debugEnabled;
|
|
9907
|
+
};
|
|
9903
9908
|
const updateDerivedState = async (oldState, newState) => {
|
|
9909
|
+
let finalState = newState;
|
|
9910
|
+
if (shouldUpdateVisibleTextData(oldState, newState)) {
|
|
9911
|
+
const syncIncremental = getEnabled();
|
|
9912
|
+
const {
|
|
9913
|
+
differences,
|
|
9914
|
+
textInfos
|
|
9915
|
+
} = await getVisible$1(newState, syncIncremental);
|
|
9916
|
+
finalState = {
|
|
9917
|
+
...newState,
|
|
9918
|
+
differences,
|
|
9919
|
+
textInfos
|
|
9920
|
+
};
|
|
9921
|
+
}
|
|
9904
9922
|
if (!shouldUpdateSelectionData(oldState, newState)) {
|
|
9905
|
-
return
|
|
9923
|
+
return finalState;
|
|
9906
9924
|
}
|
|
9907
9925
|
const {
|
|
9908
9926
|
cursorInfos,
|
|
9909
9927
|
selectionInfos
|
|
9910
|
-
} = await getVisible(
|
|
9928
|
+
} = await getVisible(finalState);
|
|
9911
9929
|
return {
|
|
9912
|
-
...
|
|
9930
|
+
...finalState,
|
|
9913
9931
|
cursorInfos,
|
|
9914
9932
|
selectionInfos
|
|
9915
9933
|
};
|
|
@@ -11590,7 +11608,7 @@ const getEditorVirtualDom = ({
|
|
|
11590
11608
|
}, ...selectionsDom, {
|
|
11591
11609
|
childCount: textInfos.length,
|
|
11592
11610
|
className: 'EditorRows',
|
|
11593
|
-
|
|
11611
|
+
onMouseDown: HandleMouseDown,
|
|
11594
11612
|
onPointerDown: HandlePointerDown,
|
|
11595
11613
|
type: Div
|
|
11596
11614
|
}, ...rowsDom, {
|
|
@@ -11914,9 +11932,12 @@ const renderEventListeners = () => {
|
|
|
11914
11932
|
name: HandlePaste,
|
|
11915
11933
|
params: ['paste', 'event.clipboardData ? event.clipboardData.getData("text/plain") : ""'],
|
|
11916
11934
|
preventDefault: true
|
|
11935
|
+
}, {
|
|
11936
|
+
name: HandleMouseDown,
|
|
11937
|
+
params: ['handleMouseDown', 'event.button', 'event.altKey', 'event.ctrlKey', ClientX, ClientY, 'event.detail']
|
|
11917
11938
|
}, {
|
|
11918
11939
|
name: HandlePointerDown,
|
|
11919
|
-
params: ['handlePointerDown', 'event.button', 'event.altKey', 'event.ctrlKey', ClientX, ClientY],
|
|
11940
|
+
params: ['handlePointerDown', 'event.button', 'event.altKey', 'event.ctrlKey', ClientX, ClientY, 'event.detail'],
|
|
11920
11941
|
trackPointerEvents: [HandlePointerMove, HandlePointerUp]
|
|
11921
11942
|
}, {
|
|
11922
11943
|
name: HandlePointerMove,
|
|
@@ -12024,6 +12045,7 @@ const wrapCommand = fn => async (editorUid, ...args) => {
|
|
|
12024
12045
|
return newEditor;
|
|
12025
12046
|
}
|
|
12026
12047
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
12048
|
+
|
|
12027
12049
|
// TODO if editor did not change, no need to update furthur
|
|
12028
12050
|
|
|
12029
12051
|
// TODO combine neweditor with latest editor?
|