@ixo/editor 7.13.1 → 7.14.0

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.
@@ -2947,7 +2947,7 @@ import {
2947
2947
  } from "@tabler/icons-react";
2948
2948
  var groupOrder = ["emoji", "headings", "formats", "content", "flows", "data", "links", "pod", "finance"];
2949
2949
  var EVERYWHERE = ["page", "canvas", "template", "flow", "topic-canvas"];
2950
- var AUTHORING = ["template", "canvas"];
2950
+ var AUTHORING = ["canvas"];
2951
2951
  var TEMPLATE_ONLY = ["template"];
2952
2952
  var DEVELOPER_ONLY = ["developer"];
2953
2953
  var DESCRIPTIONS = {
@@ -3121,7 +3121,7 @@ var insertEntries = [
3121
3121
  ["blueprint", "blueprints", "protocol", "protocol-selector", "select-protocol", "domain-type"],
3122
3122
  TEMPLATE_ONLY
3123
3123
  ),
3124
- block("enumChecklist", "enumChecklist", { listType: "", listConfig: "{}" }, "flows", "Enum Checklist", IconChecklist2, ["enum", "enum-checklist", "enum-list"], TEMPLATE_ONLY),
3124
+ block("enumChecklist", "enumChecklist", { listType: "", listConfig: "{}" }, "flows", "Enum Checklist", IconChecklist2, ["enum", "enum-checklist", "enum-list"], DEVELOPER_ONLY),
3125
3125
  block(
3126
3126
  "visualization",
3127
3127
  "visualization",
@@ -3161,7 +3161,7 @@ var insertEntries = [
3161
3161
  "Proposal",
3162
3162
  IconGavel,
3163
3163
  ["proposal", "create-proposal", "dao-proposal", "governance", "vote"],
3164
- TEMPLATE_ONLY
3164
+ DEVELOPER_ONLY
3165
3165
  ),
3166
3166
  block(
3167
3167
  "checkbox",
@@ -26746,6 +26746,31 @@ var looksLikeMarkdownList = (text) => {
26746
26746
  const listLines = lines.filter((line2) => LIST_LINE.test(line2)).length;
26747
26747
  return listLines > 0 && listLines * 2 >= lines.length;
26748
26748
  };
26749
+ var CODE_LINE = [
26750
+ /^\s*(?:import|export|const|let|var|function|class|interface|type|enum|return|if|else|for|while|switch|case|try|catch|async|await|def|fn|pub|use|package|public|private|protected|static)\b/,
26751
+ /^\s*(?:\/\/|\/\*|\*\/|#include|#!)/,
26752
+ /[;{}[\]]\s*$/,
26753
+ /=>|===|!==/,
26754
+ /^\s*"[^"]+"\s*:/
26755
+ ];
26756
+ var looksLikeCode = (text) => {
26757
+ if (text.includes("```")) return false;
26758
+ const lines = text.split(/\r?\n/).filter((line2) => line2.trim());
26759
+ const codeLines = lines.filter((line2) => CODE_LINE.some((pattern) => pattern.test(line2))).length;
26760
+ return lines.length >= 2 && codeLines >= 2 && codeLines * 2 >= lines.length;
26761
+ };
26762
+ var TAG_START = /<(?=[A-Za-z/!?])(?![A-Za-z][A-Za-z0-9+.-]*:[^\s>]*>)(?![^\s>@]+@[^\s>]+>)/g;
26763
+ var escapeAngleTags = (text) => {
26764
+ let fenced = false;
26765
+ return text.split("\n").map((line2) => {
26766
+ if (/^\s*(?:```|~~~)/.test(line2)) {
26767
+ fenced = !fenced;
26768
+ return line2;
26769
+ }
26770
+ if (fenced) return line2;
26771
+ return line2.split(/(`+[^`]*`+)/).map((part, index) => index % 2 ? part : part.replace(TAG_START, "\\<")).join("");
26772
+ }).join("\n");
26773
+ };
26749
26774
  var tightenMarkdownList = (text) => text.replace(/\n[ \t]*\n(?=[ \t]*(?:[-*+]|\d+\.)[ \t])/g, "\n");
26750
26775
  var separateListsFromText = (text) => {
26751
26776
  const lines = text.replace(/\r\n?/g, "\n").split("\n");
@@ -26799,19 +26824,21 @@ function pasteLineFromBlockNote(editor, externalHtml, defaultPaste) {
26799
26824
  else defaultPaste();
26800
26825
  return true;
26801
26826
  }
26802
- function pasteFromVSCode(editor, event) {
26803
- const text = (event.clipboardData?.getData("text/plain") ?? "").replace(/\r\n?/g, "\n");
26827
+ function pasteCodeBlock(editor, raw, language) {
26828
+ const text = raw.replace(/\r\n?/g, "\n").replace(/\n+$/, "");
26804
26829
  if (!text) return true;
26805
26830
  if (!text.includes("\n") || !editor?.schema?.blockSchema?.codeBlock) return insertPlainTextFallback(editor, text);
26831
+ insertBlocksAtCursor(editor, [{ type: "codeBlock", props: { language }, content: text }]);
26832
+ return true;
26833
+ }
26834
+ function pasteFromVSCode(editor, event) {
26806
26835
  let mode;
26807
26836
  try {
26808
26837
  mode = JSON.parse(event.clipboardData?.getData("vscode-editor-data") ?? "{}")?.mode;
26809
26838
  } catch {
26810
26839
  mode = void 0;
26811
26840
  }
26812
- const language = !mode || mode === "plaintext" ? "text" : mode;
26813
- insertBlocksAtCursor(editor, [{ type: "codeBlock", props: { language }, content: text }]);
26814
- return true;
26841
+ return pasteCodeBlock(editor, event.clipboardData?.getData("text/plain") ?? "", !mode || mode === "plaintext" ? "text" : mode);
26815
26842
  }
26816
26843
  var ixoPasteHandler = ({
26817
26844
  event,
@@ -26841,7 +26868,14 @@ var ixoPasteHandler = ({
26841
26868
  if (types.includes("blocknote/html") || types.includes("text/markdown")) return defaultPasteHandler();
26842
26869
  const html = event.clipboardData?.getData("text/html") ?? "";
26843
26870
  if (html && /<li[^>]*>\s*<p[\s>]/i.test(html)) return pasteParsed(editor, () => editor.tryParseHTMLToBlocks(tightenHtmlList(html)), plain);
26844
- if (!html && looksLikeMarkdownList(plain)) return pasteParsed(editor, () => editor.tryParseMarkdownToBlocks(separateListsFromText(tightenMarkdownList(plain))), plain);
26871
+ const plainOnly = !html && !types.includes("Files");
26872
+ if (plainOnly && looksLikeCode(plain)) return pasteCodeBlock(editor, plain, "text");
26873
+ if (plainOnly && looksLikeMarkdownList(plain))
26874
+ return pasteParsed(editor, () => editor.tryParseMarkdownToBlocks(escapeAngleTags(separateListsFromText(tightenMarkdownList(plain)))), plain);
26875
+ if (plainOnly && plain && typeof editor.pasteMarkdown === "function") {
26876
+ editor.pasteMarkdown(escapeAngleTags(plain));
26877
+ return true;
26878
+ }
26845
26879
  return defaultPasteHandler({
26846
26880
  prioritizeMarkdownOverHTML: !html.includes(IXO_BLOCK_TYPE_ATTRIBUTE),
26847
26881
  plainTextAsMarkdown: true
@@ -31039,4 +31073,4 @@ export {
31039
31073
  ixoGraphQLClient,
31040
31074
  getEntity
31041
31075
  };
31042
- //# sourceMappingURL=chunk-QFOAEPJT.js.map
31076
+ //# sourceMappingURL=chunk-OCO3YMSP.js.map