@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.es.js
CHANGED
@@ -30,8 +30,9 @@ import ListItem from "@tiptap/extension-list-item";
|
|
30
30
|
import CodeBlock from "@tiptap/extension-code-block";
|
31
31
|
import Blockquote from "@tiptap/extension-blockquote";
|
32
32
|
import Code from "@tiptap/extension-code";
|
33
|
-
import { DecorationSet as DecorationSet$1, Decoration as Decoration$1
|
33
|
+
import { DecorationSet as DecorationSet$1, Decoration as Decoration$1 } from "@tiptap/pm/view";
|
34
34
|
import { PluginKey as PluginKey$1, Plugin as Plugin$1, NodeSelection } from "@tiptap/pm/state";
|
35
|
+
import { DOMSerializer } from "prosemirror-model";
|
35
36
|
import Suggestion from "@tiptap/suggestion";
|
36
37
|
import tippy from "tippy.js";
|
37
38
|
const EditorBubble = forwardRef((t0, ref) => {
|
@@ -964,6 +965,61 @@ const CustomKeymap = Extension.create({
|
|
964
965
|
};
|
965
966
|
}
|
966
967
|
});
|
968
|
+
function serializeForClipboard(view, slice) {
|
969
|
+
view.someProp("transformCopied", (f) => {
|
970
|
+
slice = f(slice, view);
|
971
|
+
});
|
972
|
+
const context = [];
|
973
|
+
let {
|
974
|
+
content,
|
975
|
+
openStart,
|
976
|
+
openEnd
|
977
|
+
} = slice;
|
978
|
+
while (openStart > 1 && openEnd > 1 && content.childCount == 1 && content.firstChild.childCount == 1) {
|
979
|
+
openStart--;
|
980
|
+
openEnd--;
|
981
|
+
const node = content.firstChild;
|
982
|
+
context.push(node.type.name, node.attrs != node.type.defaultAttrs ? node.attrs : null);
|
983
|
+
content = node.content;
|
984
|
+
}
|
985
|
+
const serializer = view.someProp("clipboardSerializer") || DOMSerializer.fromSchema(view.state.schema);
|
986
|
+
const doc = detachedDoc(), wrap = doc.createElement("div");
|
987
|
+
wrap.appendChild(serializer.serializeFragment(content, {
|
988
|
+
document: doc
|
989
|
+
}));
|
990
|
+
let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
|
991
|
+
while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
|
992
|
+
for (let i = needsWrap.length - 1; i >= 0; i--) {
|
993
|
+
const wrapper = doc.createElement(needsWrap[i]);
|
994
|
+
while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
|
995
|
+
wrap.appendChild(wrapper);
|
996
|
+
wrappers++;
|
997
|
+
}
|
998
|
+
firstChild = wrap.firstChild;
|
999
|
+
}
|
1000
|
+
if (firstChild && firstChild.nodeType == 1) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
|
1001
|
+
const text = view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n");
|
1002
|
+
return {
|
1003
|
+
dom: wrap,
|
1004
|
+
text,
|
1005
|
+
slice
|
1006
|
+
};
|
1007
|
+
}
|
1008
|
+
const wrapMap = {
|
1009
|
+
thead: ["table"],
|
1010
|
+
tbody: ["table"],
|
1011
|
+
tfoot: ["table"],
|
1012
|
+
caption: ["table"],
|
1013
|
+
colgroup: ["table"],
|
1014
|
+
col: ["table", "colgroup"],
|
1015
|
+
tr: ["table", "tbody"],
|
1016
|
+
td: ["table", "tbody", "tr"],
|
1017
|
+
th: ["table", "tbody", "tr"]
|
1018
|
+
};
|
1019
|
+
let _detachedDoc = null;
|
1020
|
+
function detachedDoc() {
|
1021
|
+
return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
|
1022
|
+
}
|
967
1023
|
function absoluteRect(element) {
|
968
1024
|
const data = element.getBoundingClientRect();
|
969
1025
|
let ancestor = element.parentElement;
|
@@ -1003,7 +1059,7 @@ function DragHandle(options) {
|
|
1003
1059
|
const {
|
1004
1060
|
dom,
|
1005
1061
|
text
|
1006
|
-
} =
|
1062
|
+
} = serializeForClipboard(view, slice);
|
1007
1063
|
event.dataTransfer.clearData();
|
1008
1064
|
event.dataTransfer.setData("text/html", dom.innerHTML);
|
1009
1065
|
event.dataTransfer.setData("text/plain", text);
|