@skillre/dsh-plugin-sticky-wall 0.9.6 → 0.9.7

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/lib/client.js CHANGED
@@ -411,7 +411,7 @@ window.__ModuleLoader__.load({
411
411
  while (index < raw.length) {
412
412
  const char = raw[index];
413
413
  if (char === " ") width += 1;
414
- else if (char === " ") width += INDENT_WIDTH;
414
+ else if (char === " ") width += INDENT_WIDTH - width % INDENT_WIDTH;
415
415
  else break;
416
416
  index += 1;
417
417
  }
@@ -426,7 +426,7 @@ window.__ModuleLoader__.load({
426
426
  consumed += 1;
427
427
  index += 1;
428
428
  } else if (char === " ") {
429
- consumed += INDENT_WIDTH;
429
+ consumed += INDENT_WIDTH - consumed % INDENT_WIDTH;
430
430
  index += 1;
431
431
  } else break;
432
432
  }
@@ -1283,7 +1283,7 @@ window.__ModuleLoader__.load({
1283
1283
  }
1284
1284
  function applyHeading(level) {
1285
1285
  return (ctx) => rewriteLines(ctx.value, ctx.start, ctx.end, (line) => {
1286
- const indent = leadingSpace(line);
1286
+ const indent = indentSpaces(line);
1287
1287
  return `${indent}${"#".repeat(level)} ${stripBlockMarker(line)}`;
1288
1288
  });
1289
1289
  }
@@ -1291,7 +1291,7 @@ window.__ModuleLoader__.load({
1291
1291
  return (ctx) => {
1292
1292
  let nextNumber = null;
1293
1293
  return rewriteLines(ctx.value, ctx.start, ctx.end, (line) => {
1294
- const indent = leadingSpace(line);
1294
+ const indent = indentSpaces(line);
1295
1295
  const body = stripBlockMarker(line);
1296
1296
  if (kind === "bullet") return `${indent}- ${body}`;
1297
1297
  if (kind === "todo") return `${indent}- [ ] ${body}`;
@@ -1445,9 +1445,14 @@ window.__ModuleLoader__.load({
1445
1445
  ];
1446
1446
  function columnsOf(prefix) {
1447
1447
  let width = 0;
1448
- for (const char of prefix) width += char === " " ? INDENT_WIDTH2 : 1;
1448
+ for (const char of prefix) {
1449
+ width += char === " " ? INDENT_WIDTH2 - width % INDENT_WIDTH2 : 1;
1450
+ }
1449
1451
  return width;
1450
1452
  }
1453
+ function indentSpaces(line) {
1454
+ return " ".repeat(columnsOf(leadingSpace(line)));
1455
+ }
1451
1456
  var INDENT_STEP = INDENT_WIDTH2;
1452
1457
  function indentSelection(value, start, end, direction) {
1453
1458
  return rewriteLines(value, start, end, (line) => {
@@ -1528,8 +1533,8 @@ window.__ModuleLoader__.load({
1528
1533
  const body = text.slice(leadingSpace(text).length);
1529
1534
  const quote = QUOTE_PREFIX.exec(body);
1530
1535
  if (quote !== null) {
1531
- const prefix2 = leadingSpace(text);
1532
- if (start - line.from < prefix2.length + quote[0].length) return null;
1536
+ const prefix2 = indentSpaces(text);
1537
+ if (start - line.from < leadingSpace(text).length + quote[0].length) return null;
1533
1538
  if (body.slice(quote[0].length).trim() === "") return dropMarkerLine(value, line.from, line.to);
1534
1539
  const marker2 = quote[0].endsWith(" ") || quote[0].endsWith(" ") ? quote[0] : `${quote[0]} `;
1535
1540
  const insert = `
@@ -1547,7 +1552,8 @@ window.__ModuleLoader__.load({
1547
1552
  if (itemBody.trim() === "") {
1548
1553
  return dropMarkerLine(value, line.from, line.to);
1549
1554
  }
1550
- const nextMarker = todo !== null ? `${todo[1] ?? ""}${todo[2] ?? "-"} [ ] ` : bullet !== null ? `${bullet[1] ?? ""}${bullet[2] ?? "-"} ` : `${ordered?.[1] ?? ""}${Number(ordered?.[2] ?? "1") + 1}${ordered?.[3] ?? "."} `;
1555
+ const indent = indentSpaces(text);
1556
+ const nextMarker = todo !== null ? `${indent}${todo[2] ?? "-"} [ ] ` : bullet !== null ? `${indent}${bullet[2] ?? "-"} ` : `${indent}${Number(ordered?.[2] ?? "1") + 1}${ordered?.[3] ?? "."} `;
1551
1557
  const insert = `
1552
1558
  ${nextMarker}`;
1553
1559
  const caret = start + insert.length;
@@ -1571,7 +1577,7 @@ window.__ModuleLoader__.load({
1571
1577
  const prefix = leadingSpace(text);
1572
1578
  if (prefix !== "" && text.trim() !== "" && start - line.from >= prefix.length) {
1573
1579
  const insert = `
1574
- ${prefix}`;
1580
+ ${indentSpaces(text)}`;
1575
1581
  const caret = start + insert.length;
1576
1582
  return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
1577
1583
  }
@@ -1880,7 +1886,7 @@ window.__ModuleLoader__.load({
1880
1886
  .skw-ed-btn[data-style="italic"] { font-style: italic; }
1881
1887
  .skw-ed-btn[data-style="strike"] { text-decoration: line-through; }
1882
1888
  .skw-ed-btn[disabled] { opacity: .45; cursor: default; }
1883
- .skw-ed-input { width: 100%; min-height: ${MIN_HEIGHT_PX}px; padding: 8px 10px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; resize: none; overflow-y: auto; overflow-x: hidden; }
1889
+ .skw-ed-input { width: 100%; min-height: ${MIN_HEIGHT_PX}px; padding: 8px 10px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; resize: none; overflow-y: auto; overflow-x: hidden; tab-size: ${INDENT_WIDTH2}; }
1884
1890
  .skw-ed-input::placeholder { color: var(--dsw-alias-label-tertiary); }
1885
1891
  .skw-ed-input:focus-visible { outline: none; border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); }
1886
1892
  .skw-ed-input:disabled { opacity: .7; }
@@ -2574,7 +2580,7 @@ window.__ModuleLoader__.load({
2574
2580
  border: 1px solid color-mix(in srgb, var(--skw-md-ink, currentColor) 14%, transparent);
2575
2581
  font-size: .92em; line-height: 1.45; max-height: 180px;
2576
2582
  }
2577
- .skw-md .skw-md-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
2583
+ .skw-md .skw-md-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; tab-size: 2; }
2578
2584
  .skw-md .skw-md-code {
2579
2585
  padding: .08em .34em; border-radius: 4px; font-size: .94em;
2580
2586
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
@@ -61,7 +61,15 @@ const QUOTE = /^>[ \t]?(.*)$/;
61
61
  const TASK = /^\[([ xX])\][ \t]+([\s\S]*)$/;
62
62
  /** A table divider cell: `---`, `:---`, `---:`, `:---:`. */
63
63
  const TABLE_DIVIDER = /^\|?[ \t]*:?-{2,}:?[ \t]*(?:\|[ \t]*:?-{2,}:?[ \t]*)*\|?[ \t]*$/;
64
- /** Measure leading whitespace in columns and split the line. */
64
+ /**
65
+ * Measure leading whitespace in columns and split the line.
66
+ *
67
+ * A tab advances to the next multiple of {@link INDENT_WIDTH}, which is the CSS
68
+ * `tab-size` the editor paints with (see `EDITOR_CSS` in
69
+ * `src/client/editor.tsx`). The nesting LEVEL is unchanged either way — a tab is
70
+ * still worth "about one level" — but this keeps `indent` an honest column count
71
+ * instead of drifting one column on a mixed `" \t"` prefix.
72
+ */
65
73
  function toLine(raw) {
66
74
  let width = 0;
67
75
  let index = 0;
@@ -70,7 +78,7 @@ function toLine(raw) {
70
78
  if (char === ' ')
71
79
  width += 1;
72
80
  else if (char === '\t')
73
- width += INDENT_WIDTH;
81
+ width += INDENT_WIDTH - (width % INDENT_WIDTH);
74
82
  else
75
83
  break;
76
84
  index += 1;
@@ -88,7 +96,7 @@ function stripColumns(raw, width) {
88
96
  index += 1;
89
97
  }
90
98
  else if (char === '\t') {
91
- consumed += INDENT_WIDTH;
99
+ consumed += INDENT_WIDTH - (consumed % INDENT_WIDTH);
92
100
  index += 1;
93
101
  }
94
102
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillre/dsh-plugin-sticky-wall",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "便签墙:DSH 侧栏的自由画布便签板,可拖动摆放、一键整理,正文按 Markdown 渲染",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",