@lvce-editor/editor-worker 19.64.0 → 19.66.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.
|
@@ -5,7 +5,7 @@ const noColorRange = {
|
|
|
5
5
|
startOffset: -1,
|
|
6
6
|
value: ''
|
|
7
7
|
};
|
|
8
|
-
const colorPattern = /#[\da-f]{3,8}\b|\b(?:hsla?|rgba?)\([^)]*\)/gi;
|
|
8
|
+
const colorPattern = /#[\da-f]{3,8}\b|(?<![\w$])0x[\da-f]{6}(?![\w$])|\b(?:hsla?|rgba?)\([^)]*\)/gi;
|
|
9
9
|
const getColorPickerRange = async editor => {
|
|
10
10
|
const {
|
|
11
11
|
lines,
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1762,6 +1762,25 @@ const codeGeneratorAccept = state => {
|
|
|
1762
1762
|
return state;
|
|
1763
1763
|
};
|
|
1764
1764
|
|
|
1765
|
+
const javascriptHexColorPattern = /^0x([\da-f]{6})$/i;
|
|
1766
|
+
const toColorPickerValue = value => {
|
|
1767
|
+
const match = javascriptHexColorPattern.exec(value);
|
|
1768
|
+
if (!match) {
|
|
1769
|
+
return value;
|
|
1770
|
+
}
|
|
1771
|
+
return `#${match[1]}`;
|
|
1772
|
+
};
|
|
1773
|
+
const toEditorValue = (value, originalValue) => {
|
|
1774
|
+
if (!javascriptHexColorPattern.test(originalValue)) {
|
|
1775
|
+
return value;
|
|
1776
|
+
}
|
|
1777
|
+
const match = /^#([\da-f]{6})$/i.exec(value);
|
|
1778
|
+
if (!match) {
|
|
1779
|
+
return value;
|
|
1780
|
+
}
|
|
1781
|
+
return `0x${match[1]}`;
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1765
1784
|
const editorStates = create$9();
|
|
1766
1785
|
const {
|
|
1767
1786
|
dispose: dispose$5,
|
|
@@ -4513,21 +4532,23 @@ const updateColorPickerValue$1 = async (editor, value) => {
|
|
|
4513
4532
|
const {
|
|
4514
4533
|
endOffset,
|
|
4515
4534
|
startOffset,
|
|
4516
|
-
undoStackIndex
|
|
4535
|
+
undoStackIndex,
|
|
4536
|
+
value: originalValue
|
|
4517
4537
|
} = widget.newState;
|
|
4518
4538
|
if (startOffset < 0 || endOffset < startOffset) {
|
|
4519
4539
|
return editor;
|
|
4520
4540
|
}
|
|
4541
|
+
const editorValue = toEditorValue(value, originalValue);
|
|
4521
4542
|
const edits = getDocumentEdits(editor, [{
|
|
4522
4543
|
endOffset,
|
|
4523
|
-
inserted:
|
|
4544
|
+
inserted: editorValue,
|
|
4524
4545
|
startOffset
|
|
4525
4546
|
}]).map(edit => ({
|
|
4526
4547
|
...edit,
|
|
4527
4548
|
origin: ColorPicker$1
|
|
4528
4549
|
}));
|
|
4529
4550
|
const updatedEditor = await scheduleDocumentAndCursorsSelections(editor, edits);
|
|
4530
|
-
const newEndOffset = startOffset +
|
|
4551
|
+
const newEndOffset = startOffset + editorValue.length;
|
|
4531
4552
|
const widgets = updatedEditor.widgets.map(candidate => {
|
|
4532
4553
|
if (candidate.id !== ColorPicker$2) {
|
|
4533
4554
|
return candidate;
|
|
@@ -5199,7 +5220,7 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
5199
5220
|
y
|
|
5200
5221
|
} = state;
|
|
5201
5222
|
await invoke$7('ColorPicker.create', uid, x, y, width, height, parentUid);
|
|
5202
|
-
await invoke$7('ColorPicker.loadContent', uid, value);
|
|
5223
|
+
await invoke$7('ColorPicker.loadContent', uid, toColorPickerValue(value));
|
|
5203
5224
|
const diff = await invoke$7('ColorPicker.diff2', uid);
|
|
5204
5225
|
const commands = await invoke$7('ColorPicker.render2', uid, diff);
|
|
5205
5226
|
return {
|
|
@@ -6654,8 +6675,8 @@ const format = async editor => {
|
|
|
6654
6675
|
}
|
|
6655
6676
|
};
|
|
6656
6677
|
|
|
6657
|
-
const getNewEditor = async editor => {
|
|
6658
|
-
if (editor.formatOnSave) {
|
|
6678
|
+
const getNewEditor = async (editor, skipFormatting = false) => {
|
|
6679
|
+
if (editor.formatOnSave && !skipFormatting) {
|
|
6659
6680
|
return format(editor);
|
|
6660
6681
|
}
|
|
6661
6682
|
return editor;
|
|
@@ -6721,7 +6742,7 @@ const showSaveErrorDialog = async error => {
|
|
|
6721
6742
|
});
|
|
6722
6743
|
};
|
|
6723
6744
|
|
|
6724
|
-
const save = async editor => {
|
|
6745
|
+
const save = async (editor, skipFormatting = false) => {
|
|
6725
6746
|
try {
|
|
6726
6747
|
const {
|
|
6727
6748
|
applicationId,
|
|
@@ -6731,7 +6752,7 @@ const save = async editor => {
|
|
|
6731
6752
|
if (!isUntitledFile(uri) && (await isReadonlyFile(uri, applicationId))) {
|
|
6732
6753
|
return editor;
|
|
6733
6754
|
}
|
|
6734
|
-
const newEditor = await getNewEditor(editor);
|
|
6755
|
+
const newEditor = await getNewEditor(editor, skipFormatting);
|
|
6735
6756
|
const content = applyLineEndings(getText$1(newEditor), newEditor.endOfLine);
|
|
6736
6757
|
if (isUntitledFile(uri)) {
|
|
6737
6758
|
const pickedFilePath = await saveUntitledFile(uri, content, platform, applicationId);
|
|
@@ -7408,7 +7429,7 @@ const openColorPicker = async editor => {
|
|
|
7408
7429
|
const bounds = getColorPickerBounds(editor);
|
|
7409
7430
|
const {
|
|
7410
7431
|
getColorPickerRange
|
|
7411
|
-
} = await import('./GetColorPickerRange-
|
|
7432
|
+
} = await import('./GetColorPickerRange-CsGZK202.js');
|
|
7412
7433
|
const range = await getColorPickerRange(editor);
|
|
7413
7434
|
const createWidget = () => create$6(bounds, range, editor.undoStack.length);
|
|
7414
7435
|
return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$5, fullFocus);
|
|
@@ -14871,6 +14892,7 @@ const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
|
14871
14892
|
await initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental);
|
|
14872
14893
|
};
|
|
14873
14894
|
|
|
14895
|
+
const largeFileContentLength = 10 * 1024 * 1024;
|
|
14874
14896
|
const getWorkspaceUri = async applicationId => {
|
|
14875
14897
|
try {
|
|
14876
14898
|
return await invoke$9(applicationId, 'Workspace.getPath');
|
|
@@ -15014,7 +15036,7 @@ const loadContent = async (state, savedState, largeFile = false) => {
|
|
|
15014
15036
|
};
|
|
15015
15037
|
}
|
|
15016
15038
|
const savedLargeFile = !!savedState && typeof savedState === 'object' && savedState.largeFile === true;
|
|
15017
|
-
largeFile ||= state.largeFile === true || existingEditor?.largeFile === true || savedLargeFile || content.length >
|
|
15039
|
+
largeFile ||= state.largeFile === true || existingEditor?.largeFile === true || savedLargeFile || content.length > largeFileContentLength;
|
|
15018
15040
|
const effectiveEditor = {
|
|
15019
15041
|
...newEditor0,
|
|
15020
15042
|
largeFile,
|