@tiptap/core 2.1.9 → 2.1.11
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/index.cjs +17 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +17 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/PasteRule.d.ts +9 -5
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -1
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +1 -1
- package/package.json +2 -2
- package/src/PasteRule.ts +26 -8
- package/src/pasteRules/markPasteRule.ts +5 -3
- package/src/pasteRules/nodePasteRule.ts +5 -3
package/dist/index.umd.js
CHANGED
|
@@ -751,7 +751,7 @@
|
|
|
751
751
|
});
|
|
752
752
|
};
|
|
753
753
|
function run(config) {
|
|
754
|
-
const { editor, state, from, to, rule, } = config;
|
|
754
|
+
const { editor, state, from, to, rule, pasteEvent, dropEvent, } = config;
|
|
755
755
|
const { commands, chain, can } = new CommandManager({
|
|
756
756
|
editor,
|
|
757
757
|
state,
|
|
@@ -782,6 +782,8 @@
|
|
|
782
782
|
commands,
|
|
783
783
|
chain,
|
|
784
784
|
can,
|
|
785
|
+
pasteEvent,
|
|
786
|
+
dropEvent,
|
|
785
787
|
});
|
|
786
788
|
handlers.push(handler);
|
|
787
789
|
});
|
|
@@ -799,6 +801,8 @@
|
|
|
799
801
|
let dragSourceElement = null;
|
|
800
802
|
let isPastedFromProseMirror = false;
|
|
801
803
|
let isDroppedFromProseMirror = false;
|
|
804
|
+
let pasteEvent = new ClipboardEvent('paste');
|
|
805
|
+
let dropEvent = new DragEvent('drop');
|
|
802
806
|
const plugins = rules.map(rule => {
|
|
803
807
|
return new state.Plugin({
|
|
804
808
|
// we register a global drag handler to track the current drag source element
|
|
@@ -818,13 +822,15 @@
|
|
|
818
822
|
},
|
|
819
823
|
props: {
|
|
820
824
|
handleDOMEvents: {
|
|
821
|
-
drop: view => {
|
|
825
|
+
drop: (view, event) => {
|
|
822
826
|
isDroppedFromProseMirror = dragSourceElement === view.dom.parentElement;
|
|
827
|
+
dropEvent = event;
|
|
823
828
|
return false;
|
|
824
829
|
},
|
|
825
|
-
paste: (
|
|
830
|
+
paste: (_view, event) => {
|
|
826
831
|
var _a;
|
|
827
832
|
const html = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text/html');
|
|
833
|
+
pasteEvent = event;
|
|
828
834
|
isPastedFromProseMirror = !!(html === null || html === void 0 ? void 0 : html.includes('data-pm-slice'));
|
|
829
835
|
return false;
|
|
830
836
|
},
|
|
@@ -856,11 +862,15 @@
|
|
|
856
862
|
from: Math.max(from - 1, 0),
|
|
857
863
|
to: to.b - 1,
|
|
858
864
|
rule,
|
|
865
|
+
pasteEvent,
|
|
866
|
+
dropEvent,
|
|
859
867
|
});
|
|
860
868
|
// stop if there are no changes
|
|
861
869
|
if (!handler || !tr.steps.length) {
|
|
862
870
|
return;
|
|
863
871
|
}
|
|
872
|
+
dropEvent = new DragEvent('drop');
|
|
873
|
+
pasteEvent = new ClipboardEvent('paste');
|
|
864
874
|
return tr;
|
|
865
875
|
},
|
|
866
876
|
});
|
|
@@ -4267,8 +4277,8 @@ img.ProseMirror-separator {
|
|
|
4267
4277
|
function markPasteRule(config) {
|
|
4268
4278
|
return new PasteRule({
|
|
4269
4279
|
find: config.find,
|
|
4270
|
-
handler: ({ state, range, match }) => {
|
|
4271
|
-
const attributes = callOrReturn(config.getAttributes, undefined, match);
|
|
4280
|
+
handler: ({ state, range, match, pasteEvent, }) => {
|
|
4281
|
+
const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent);
|
|
4272
4282
|
if (attributes === false || attributes === null) {
|
|
4273
4283
|
return null;
|
|
4274
4284
|
}
|
|
@@ -4320,8 +4330,8 @@ img.ProseMirror-separator {
|
|
|
4320
4330
|
function nodePasteRule(config) {
|
|
4321
4331
|
return new PasteRule({
|
|
4322
4332
|
find: config.find,
|
|
4323
|
-
handler({ match, chain, range }) {
|
|
4324
|
-
const attributes = callOrReturn(config.getAttributes, undefined, match);
|
|
4333
|
+
handler({ match, chain, range, pasteEvent, }) {
|
|
4334
|
+
const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent);
|
|
4325
4335
|
if (attributes === false || attributes === null) {
|
|
4326
4336
|
return null;
|
|
4327
4337
|
}
|