@bendyline/squisq-editor-react 2.12.7 → 2.12.9

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MARKDOWN_ESCAPE_ATTR
3
- } from "./chunk-MHG4KPMA.js";
3
+ } from "./chunk-G4INWIOX.js";
4
4
 
5
5
  // src/MarkdownEscape.ts
6
6
  import { Mark, mergeAttributes } from "@tiptap/core";
@@ -1,6 +1,7 @@
1
1
  // src/tiptapBridge.ts
2
2
  import { resolveIcon } from "@bendyline/squisq/icons";
3
3
  import {
4
+ parseWikiLink,
4
5
  matchTrailingTemplateAnnotation,
5
6
  matchTrailingPandocAttr,
6
7
  tokenizeAttrTokens,
@@ -962,7 +963,21 @@ function parseTableCells(line) {
962
963
  let inner = line.trim();
963
964
  if (inner.startsWith("|")) inner = inner.slice(1);
964
965
  if (inner.endsWith("|")) inner = inner.slice(0, -1);
965
- return inner.split("|").map((cell) => cell.trim());
966
+ const cells = [];
967
+ let cell = "";
968
+ let slashes = 0;
969
+ for (const char of inner) {
970
+ if (char === "|") {
971
+ if (slashes % 2) cell = cell.slice(0, -1) + "|";
972
+ else {
973
+ cells.push(cell.trim());
974
+ cell = "";
975
+ }
976
+ } else cell += char;
977
+ slashes = char === "\\" ? slashes + 1 : 0;
978
+ }
979
+ cells.push(cell.trim());
980
+ return cells;
966
981
  }
967
982
  function parseAlignments(separatorLine) {
968
983
  return parseTableCells(separatorLine).map((cell) => {
@@ -1049,8 +1064,16 @@ function inlineToHtml(text) {
1049
1064
  return token;
1050
1065
  };
1051
1066
  let staged = text.replace(
1052
- RE_INLINE_CODE,
1053
- (_m, code) => stash(`<code>${escapeHtml(code)}</code>`)
1067
+ /`(.+?)`|\[\[([^\u005b\]\n]+)\]\]/g,
1068
+ (full, code, value, offset) => {
1069
+ if (code !== void 0) return stash(`<code>${escapeHtml(code)}</code>`);
1070
+ const wiki = parseWikiLink((value ?? "").replace(/\\\|/g, "|"));
1071
+ if (isEscapedMarkdownCharacter(text, offset) || !wiki) return full;
1072
+ const labelAttr = wiki.label !== void 0 ? ` data-wiki-label="${escapeHtml(wiki.label)}"` : "";
1073
+ return stash(
1074
+ `<span data-wiki-link="${escapeHtml(wiki.target)}"${labelAttr}>${escapeHtml(wiki.label ?? wiki.target)}</span>`
1075
+ );
1076
+ }
1054
1077
  );
1055
1078
  staged = staged.replace(RE_VERT_ALIGN_TAG, (_m, tag, inner) => {
1056
1079
  const name = tag.toLowerCase();
@@ -1277,6 +1300,19 @@ var RawHtmlVault = class {
1277
1300
  function htmlToInline(html) {
1278
1301
  let result = html;
1279
1302
  const vault = new RawHtmlVault();
1303
+ result = result.replace(
1304
+ /<span\b((?:[^>"']|"[^"]*"|'[^']*')*)>[\s\S]*?<\/span>/gi,
1305
+ (full, attrs) => {
1306
+ const values = new Map(
1307
+ [...attrs.matchAll(/([-\w]+)="([^"]*)"/g)].map((match) => [match[1], match[2]])
1308
+ );
1309
+ const target = values.get("data-wiki-link");
1310
+ if (target === void 0) return full;
1311
+ const label = values.get("data-wiki-label");
1312
+ const value = target + (label !== void 0 ? `|${label}` : "");
1313
+ return parseWikiLink(unescapeHtml(value)) ? vault.protect(`[[${value}]]`) : full;
1314
+ }
1315
+ );
1280
1316
  result = result.replace(
1281
1317
  RE_ESCAPE_SPAN,
1282
1318
  (_span, inner) => inner.replace(
@@ -1329,7 +1365,7 @@ function htmlToTableCell(html) {
1329
1365
  return `<div data-squisq-table-cell="">${safe.replace(/\|/g, "&#124;").replace(/\r/g, "&#13;").replace(/\n/g, "&#10;")}</div>`;
1330
1366
  }
1331
1367
  const withParagraphBreaks = html.replace(/<\/p>\s*<p(?:\s[^>]*)?>/gi, "<br>").replace(/^\s*<p(?:\s[^>]*)?>/i, "").replace(/<\/p>\s*$/i, "");
1332
- return htmlToInline(withParagraphBreaks).replace(/ {2}\n/g, "<br>");
1368
+ return htmlToInline(withParagraphBreaks).replace(/ {2}\n/g, "<br>").replace(/\\*\|/g, (match) => (match.length - 1) % 2 ? match : `${match.slice(0, -1)}\\|`);
1333
1369
  }
1334
1370
  function preserveLeadingSpaces(html) {
1335
1371
  return html.replace(/^ +/, (spaces) => "&nbsp;".repeat(spaces.length));
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  MarkdownEscape
3
- } from "./chunk-LRUBYTKW.js";
3
+ } from "./chunk-6KS5IDN3.js";
4
4
  import {
5
5
  markdownToTiptap,
6
6
  tiptapToMarkdown
7
- } from "./chunk-MHG4KPMA.js";
7
+ } from "./chunk-G4INWIOX.js";
8
8
 
9
9
  // src/jsonEditor/JsonEditorContext.tsx
10
10
  import { createContext, useContext, useEffect, useMemo } from "react";