@lvce-editor/editor-worker 1.7.0 → 1.9.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 +24 -0
- package/dist/api/api.js +0 -0
- package/dist/editorWorkerMain.js +90 -3
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface EventMap {
|
|
2
|
+
'ColorPicker.loadContent': (state: any) => Promise<any>
|
|
3
|
+
'ColorPicker.handleSliderPointerDown': (state: any, x: number, y: number) => Promise<any>
|
|
4
|
+
'ColorPicker.handleSliderPointerMove': (state: any, x: number, y: number) => Promise<any>
|
|
5
|
+
'EditorCompletion.loadContent': (editorUid: number, state: any) => Promise<any>
|
|
6
|
+
'EditorCompletion.selectCurrent': (editorUid: number, state: any) => Promise<any>
|
|
7
|
+
'EditorCompletion.selectIndex': (editorUid: number, state: any, index: number) => Promise<any>
|
|
8
|
+
'Hover.getHoverInfo': (editorUid: number, position: any) => Promise<any>
|
|
9
|
+
'Font.ensure': (fontName: string, fontUrl: string) => Promise<void>
|
|
10
|
+
'Editor.create': (options: any) => Promise<void>
|
|
11
|
+
'Editor.render': (editorUid: number) => Promise<any>
|
|
12
|
+
'FindWidget.loadContent': (editorUid: number) => Promise<any>
|
|
13
|
+
'FindWidget.handleInput': (state: any, value: string) => Promise<any>
|
|
14
|
+
'FindWidget.focusIndex': (state: any, index: number) => Promise<any>
|
|
15
|
+
'FindWidget.focusFirst': (state: any) => Promise<any>
|
|
16
|
+
'FindWidget.focusLast': (state: any) => Promise<any>
|
|
17
|
+
'FindWidget.focusNext': (state: any) => Promise<any>
|
|
18
|
+
'FindWidget.focusPrevious': (state: any) => Promise<any>
|
|
19
|
+
'Editor.offsetAt': (textDocument: any, positionRowIndex: number, positionColumnIndex: number) => Promise<any>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface EditorWorkerApi {
|
|
23
|
+
readonly invoke: <K extends keyof EventMap>(method: K, ...params: Parameters<EventMap[K]>) => Promise<any>
|
|
24
|
+
}
|
package/dist/api/api.js
ADDED
|
File without changes
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -7654,10 +7654,18 @@ const Div = 4;
|
|
|
7654
7654
|
const Span = 8;
|
|
7655
7655
|
const Text = 12;
|
|
7656
7656
|
|
|
7657
|
+
const ColorPicker = 'ColorPicker';
|
|
7658
|
+
const ColorPickerBackgroundColor = 'ColorPickerBackgroundColor';
|
|
7659
|
+
const ColorPickerDark = 'ColorPickerDark';
|
|
7660
|
+
const ColorPickerLight = 'ColorPickerLight';
|
|
7661
|
+
const ColorPickerRectangle = 'ColorPickerRectangle';
|
|
7662
|
+
const ColorPickerSlider = 'ColorPickerSlider';
|
|
7663
|
+
const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
|
|
7657
7664
|
const Diagnostic = 'Diagnostic';
|
|
7658
7665
|
const EditorCursor = 'EditorCursor';
|
|
7659
7666
|
const EditorRow = 'EditorRow';
|
|
7660
7667
|
const EditorSelection = 'EditorSelection';
|
|
7668
|
+
const Viewlet = 'Viewlet';
|
|
7661
7669
|
|
|
7662
7670
|
const getCursorsVirtualDom = cursors => {
|
|
7663
7671
|
const dom = [];
|
|
@@ -7916,7 +7924,7 @@ const renderGutterInfo = {
|
|
|
7916
7924
|
return ['renderGutter', dom];
|
|
7917
7925
|
}
|
|
7918
7926
|
};
|
|
7919
|
-
const render = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus, renderDecorations, renderGutterInfo];
|
|
7927
|
+
const render$1 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus, renderDecorations, renderGutterInfo];
|
|
7920
7928
|
const renderEditor = async id => {
|
|
7921
7929
|
const instance = get$6(id);
|
|
7922
7930
|
if (!instance) {
|
|
@@ -7928,7 +7936,7 @@ const renderEditor = async id => {
|
|
|
7928
7936
|
} = instance;
|
|
7929
7937
|
const commands = [];
|
|
7930
7938
|
set$6(id, newState, newState);
|
|
7931
|
-
for (const item of render) {
|
|
7939
|
+
for (const item of render$1) {
|
|
7932
7940
|
if (!item.isEqual(oldState, newState)) {
|
|
7933
7941
|
commands.push(await item.apply(oldState, newState));
|
|
7934
7942
|
}
|
|
@@ -7936,7 +7944,7 @@ const renderEditor = async id => {
|
|
|
7936
7944
|
return commands;
|
|
7937
7945
|
};
|
|
7938
7946
|
|
|
7939
|
-
const keep = ['ColorPicker.handleSliderPointerDown', 'ColorPicker.handleSliderPointerMove', 'ColorPicker.loadContent', 'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'FindWidget.focusFirst', 'FindWidget.focusIndex', 'FindWidget.focusLast', 'FindWidget.focusNext', 'FindWidget.focusPrevious', 'FindWidget.handleInput', 'FindWidget.loadContent', 'Font.ensure', 'Hover.getHoverInfo', 'Initialize.initialize', 'EditorCompletion.advance', 'EditorCompletion.handleEditorBlur', 'EditorCompletion.handleEditorClick', 'EditorCompletion.handleEditorDeleteLeft', 'EditorCompletion.handleEditorType', 'EditorCompletion.loadContent', 'EditorCompletion.selectCurrent', 'EditorCompletion.selectIndex'];
|
|
7947
|
+
const keep = ['ColorPicker.handleSliderPointerDown', 'ColorPicker.handleSliderPointerMove', 'ColorPicker.loadContent', 'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'FindWidget.focusFirst', 'FindWidget.focusIndex', 'FindWidget.focusLast', 'FindWidget.focusNext', 'FindWidget.focusPrevious', 'FindWidget.handleInput', 'FindWidget.loadContent', 'Font.ensure', 'Hover.getHoverInfo', 'Initialize.initialize', 'EditorCompletion.advance', 'EditorCompletion.handleEditorBlur', 'EditorCompletion.handleEditorClick', 'EditorCompletion.handleEditorDeleteLeft', 'EditorCompletion.handleEditorType', 'EditorCompletion.loadContent', 'EditorCompletion.selectCurrent', 'EditorCompletion.selectIndex', 'ColorPicker.render'];
|
|
7940
7948
|
|
|
7941
7949
|
// TODO wrap commands globally, not per editor
|
|
7942
7950
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
@@ -7958,10 +7966,89 @@ const wrapCommands = commands => {
|
|
|
7958
7966
|
}
|
|
7959
7967
|
};
|
|
7960
7968
|
|
|
7969
|
+
const HandlePointerDown = 'handlePointerDown';
|
|
7970
|
+
|
|
7971
|
+
const mergeClassNames = (...classNames) => {
|
|
7972
|
+
return classNames.filter(Boolean).join(' ');
|
|
7973
|
+
};
|
|
7974
|
+
|
|
7975
|
+
const getColorPickerVirtualDom = () => {
|
|
7976
|
+
return [{
|
|
7977
|
+
type: Div,
|
|
7978
|
+
className: mergeClassNames(Viewlet, ColorPicker),
|
|
7979
|
+
onPointerDown: HandlePointerDown,
|
|
7980
|
+
childCount: 3
|
|
7981
|
+
}, {
|
|
7982
|
+
type: Div,
|
|
7983
|
+
className: ColorPickerRectangle,
|
|
7984
|
+
childCount: 3
|
|
7985
|
+
}, {
|
|
7986
|
+
type: Div,
|
|
7987
|
+
className: ColorPickerBackgroundColor,
|
|
7988
|
+
childCount: 0
|
|
7989
|
+
}, {
|
|
7990
|
+
type: Div,
|
|
7991
|
+
className: ColorPickerLight,
|
|
7992
|
+
childCount: 0
|
|
7993
|
+
}, {
|
|
7994
|
+
type: Div,
|
|
7995
|
+
className: ColorPickerDark,
|
|
7996
|
+
childCount: 0
|
|
7997
|
+
}, {
|
|
7998
|
+
type: Div,
|
|
7999
|
+
className: ColorPickerSlider,
|
|
8000
|
+
childCount: 0
|
|
8001
|
+
}, {
|
|
8002
|
+
type: Div,
|
|
8003
|
+
className: ColorPickerSliderThumb,
|
|
8004
|
+
childCount: 0
|
|
8005
|
+
}];
|
|
8006
|
+
};
|
|
8007
|
+
|
|
8008
|
+
const SetColor = 'setColor';
|
|
8009
|
+
const SetOffsetX = 'setOffsetX';
|
|
8010
|
+
|
|
8011
|
+
const renderColor = {
|
|
8012
|
+
isEqual(oldState, newState) {
|
|
8013
|
+
return oldState.color === newState.color;
|
|
8014
|
+
},
|
|
8015
|
+
apply(oldState, newState) {
|
|
8016
|
+
return [/* method */SetColor, /* color */newState.color];
|
|
8017
|
+
}
|
|
8018
|
+
};
|
|
8019
|
+
const renderOffsetX = {
|
|
8020
|
+
isEqual(oldState, newState) {
|
|
8021
|
+
return oldState.offsetX === newState.offsetX;
|
|
8022
|
+
},
|
|
8023
|
+
apply(oldState, newState) {
|
|
8024
|
+
return [/* method */SetOffsetX, /* offsetX */newState.offsetX];
|
|
8025
|
+
}
|
|
8026
|
+
};
|
|
8027
|
+
const renderColorPickerDom = {
|
|
8028
|
+
isEqual(oldState, newState) {
|
|
8029
|
+
return oldState.min === newState.min && oldState.max === newState.max;
|
|
8030
|
+
},
|
|
8031
|
+
apply(oldState, newState) {
|
|
8032
|
+
const dom = getColorPickerVirtualDom();
|
|
8033
|
+
return ['Viewlet.setDom2', dom];
|
|
8034
|
+
}
|
|
8035
|
+
};
|
|
8036
|
+
const render = [renderColorPickerDom, renderColor, renderOffsetX];
|
|
8037
|
+
const renderColorPicker = async (oldState, newState) => {
|
|
8038
|
+
const commands = [];
|
|
8039
|
+
for (const item of render) {
|
|
8040
|
+
if (!item.isEqual(oldState, newState)) {
|
|
8041
|
+
commands.push(item.apply(oldState, newState));
|
|
8042
|
+
}
|
|
8043
|
+
}
|
|
8044
|
+
return commands;
|
|
8045
|
+
};
|
|
8046
|
+
|
|
7961
8047
|
const commandMap = {
|
|
7962
8048
|
'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
|
|
7963
8049
|
'ColorPicker.handleSliderPointerMove': handleSliderPointerMove,
|
|
7964
8050
|
'ColorPicker.loadContent': loadContent$2,
|
|
8051
|
+
'ColorPicker.render': renderColorPicker,
|
|
7965
8052
|
'Editor.addCursorAbove': addCursorAbove,
|
|
7966
8053
|
'Editor.addCursorBelow': addCursorBelow,
|
|
7967
8054
|
'Editor.applyEdit': applyEdit,
|