@firecms/editor 3.0.0-canary.244 → 3.0.0-canary.246
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/extensions/clipboard.d.ts +7 -0
- package/dist/index.es.js +58 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +64 -9
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.umd.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
(function(global, factory) {
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react"), require("@firecms/ui"), require("@tiptap/react"), require("@tiptap/extension-document"), require("tiptap-markdown"), require("@tiptap/extension-underline"), require("@tiptap/extension-heading"), require("@tiptap/extension-text-style"), require("@tiptap/extension-color"), require("@tiptap/extension-highlight"), require("@tiptap/extension-bold"), require("@tiptap/extension-italic"), require("@tiptap/extension-strike"), require("react-compiler-runtime"), require("@radix-ui/react-slot"), require("@tiptap/starter-kit"), require("@tiptap/extension-horizontal-rule"), require("@tiptap/extension-link"), require("@tiptap/extension-image"), require("@tiptap/extension-placeholder"), require("@tiptap/extension-task-item"), require("@tiptap/extension-task-list"), require("@tiptap/core"), require("prosemirror-state"), require("prosemirror-view"), require("@tiptap/extension-ordered-list"), require("@tiptap/extension-bullet-list"), require("@tiptap/extension-list-item"), require("@tiptap/extension-code-block"), require("@tiptap/extension-blockquote"), require("@tiptap/extension-code"), require("@tiptap/pm/view"), require("@tiptap/pm/state"), require("@tiptap/suggestion"), require("tippy.js")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react", "@firecms/ui", "@tiptap/react", "@tiptap/extension-document", "tiptap-markdown", "@tiptap/extension-underline", "@tiptap/extension-heading", "@tiptap/extension-text-style", "@tiptap/extension-color", "@tiptap/extension-highlight", "@tiptap/extension-bold", "@tiptap/extension-italic", "@tiptap/extension-strike", "react-compiler-runtime", "@radix-ui/react-slot", "@tiptap/starter-kit", "@tiptap/extension-horizontal-rule", "@tiptap/extension-link", "@tiptap/extension-image", "@tiptap/extension-placeholder", "@tiptap/extension-task-item", "@tiptap/extension-task-list", "@tiptap/core", "prosemirror-state", "prosemirror-view", "@tiptap/extension-ordered-list", "@tiptap/extension-bullet-list", "@tiptap/extension-list-item", "@tiptap/extension-code-block", "@tiptap/extension-blockquote", "@tiptap/extension-code", "@tiptap/pm/view", "@tiptap/pm/state", "@tiptap/suggestion", "tippy.js"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS Editor"] = {}, global.jsxRuntime, global.React, global.ui, global.react, global.Document, global.tiptapMarkdown, global.Underline, global.Heading, global.TextStyle, global.Color, global.Highlight, global.Bold, global.Italic, global.Strike, global.reactCompilerRuntime, global.reactSlot, global.StarterKit, global.HorizontalRule, global.TiptapLink, global.TiptapImage, global.Placeholder, global.extensionTaskItem, global.extensionTaskList, global.core, global.prosemirrorState, global.prosemirrorView, global.OrderedList, global.BulletList, global.ListItem, global.CodeBlock, global.Blockquote, global.Code, global.view, global.state, global.Suggestion, global.tippy));
|
3
|
-
})(this, function(exports2, jsxRuntime, React, ui, react, Document, tiptapMarkdown, Underline, Heading, TextStyle, Color, Highlight, Bold, Italic, Strike, reactCompilerRuntime, reactSlot, StarterKit, HorizontalRule, TiptapLink, TiptapImage, Placeholder, extensionTaskItem, extensionTaskList, core, prosemirrorState, prosemirrorView, OrderedList, BulletList, ListItem, CodeBlock, Blockquote, Code, view, state, Suggestion, tippy) {
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react"), require("@firecms/ui"), require("@tiptap/react"), require("@tiptap/extension-document"), require("tiptap-markdown"), require("@tiptap/extension-underline"), require("@tiptap/extension-heading"), require("@tiptap/extension-text-style"), require("@tiptap/extension-color"), require("@tiptap/extension-highlight"), require("@tiptap/extension-bold"), require("@tiptap/extension-italic"), require("@tiptap/extension-strike"), require("react-compiler-runtime"), require("@radix-ui/react-slot"), require("@tiptap/starter-kit"), require("@tiptap/extension-horizontal-rule"), require("@tiptap/extension-link"), require("@tiptap/extension-image"), require("@tiptap/extension-placeholder"), require("@tiptap/extension-task-item"), require("@tiptap/extension-task-list"), require("@tiptap/core"), require("prosemirror-state"), require("prosemirror-view"), require("@tiptap/extension-ordered-list"), require("@tiptap/extension-bullet-list"), require("@tiptap/extension-list-item"), require("@tiptap/extension-code-block"), require("@tiptap/extension-blockquote"), require("@tiptap/extension-code"), require("@tiptap/pm/view"), require("@tiptap/pm/state"), require("prosemirror-model"), require("@tiptap/suggestion"), require("tippy.js")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react", "@firecms/ui", "@tiptap/react", "@tiptap/extension-document", "tiptap-markdown", "@tiptap/extension-underline", "@tiptap/extension-heading", "@tiptap/extension-text-style", "@tiptap/extension-color", "@tiptap/extension-highlight", "@tiptap/extension-bold", "@tiptap/extension-italic", "@tiptap/extension-strike", "react-compiler-runtime", "@radix-ui/react-slot", "@tiptap/starter-kit", "@tiptap/extension-horizontal-rule", "@tiptap/extension-link", "@tiptap/extension-image", "@tiptap/extension-placeholder", "@tiptap/extension-task-item", "@tiptap/extension-task-list", "@tiptap/core", "prosemirror-state", "prosemirror-view", "@tiptap/extension-ordered-list", "@tiptap/extension-bullet-list", "@tiptap/extension-list-item", "@tiptap/extension-code-block", "@tiptap/extension-blockquote", "@tiptap/extension-code", "@tiptap/pm/view", "@tiptap/pm/state", "prosemirror-model", "@tiptap/suggestion", "tippy.js"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS Editor"] = {}, global.jsxRuntime, global.React, global.ui, global.react, global.Document, global.tiptapMarkdown, global.Underline, global.Heading, global.TextStyle, global.Color, global.Highlight, global.Bold, global.Italic, global.Strike, global.reactCompilerRuntime, global.reactSlot, global.StarterKit, global.HorizontalRule, global.TiptapLink, global.TiptapImage, global.Placeholder, global.extensionTaskItem, global.extensionTaskList, global.core, global.prosemirrorState, global.prosemirrorView, global.OrderedList, global.BulletList, global.ListItem, global.CodeBlock, global.Blockquote, global.Code, global.view, global.state, global.prosemirrorModel, global.Suggestion, global.tippy));
|
3
|
+
})(this, function(exports2, jsxRuntime, React, ui, react, Document, tiptapMarkdown, Underline, Heading, TextStyle, Color, Highlight, Bold, Italic, Strike, reactCompilerRuntime, reactSlot, StarterKit, HorizontalRule, TiptapLink, TiptapImage, Placeholder, extensionTaskItem, extensionTaskList, core, prosemirrorState, prosemirrorView, OrderedList, BulletList, ListItem, CodeBlock, Blockquote, Code, view, state, prosemirrorModel, Suggestion, tippy) {
|
4
4
|
"use strict";
|
5
5
|
const EditorBubble = React.forwardRef((t0, ref) => {
|
6
6
|
const $ = reactCompilerRuntime.c(21);
|
@@ -932,6 +932,61 @@
|
|
932
932
|
};
|
933
933
|
}
|
934
934
|
});
|
935
|
+
function serializeForClipboard(view2, slice) {
|
936
|
+
view2.someProp("transformCopied", (f) => {
|
937
|
+
slice = f(slice, view2);
|
938
|
+
});
|
939
|
+
const context = [];
|
940
|
+
let {
|
941
|
+
content,
|
942
|
+
openStart,
|
943
|
+
openEnd
|
944
|
+
} = slice;
|
945
|
+
while (openStart > 1 && openEnd > 1 && content.childCount == 1 && content.firstChild.childCount == 1) {
|
946
|
+
openStart--;
|
947
|
+
openEnd--;
|
948
|
+
const node = content.firstChild;
|
949
|
+
context.push(node.type.name, node.attrs != node.type.defaultAttrs ? node.attrs : null);
|
950
|
+
content = node.content;
|
951
|
+
}
|
952
|
+
const serializer = view2.someProp("clipboardSerializer") || prosemirrorModel.DOMSerializer.fromSchema(view2.state.schema);
|
953
|
+
const doc = detachedDoc(), wrap = doc.createElement("div");
|
954
|
+
wrap.appendChild(serializer.serializeFragment(content, {
|
955
|
+
document: doc
|
956
|
+
}));
|
957
|
+
let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
|
958
|
+
while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
|
959
|
+
for (let i = needsWrap.length - 1; i >= 0; i--) {
|
960
|
+
const wrapper = doc.createElement(needsWrap[i]);
|
961
|
+
while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
|
962
|
+
wrap.appendChild(wrapper);
|
963
|
+
wrappers++;
|
964
|
+
}
|
965
|
+
firstChild = wrap.firstChild;
|
966
|
+
}
|
967
|
+
if (firstChild && firstChild.nodeType == 1) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
|
968
|
+
const text = view2.someProp("clipboardTextSerializer", (f) => f(slice, view2)) || slice.content.textBetween(0, slice.content.size, "\n\n");
|
969
|
+
return {
|
970
|
+
dom: wrap,
|
971
|
+
text,
|
972
|
+
slice
|
973
|
+
};
|
974
|
+
}
|
975
|
+
const wrapMap = {
|
976
|
+
thead: ["table"],
|
977
|
+
tbody: ["table"],
|
978
|
+
tfoot: ["table"],
|
979
|
+
caption: ["table"],
|
980
|
+
colgroup: ["table"],
|
981
|
+
col: ["table", "colgroup"],
|
982
|
+
tr: ["table", "tbody"],
|
983
|
+
td: ["table", "tbody", "tr"],
|
984
|
+
th: ["table", "tbody", "tr"]
|
985
|
+
};
|
986
|
+
let _detachedDoc = null;
|
987
|
+
function detachedDoc() {
|
988
|
+
return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
|
989
|
+
}
|
935
990
|
function absoluteRect(element) {
|
936
991
|
const data = element.getBoundingClientRect();
|
937
992
|
let ancestor = element.parentElement;
|
@@ -956,28 +1011,28 @@
|
|
956
1011
|
})?.inside;
|
957
1012
|
}
|
958
1013
|
function DragHandle(options) {
|
959
|
-
function handleDragStart(event,
|
960
|
-
|
1014
|
+
function handleDragStart(event, view2) {
|
1015
|
+
view2.focus();
|
961
1016
|
if (!event.dataTransfer) return;
|
962
1017
|
const node = nodeDOMAtCoords({
|
963
1018
|
x: event.clientX + 50 + options.dragHandleWidth,
|
964
1019
|
y: event.clientY
|
965
1020
|
});
|
966
1021
|
if (!(node instanceof Element)) return;
|
967
|
-
const nodePos = nodePosAtDOM(node,
|
1022
|
+
const nodePos = nodePosAtDOM(node, view2, options);
|
968
1023
|
if (nodePos == null || nodePos < 0) return;
|
969
|
-
|
970
|
-
const slice =
|
1024
|
+
view2.dispatch(view2.state.tr.setSelection(state.NodeSelection.create(view2.state.doc, nodePos)));
|
1025
|
+
const slice = view2.state.selection.content();
|
971
1026
|
const {
|
972
1027
|
dom,
|
973
1028
|
text
|
974
|
-
} =
|
1029
|
+
} = serializeForClipboard(view2, slice);
|
975
1030
|
event.dataTransfer.clearData();
|
976
1031
|
event.dataTransfer.setData("text/html", dom.innerHTML);
|
977
1032
|
event.dataTransfer.setData("text/plain", text);
|
978
1033
|
event.dataTransfer.effectAllowed = "copyMove";
|
979
1034
|
event.dataTransfer.setDragImage(node, 0, 0);
|
980
|
-
|
1035
|
+
view2.dragging = {
|
981
1036
|
slice,
|
982
1037
|
move: event.ctrlKey
|
983
1038
|
};
|