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

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.
Files changed (2) hide show
  1. package/lib/client.js +9 -11
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -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 = indentSpaces(line);
1286
+ const indent = leadingSpace(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 = indentSpaces(line);
1294
+ const indent = leadingSpace(line);
1295
1295
  const body = stripBlockMarker(line);
1296
1296
  if (kind === "bullet") return `${indent}- ${body}`;
1297
1297
  if (kind === "todo") return `${indent}- [ ] ${body}`;
@@ -1450,9 +1450,6 @@ window.__ModuleLoader__.load({
1450
1450
  }
1451
1451
  return width;
1452
1452
  }
1453
- function indentSpaces(line) {
1454
- return " ".repeat(columnsOf(leadingSpace(line)));
1455
- }
1456
1453
  var INDENT_STEP = INDENT_WIDTH2;
1457
1454
  function indentSelection(value, start, end, direction) {
1458
1455
  return rewriteLines(value, start, end, (line) => {
@@ -1460,12 +1457,13 @@ window.__ModuleLoader__.load({
1460
1457
  const prefix = leadingSpace(line);
1461
1458
  const body = line.slice(prefix.length);
1462
1459
  const columns2 = columnsOf(prefix);
1460
+ const atLevel = (level2) => prefix.includes(" ") ? " ".repeat(level2) : " ".repeat(level2 * INDENT_STEP);
1463
1461
  if (direction === 1) {
1464
1462
  const level2 = Math.floor(columns2 / INDENT_STEP);
1465
- return `${" ".repeat((level2 + 1) * INDENT_STEP)}${body}`;
1463
+ return `${atLevel(level2 + 1)}${body}`;
1466
1464
  }
1467
1465
  const level = Math.ceil(columns2 / INDENT_STEP);
1468
- return `${" ".repeat(Math.max(0, level - 1) * INDENT_STEP)}${body}`;
1466
+ return `${atLevel(Math.max(0, level - 1))}${body}`;
1469
1467
  });
1470
1468
  }
1471
1469
  function fenceLines(lines) {
@@ -1533,8 +1531,8 @@ window.__ModuleLoader__.load({
1533
1531
  const body = text.slice(leadingSpace(text).length);
1534
1532
  const quote = QUOTE_PREFIX.exec(body);
1535
1533
  if (quote !== null) {
1536
- const prefix2 = indentSpaces(text);
1537
- if (start - line.from < leadingSpace(text).length + quote[0].length) return null;
1534
+ const prefix2 = leadingSpace(text);
1535
+ if (start - line.from < prefix2.length + quote[0].length) return null;
1538
1536
  if (body.slice(quote[0].length).trim() === "") return dropMarkerLine(value, line.from, line.to);
1539
1537
  const marker2 = quote[0].endsWith(" ") || quote[0].endsWith(" ") ? quote[0] : `${quote[0]} `;
1540
1538
  const insert = `
@@ -1552,7 +1550,7 @@ window.__ModuleLoader__.load({
1552
1550
  if (itemBody.trim() === "") {
1553
1551
  return dropMarkerLine(value, line.from, line.to);
1554
1552
  }
1555
- const indent = indentSpaces(text);
1553
+ const indent = leadingSpace(text);
1556
1554
  const nextMarker = todo !== null ? `${indent}${todo[2] ?? "-"} [ ] ` : bullet !== null ? `${indent}${bullet[2] ?? "-"} ` : `${indent}${Number(ordered?.[2] ?? "1") + 1}${ordered?.[3] ?? "."} `;
1557
1555
  const insert = `
1558
1556
  ${nextMarker}`;
@@ -1577,7 +1575,7 @@ window.__ModuleLoader__.load({
1577
1575
  const prefix = leadingSpace(text);
1578
1576
  if (prefix !== "" && text.trim() !== "" && start - line.from >= prefix.length) {
1579
1577
  const insert = `
1580
- ${indentSpaces(text)}`;
1578
+ ${prefix}`;
1581
1579
  const caret = start + insert.length;
1582
1580
  return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
1583
1581
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillre/dsh-plugin-sticky-wall",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "便签墙:DSH 侧栏的自由画布便签板,可拖动摆放、一键整理,正文按 Markdown 渲染",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",