@lvce-editor/editor-worker 19.69.0 → 19.69.1

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.
@@ -15431,6 +15431,17 @@ const kAutoClosingBrackets = 'editor.autoClosingBrackets';
15431
15431
  const kFontWeight = 'editor.fontWeight';
15432
15432
  const kMinimapEnabled = 'editor.minimap.enabled';
15433
15433
  const kMergeConflictActions = 'editor.mergeConflictActions';
15434
+ const kMinFontSize = 10;
15435
+ const kMaxFontSize = 100;
15436
+ const kMaxLineHeight = 100;
15437
+ const lastWarnings = new Map();
15438
+ const warnIfChanged = (setting, value, bound, direction) => {
15439
+ if (Object.is(lastWarnings.get(setting), value)) {
15440
+ return;
15441
+ }
15442
+ lastWarnings.set(setting, value);
15443
+ warn(`[editor-worker] ${setting} value ${value} is too ${direction}; using ${bound}`);
15444
+ };
15434
15445
  const isAutoClosingBracketsEnabled = async () => {
15435
15446
  return Boolean(await get$3(kAutoClosingBrackets));
15436
15447
  };
@@ -15445,13 +15456,37 @@ const isAutoClosingTagsEnabled = async () => {
15445
15456
  };
15446
15457
  const getRowHeight = async () => {
15447
15458
  const [lineHeight, fontSize] = await Promise.all([get$3(kLineHeight), getFontSize()]);
15448
- if (typeof lineHeight !== 'number' || !Number.isFinite(lineHeight) || lineHeight < fontSize) {
15459
+ if (typeof lineHeight !== 'number' || !Number.isFinite(lineHeight) || lineHeight === 0) {
15460
+ lastWarnings.delete(kLineHeight);
15449
15461
  return fontSize;
15450
15462
  }
15463
+ if (lineHeight > kMaxLineHeight) {
15464
+ warnIfChanged(kLineHeight, lineHeight, kMaxLineHeight, 'large');
15465
+ return kMaxLineHeight;
15466
+ }
15467
+ if (lineHeight < fontSize) {
15468
+ warnIfChanged(kLineHeight, lineHeight, fontSize, 'small');
15469
+ return fontSize;
15470
+ }
15471
+ lastWarnings.delete(kLineHeight);
15451
15472
  return lineHeight;
15452
15473
  };
15453
15474
  const getFontSize = async () => {
15454
- return (await get$3(kFontSize)) || 15; // TODO find out if it is possible to use all numeric values for settings for efficiency, maybe settings could be an array
15475
+ const fontSize = await get$3(kFontSize);
15476
+ if (typeof fontSize !== 'number' || !Number.isFinite(fontSize)) {
15477
+ lastWarnings.delete(kFontSize);
15478
+ return 15;
15479
+ }
15480
+ if (fontSize < kMinFontSize) {
15481
+ warnIfChanged(kFontSize, fontSize, kMinFontSize, 'small');
15482
+ return kMinFontSize;
15483
+ }
15484
+ if (fontSize > kMaxFontSize) {
15485
+ warnIfChanged(kFontSize, fontSize, kMaxFontSize, 'large');
15486
+ return kMaxFontSize;
15487
+ }
15488
+ lastWarnings.delete(kFontSize);
15489
+ return fontSize;
15455
15490
  };
15456
15491
  const getFontFamily = async () => {
15457
15492
  return (await get$3(kFontFamily)) || 'Fira Code';
@@ -819,7 +819,8 @@
819
819
  "heading": "Line Height",
820
820
  "id": "editor.lineHeight",
821
821
  "type": "number",
822
- "value": "0"
822
+ "value": "0",
823
+ "maximum": 100
823
824
  },
824
825
  {
825
826
  "category": "text-editor",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.69.0",
3
+ "version": "19.69.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"