@lvce-editor/editor-worker 1.11.0 → 1.13.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/api/api.d.ts +1 -0
- package/dist/editorWorkerMain.js +5 -36
- package/package.json +1 -1
package/dist/api/api.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ interface EventMap {
|
|
|
21
21
|
'Hover.handleSashPointerDown': (state: any, eventX: number, eventY: number) => Promise<any>
|
|
22
22
|
'Hover.handleSashPointerMove': (state: any, eventX: number, eventY: number) => Promise<any>
|
|
23
23
|
'Hover.handleSashPointerUp': (state: any, eventX: number, eventY: number) => Promise<any>
|
|
24
|
+
'Hover.loadContent': (editorUid: number, state: any, position: any) => Promise<any>
|
|
24
25
|
'Hover.render': (oldState: any, newState: any) => Promise<any>
|
|
25
26
|
}
|
|
26
27
|
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -7768,7 +7768,7 @@ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true) =>
|
|
|
7768
7768
|
return dom;
|
|
7769
7769
|
};
|
|
7770
7770
|
|
|
7771
|
-
const getIncrementalEdits = (oldState, newState) => {
|
|
7771
|
+
const getIncrementalEdits = async (oldState, newState) => {
|
|
7772
7772
|
if (!newState.undoStack) {
|
|
7773
7773
|
return undefined;
|
|
7774
7774
|
}
|
|
@@ -7780,39 +7780,8 @@ const getIncrementalEdits = (oldState, newState) => {
|
|
|
7780
7780
|
const lines = newState.lines;
|
|
7781
7781
|
const oldLine = oldState.lines[rowIndex];
|
|
7782
7782
|
const newLine = lines[rowIndex];
|
|
7783
|
-
const
|
|
7784
|
-
|
|
7785
|
-
const initialLineState = newState.lineCache[rowIndex] || getInitialLineState(newTokenizer.initialLineState);
|
|
7786
|
-
const {
|
|
7787
|
-
tokens: oldTokens
|
|
7788
|
-
} = safeTokenizeLine(newState.languageId, oldTokenizer.tokenizeLine, oldLine, initialLineState, newTokenizer.hasArrayReturn);
|
|
7789
|
-
// @ts-ignore
|
|
7790
|
-
const {
|
|
7791
|
-
tokens: newTokens,
|
|
7792
|
-
lineState
|
|
7793
|
-
} = safeTokenizeLine(newState.languageId, newTokenizer.tokenizeLine, newLine, initialLineState, newTokenizer.hasArrayReturn);
|
|
7794
|
-
if (newTokens.length !== oldTokens.length) {
|
|
7795
|
-
return undefined;
|
|
7796
|
-
}
|
|
7797
|
-
const incrementalEdits = [];
|
|
7798
|
-
let offset = 0;
|
|
7799
|
-
const relativeRowIndex = rowIndex - newState.minLineY;
|
|
7800
|
-
for (let i = 0; i < oldTokens.length; i += 2) {
|
|
7801
|
-
const oldTokenType = oldTokens[i];
|
|
7802
|
-
const oldTokenLength = oldTokens[i + 1];
|
|
7803
|
-
const newTokenType = newTokens[i];
|
|
7804
|
-
const newTokenLength = newTokens[i + 1];
|
|
7805
|
-
if (oldTokenType === newTokenType && oldTokenLength !== newTokenLength && oldTokenLength > 0) {
|
|
7806
|
-
const columnTokenIndex = i / 2;
|
|
7807
|
-
incrementalEdits.push({
|
|
7808
|
-
rowIndex: relativeRowIndex,
|
|
7809
|
-
columnIndex: columnTokenIndex,
|
|
7810
|
-
text: newLine.slice(offset, offset + newTokenLength)
|
|
7811
|
-
});
|
|
7812
|
-
}
|
|
7813
|
-
offset += newTokenLength;
|
|
7814
|
-
}
|
|
7815
|
-
if (incrementalEdits.length === 1) {
|
|
7783
|
+
const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid, newState.languageId, oldLine, newLine, rowIndex, newState.minLineY);
|
|
7784
|
+
if (incrementalEdits && incrementalEdits.length === 1) {
|
|
7816
7785
|
return incrementalEdits;
|
|
7817
7786
|
}
|
|
7818
7787
|
}
|
|
@@ -7844,7 +7813,7 @@ const renderLines = {
|
|
|
7844
7813
|
return oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width;
|
|
7845
7814
|
},
|
|
7846
7815
|
async apply(oldState, newState) {
|
|
7847
|
-
const incrementalEdits = getIncrementalEdits(oldState, newState);
|
|
7816
|
+
const incrementalEdits = await getIncrementalEdits(oldState, newState);
|
|
7848
7817
|
if (incrementalEdits) {
|
|
7849
7818
|
return [/* method */'setIncrementalEdits', /* incrementalEdits */incrementalEdits];
|
|
7850
7819
|
}
|
|
@@ -8053,7 +8022,7 @@ const renderColorPicker = async (oldState, newState) => {
|
|
|
8053
8022
|
};
|
|
8054
8023
|
|
|
8055
8024
|
const loadContent = async (editorUid, state, position) => {
|
|
8056
|
-
const hoverInfo = await
|
|
8025
|
+
const hoverInfo = await getEditorHoverInfo(editorUid, position);
|
|
8057
8026
|
if (!hoverInfo) {
|
|
8058
8027
|
return state;
|
|
8059
8028
|
}
|