@lvce-editor/editor-worker 19.64.0 → 19.65.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,
@@ -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: value,
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 + value.length;
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 {
@@ -7408,7 +7429,7 @@ const openColorPicker = async editor => {
7408
7429
  const bounds = getColorPickerBounds(editor);
7409
7430
  const {
7410
7431
  getColorPickerRange
7411
- } = await import('./GetColorPickerRange-B84IlfRJ.js');
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 > 50 * 1024 * 1024;
15039
+ largeFile ||= state.largeFile === true || existingEditor?.largeFile === true || savedLargeFile || content.length > largeFileContentLength;
15018
15040
  const effectiveEditor = {
15019
15041
  ...newEditor0,
15020
15042
  largeFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.64.0",
3
+ "version": "19.65.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"