@aicayzer/inkkit 0.4.0 → 0.4.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.
@@ -48897,6 +48897,7 @@ function runOffsets(nodes, text, from, to) {
48897
48897
  const offsets = [from];
48898
48898
  const links = [];
48899
48899
  const breaks = /* @__PURE__ */ new Set();
48900
+ const tokens = /* @__PURE__ */ new Map();
48900
48901
  let at = from;
48901
48902
  let afterBreak = false;
48902
48903
  for (const node of nodes) {
@@ -48909,10 +48910,9 @@ function runOffsets(nodes, text, from, to) {
48909
48910
  }
48910
48911
  if (start !== at) return void 0;
48911
48912
  const raw = text.slice(start, end);
48912
- if (node.type === "link") {
48913
- const label = inlineText(node);
48914
- const angle = raw === `<${label}>`;
48915
- if (raw !== label && !angle) return void 0;
48913
+ const label = node.type === "link" ? inlineText(node) : void 0;
48914
+ const angle = label !== void 0 && raw === `<${label}>`;
48915
+ if (label !== void 0 && (raw === label || angle)) {
48916
48916
  links.push([decoded.length, decoded.length + label.length]);
48917
48917
  decoded += label;
48918
48918
  for (let index = 1; index <= label.length; index++) offsets.push(index === label.length ? end : start + index + Number(angle));
@@ -48925,7 +48925,12 @@ function runOffsets(nodes, text, from, to) {
48925
48925
  breaks.add(decoded.length);
48926
48926
  decoded += "\n";
48927
48927
  offsets.push(end);
48928
- } else return void 0;
48928
+ } else {
48929
+ tokens.set(decoded.length, signature(node));
48930
+ links.push([decoded.length, decoded.length + 1]);
48931
+ decoded += "";
48932
+ offsets.push(end);
48933
+ }
48929
48934
  afterBreak = node.type === "break";
48930
48935
  at = end;
48931
48936
  }
@@ -48933,7 +48938,8 @@ function runOffsets(nodes, text, from, to) {
48933
48938
  decoded,
48934
48939
  offsets,
48935
48940
  links,
48936
- breaks
48941
+ breaks,
48942
+ tokens
48937
48943
  } : void 0;
48938
48944
  }
48939
48945
  function retainRun(before, after, source, canonical, [from, to], [newFrom, newTo]) {
@@ -48943,11 +48949,31 @@ function retainRun(before, after, source, canonical, [from, to], [newFrom, newTo
48943
48949
  const a = old.decoded;
48944
48950
  const b = now.decoded;
48945
48951
  let prefix = 0;
48946
- while (prefix < a.length && prefix < b.length && a[prefix] === b[prefix] && old.breaks.has(prefix) === now.breaks.has(prefix)) prefix++;
48952
+ while (prefix < a.length && prefix < b.length && a[prefix] === b[prefix] && old.tokens.get(prefix) === now.tokens.get(prefix) && old.breaks.has(prefix) === now.breaks.has(prefix)) prefix++;
48947
48953
  let suffix = 0;
48948
- while (suffix < a.length - prefix && suffix < b.length - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix] && old.breaks.has(a.length - 1 - suffix) === now.breaks.has(b.length - 1 - suffix)) suffix++;
48954
+ while (suffix < a.length - prefix && suffix < b.length - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix] && old.tokens.get(a.length - 1 - suffix) === now.tokens.get(b.length - 1 - suffix) && old.breaks.has(a.length - 1 - suffix) === now.breaks.has(b.length - 1 - suffix)) suffix++;
48955
+ const reference = /^&(?:#[xX][\da-fA-F]+|#\d+|[A-Za-z][A-Za-z\d]+);$/;
48956
+ const encodedBoundary = (oldIndex, newIndex) => reference.test(canonical.slice(now.offsets[newIndex], now.offsets[newIndex + 1])) && !reference.test(source.slice(old.offsets[oldIndex], old.offsets[oldIndex + 1]));
48949
48957
  for (let widened = true; widened;) {
48950
48958
  widened = false;
48959
+ if (prefix > 0 && encodedBoundary(prefix - 1, prefix - 1)) {
48960
+ prefix--;
48961
+ widened = true;
48962
+ }
48963
+ if (suffix > 0 && encodedBoundary(a.length - suffix, b.length - suffix)) {
48964
+ suffix--;
48965
+ widened = true;
48966
+ }
48967
+ for (const { offsets, decoded } of [old, now]) {
48968
+ while (prefix > 0 && offsets[prefix] === offsets[prefix + 1]) {
48969
+ prefix--;
48970
+ widened = true;
48971
+ }
48972
+ while (suffix > 0 && offsets[decoded.length - suffix] === offsets[decoded.length - suffix + 1]) {
48973
+ suffix--;
48974
+ widened = true;
48975
+ }
48976
+ }
48951
48977
  for (const [links, length] of [[old.links, a.length], [now.links, b.length]]) for (const [start, end] of links) if (start <= length - suffix && end >= prefix) {
48952
48978
  if (start < prefix) {
48953
48979
  prefix = start;
@@ -56944,7 +56970,7 @@ async function createMilkdownEditor(root, options, runtime) {
56944
56970
  return true;
56945
56971
  }
56946
56972
  }));
56947
- }).use(labelsCtx).use(linkSchemesCtx).use(formatInputCtx).use(richTextGuard).use(runtime.plugins.paste).use(visibleClipboard).use(runtime.plugins.suggestions).use(runtime.plugins.keymap).use(createDialect(Boolean(options.images || options.files), Boolean(options.wikiLinks), Boolean(options.files))).use(codeControlCtx).use(codeControlsPlugin(() => runtime.visibleRect())).use(tablePlugins).use(tableBlock).use(runtime.plugins.change).use(runtime.plugins.historyInput).use(history).use(clipboard).use(cursor).use(taskListPlugin((operation) => runtime.mutate(operation))).use(undoTypedRule).use(quoteBackspace).use(calloutEnter).use(literalEnter).use(literalReread).use(listItemBackspace).use(nestedItemEnter).use(rejoinLists).use(movedListItems).use(textInputPolicy).use(runtime.copy ? codeCopyPlugin((text) => runtime.copy?.(text)) : []).use(placeholderPlugin).use(options.rendering?.codeHighlighting === false ? [] : (await import("./highlight-4lYN38Zo.js")).highlightPlugin).use(options.rendering?.diagramPreview === false || !diagramsAvailable() ? [] : mermaidPreview(runtime.diagrams, (error) => runtime.report(error))).use(selectionPlugin).use($prose(() => search())).use(runtime.plugins.policy).use(options.wikiLinks ? wikiLinkView(options.wikiLinks, {
56973
+ }).use(labelsCtx).use(linkSchemesCtx).use(formatInputCtx).use(richTextGuard).use(runtime.plugins.paste).use(visibleClipboard).use(runtime.plugins.suggestions).use(runtime.plugins.keymap).use(createDialect(Boolean(options.images || options.files), Boolean(options.wikiLinks), Boolean(options.files))).use(codeControlCtx).use(codeControlsPlugin(() => runtime.visibleRect())).use(tablePlugins).use(tableBlock).use(runtime.plugins.change).use(runtime.plugins.historyInput).use(history).use(clipboard).use(cursor).use(taskListPlugin((operation) => runtime.mutate(operation))).use(undoTypedRule).use(quoteBackspace).use(calloutEnter).use(literalEnter).use(literalReread).use(listItemBackspace).use(nestedItemEnter).use(rejoinLists).use(movedListItems).use(textInputPolicy).use(runtime.copy ? codeCopyPlugin((text) => runtime.copy?.(text)) : []).use(placeholderPlugin).use(options.rendering?.codeHighlighting === false ? [] : (await import("./highlight-CqtvWKCp.js")).highlightPlugin).use(options.rendering?.diagramPreview === false || !diagramsAvailable() ? [] : mermaidPreview(runtime.diagrams, (error) => runtime.report(error))).use(selectionPlugin).use($prose(() => search())).use(runtime.plugins.policy).use(options.wikiLinks ? wikiLinkView(options.wikiLinks, {
56948
56974
  capture: () => runtime.capture(),
56949
56975
  active: () => runtime.active(),
56950
56976
  labels: {
@@ -1,4 +1,4 @@
1
- import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-Dl4jPn_d.js";
1
+ import { a as Decoration, c as PluginKey, d as __toESM, i as $prose, o as DecorationSet, s as Plugin, u as __commonJSMin } from "./core-CisgnAp-.js";
2
2
  //#region node_modules/.pnpm/highlight.js@11.11.2/node_modules/highlight.js/es/languages/arduino.js
3
3
  /** @type LanguageFn */
4
4
  function cPlusPlus(hljs) {
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- import { r as InkKitError, t as InkKitEditor } from "./chunks/core-Dl4jPn_d.js";
1
+ import { r as InkKitError, t as InkKitEditor } from "./chunks/core-CisgnAp-.js";
2
2
  export { InkKitEditor, InkKitError };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-Dl4jPn_d.js";
1
+ import { n as registerDiagram, r as InkKitError, t as InkKitEditor } from "./chunks/core-CisgnAp-.js";
2
2
  //#region node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
3
3
  /*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */
4
4
  function _OverloadYield(e, d) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicayzer/inkkit",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "A preserving Markdown editor for offline web views and the web",
5
5
  "license": "MIT",
6
6
  "type": "module",