@ixo/editor 7.13.2 → 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.
- package/dist/{chunk-KLNIHNFR.js → chunk-OCO3YMSP.js} +41 -7
- package/dist/{chunk-KLNIHNFR.js.map → chunk-OCO3YMSP.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/mantine/index.js +1 -1
- package/package.json +2 -2
- package/style-core.css +16 -0
- package/style-mantine.css +16 -0
- package/style-scoped.css +16 -0
- package/style.css +16 -0
|
@@ -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
|
|
26803
|
-
const text =
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
31076
|
+
//# sourceMappingURL=chunk-OCO3YMSP.js.map
|