@threadlabs/looma 0.16.3 → 0.16.4
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/editor/chunks/extensions.js +13 -1
- package/package.json +1 -1
- package/vue/components.css +1 -1
- package/vue/editor/index.js +14 -3
|
@@ -8648,8 +8648,20 @@ function parseHtmlSlice(schema, value) {
|
|
|
8648
8648
|
if (!container.textContent?.trim() && !container.querySelector("img, hr")) return Slice.empty;
|
|
8649
8649
|
return DOMParser.fromSchema(schema).parseSlice(container, { preserveWhitespace: false });
|
|
8650
8650
|
}
|
|
8651
|
+
function markdownFrontmatter(value) {
|
|
8652
|
+
const match = /^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/.exec(value.slice(0, 8192));
|
|
8653
|
+
if (!match || !/^[A-Za-z][\w-]*:[ \t]*\S/m.test(match[1])) return null;
|
|
8654
|
+
return {
|
|
8655
|
+
source: match[0].trimEnd(),
|
|
8656
|
+
body: value.slice(match[0].length)
|
|
8657
|
+
};
|
|
8658
|
+
}
|
|
8659
|
+
function escapeHtmlText(value) {
|
|
8660
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
8661
|
+
}
|
|
8651
8662
|
function documentSlice(schema, plainText) {
|
|
8652
|
-
|
|
8663
|
+
const frontmatter = markdownFrontmatter(plainText);
|
|
8664
|
+
if (frontmatter || looksLikeMarkdown(plainText)) return parseHtmlSlice(schema, frontmatter ? `<pre><code class="language-yaml">${escapeHtmlText(frontmatter.source)}</code></pre>${markdown.render(frontmatter.body)}` : markdown.render(plainText));
|
|
8653
8665
|
if (looksLikeDocumentHtml(plainText)) return parseHtmlSlice(schema, plainText);
|
|
8654
8666
|
return null;
|
|
8655
8667
|
}
|
package/package.json
CHANGED
package/vue/components.css
CHANGED
|
@@ -8929,7 +8929,7 @@ html[data-ui-input-modality="touch"]
|
|
|
8929
8929
|
.ProseMirror table {
|
|
8930
8930
|
border-collapse: collapse;
|
|
8931
8931
|
margin: 0;
|
|
8932
|
-
width:
|
|
8932
|
+
width: 100% !important;
|
|
8933
8933
|
min-width: 100%;
|
|
8934
8934
|
max-width: none !important;
|
|
8935
8935
|
table-layout: fixed;
|
package/vue/editor/index.js
CHANGED
|
@@ -495,6 +495,7 @@ var LoomaEditor = defineComponent({
|
|
|
495
495
|
});
|
|
496
496
|
const imageDelivery = createLoomaImageDeliveryController({ resolveAttributes: () => props.resolveImageAttributes });
|
|
497
497
|
let lastFocusedSelection = null;
|
|
498
|
+
let linkPressedSelection = null;
|
|
498
499
|
const rememberSelection = (instance) => {
|
|
499
500
|
if (!instance.isFocused) return;
|
|
500
501
|
const selection = instance.view.state.selection;
|
|
@@ -541,8 +542,10 @@ var LoomaEditor = defineComponent({
|
|
|
541
542
|
if (!instance || !props.editable) return;
|
|
542
543
|
const current = instance.state.selection;
|
|
543
544
|
const preserved = lastFocusedSelection?.text && lastFocusedSelection.from !== lastFocusedSelection.to ? lastFocusedSelection : null;
|
|
544
|
-
const
|
|
545
|
-
|
|
545
|
+
const selection = linkPressedSelection ?? (current.empty ? preserved : null);
|
|
546
|
+
linkPressedSelection = null;
|
|
547
|
+
const from = selection?.from ?? current.from;
|
|
548
|
+
const to = selection?.to ?? current.to;
|
|
546
549
|
const empty = from === to;
|
|
547
550
|
const existing = instance.isActive("link");
|
|
548
551
|
linkSelection = {
|
|
@@ -1084,6 +1087,13 @@ var LoomaEditor = defineComponent({
|
|
|
1084
1087
|
"data-active": instance.isActive("link") ? "true" : "false",
|
|
1085
1088
|
onPointerenter: () => showTool(linkAnchorId, "Link", false),
|
|
1086
1089
|
onPointerleave: hideTool,
|
|
1090
|
+
onPointerdown: () => {
|
|
1091
|
+
const selection = instance.state.selection;
|
|
1092
|
+
linkPressedSelection = selection.empty ? null : {
|
|
1093
|
+
from: selection.from,
|
|
1094
|
+
to: selection.to
|
|
1095
|
+
};
|
|
1096
|
+
},
|
|
1087
1097
|
onFocusin: () => showTool(linkAnchorId, "Link", true),
|
|
1088
1098
|
onFocusout: hideTool
|
|
1089
1099
|
}, () => loomaIcon("link")),
|
|
@@ -1282,7 +1292,7 @@ var LoomaEditor = defineComponent({
|
|
|
1282
1292
|
class: "looma-editor__chip-popover",
|
|
1283
1293
|
open: chipOpen.value,
|
|
1284
1294
|
for: chipAnchorId,
|
|
1285
|
-
placement:
|
|
1295
|
+
placement: "bottom-start",
|
|
1286
1296
|
onClose: () => {
|
|
1287
1297
|
chipOpen.value = false;
|
|
1288
1298
|
}
|
|
@@ -1334,6 +1344,7 @@ var LoomaEditor = defineComponent({
|
|
|
1334
1344
|
onOpen: openLinkEditor,
|
|
1335
1345
|
onClose: () => {
|
|
1336
1346
|
linkOpen.value = false;
|
|
1347
|
+
linkPressedSelection = null;
|
|
1337
1348
|
}
|
|
1338
1349
|
}, () => h("form", {
|
|
1339
1350
|
class: "looma-editor__link-form",
|