@tiptap/core 2.2.0-rc.3 → 2.2.0-rc.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.
- package/dist/index.cjs +20 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +20 -10
- 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/Extension.ts +1 -1
- package/src/Mark.ts +1 -1
- package/src/Node.ts +1 -1
- 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
|
});
|
|
@@ -1165,7 +1175,7 @@
|
|
|
1165
1175
|
return extension;
|
|
1166
1176
|
}
|
|
1167
1177
|
extend(extendedConfig = {}) {
|
|
1168
|
-
const extension = new Extension(extendedConfig);
|
|
1178
|
+
const extension = new Extension({ ...this.config, ...extendedConfig });
|
|
1169
1179
|
extension.parent = this;
|
|
1170
1180
|
this.child = extension;
|
|
1171
1181
|
extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
|
|
@@ -3968,7 +3978,7 @@ img.ProseMirror-separator {
|
|
|
3968
3978
|
return extension;
|
|
3969
3979
|
}
|
|
3970
3980
|
extend(extendedConfig = {}) {
|
|
3971
|
-
const extension = new Mark(extendedConfig);
|
|
3981
|
+
const extension = new Mark({ ...this.config, ...extendedConfig });
|
|
3972
3982
|
extension.parent = this;
|
|
3973
3983
|
this.child = extension;
|
|
3974
3984
|
extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
|
|
@@ -4051,7 +4061,7 @@ img.ProseMirror-separator {
|
|
|
4051
4061
|
return extension;
|
|
4052
4062
|
}
|
|
4053
4063
|
extend(extendedConfig = {}) {
|
|
4054
|
-
const extension = new Node(extendedConfig);
|
|
4064
|
+
const extension = new Node({ ...this.config, ...extendedConfig });
|
|
4055
4065
|
extension.parent = this;
|
|
4056
4066
|
this.child = extension;
|
|
4057
4067
|
extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
|
|
@@ -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
|
}
|