@threadlabs/looma 0.15.4 → 0.15.5
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.
|
@@ -6,7 +6,7 @@ import { history, redo, undo } from "@tiptap/pm/history";
|
|
|
6
6
|
import { dropCursor } from "@tiptap/pm/dropcursor";
|
|
7
7
|
import { gapCursor } from "@tiptap/pm/gapcursor";
|
|
8
8
|
import { common, createLowlight } from "lowlight";
|
|
9
|
-
import { DOMParser, Node as Node$2 } from "@tiptap/pm/model";
|
|
9
|
+
import { DOMParser, Node as Node$2, Slice } from "@tiptap/pm/model";
|
|
10
10
|
import MarkdownIt from "markdown-it";
|
|
11
11
|
import { CellSelection, TableMap, addColumn, addColumnAfter, addColumnBefore, addRow, addRowAfter, addRowBefore, cellAround, columnResizing, deleteCellSelection, deleteColumn, deleteRow, deleteTable, fixTables, goToNextCell, mergeCells, moveTableColumn, moveTableRow, setCellAttr, splitCell, tableEditing, toggleHeader, toggleHeaderCell } from "@tiptap/pm/tables";
|
|
12
12
|
//#region src/editor/extensions/active-block.ts
|
|
@@ -8514,6 +8514,8 @@ function looksLikeMarkdown(value) {
|
|
|
8514
8514
|
}
|
|
8515
8515
|
function parseHtmlSlice(schema, value) {
|
|
8516
8516
|
const parsed = new globalThis.DOMParser().parseFromString(value, "text/html");
|
|
8517
|
+
if (parsed.body.style.display === "none") return Slice.empty;
|
|
8518
|
+
for (const element of parsed.body.querySelectorAll("[style]")) if (element.style.display === "none") element.remove();
|
|
8517
8519
|
const container = document.createElement("div");
|
|
8518
8520
|
container.append(purify.sanitize(parsed.body.innerHTML, {
|
|
8519
8521
|
USE_PROFILES: { html: true },
|
|
@@ -8528,7 +8530,7 @@ function parseHtmlSlice(schema, value) {
|
|
|
8528
8530
|
FORBID_ATTR: ["style"],
|
|
8529
8531
|
RETURN_DOM_FRAGMENT: true
|
|
8530
8532
|
}));
|
|
8531
|
-
if (!container.textContent?.trim() && !container.querySelector("img, hr")) return
|
|
8533
|
+
if (!container.textContent?.trim() && !container.querySelector("img, hr")) return Slice.empty;
|
|
8532
8534
|
return DOMParser.fromSchema(schema).parseSlice(container, { preserveWhitespace: false });
|
|
8533
8535
|
}
|
|
8534
8536
|
function documentSlice(schema, plainText) {
|
|
@@ -8558,6 +8560,7 @@ var LoomaSmartPaste = Extension.create({
|
|
|
8558
8560
|
if (!plainText.trim()) return false;
|
|
8559
8561
|
const slice = documentSlice(view.state.schema, plainText);
|
|
8560
8562
|
if (!slice) return false;
|
|
8563
|
+
if (slice.size === 0) return true;
|
|
8561
8564
|
const transaction = view.state.tr.replaceSelection(slice).scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste");
|
|
8562
8565
|
view.dispatch(transaction);
|
|
8563
8566
|
return true;
|