@tiptap/core 2.2.0-rc.3 → 2.2.0-rc.4

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.js CHANGED
@@ -753,7 +753,7 @@ const pasteRuleMatcherHandler = (text, find) => {
753
753
  });
754
754
  };
755
755
  function run(config) {
756
- const { editor, state, from, to, rule, } = config;
756
+ const { editor, state, from, to, rule, pasteEvent, dropEvent, } = config;
757
757
  const { commands, chain, can } = new CommandManager({
758
758
  editor,
759
759
  state,
@@ -784,6 +784,8 @@ function run(config) {
784
784
  commands,
785
785
  chain,
786
786
  can,
787
+ pasteEvent,
788
+ dropEvent,
787
789
  });
788
790
  handlers.push(handler);
789
791
  });
@@ -801,6 +803,8 @@ function pasteRulesPlugin(props) {
801
803
  let dragSourceElement = null;
802
804
  let isPastedFromProseMirror = false;
803
805
  let isDroppedFromProseMirror = false;
806
+ let pasteEvent = new ClipboardEvent('paste');
807
+ let dropEvent = new DragEvent('drop');
804
808
  const plugins = rules.map(rule => {
805
809
  return new Plugin({
806
810
  // we register a global drag handler to track the current drag source element
@@ -820,13 +824,15 @@ function pasteRulesPlugin(props) {
820
824
  },
821
825
  props: {
822
826
  handleDOMEvents: {
823
- drop: view => {
827
+ drop: (view, event) => {
824
828
  isDroppedFromProseMirror = dragSourceElement === view.dom.parentElement;
829
+ dropEvent = event;
825
830
  return false;
826
831
  },
827
- paste: (view, event) => {
832
+ paste: (_view, event) => {
828
833
  var _a;
829
834
  const html = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text/html');
835
+ pasteEvent = event;
830
836
  isPastedFromProseMirror = !!(html === null || html === void 0 ? void 0 : html.includes('data-pm-slice'));
831
837
  return false;
832
838
  },
@@ -858,11 +864,15 @@ function pasteRulesPlugin(props) {
858
864
  from: Math.max(from - 1, 0),
859
865
  to: to.b - 1,
860
866
  rule,
867
+ pasteEvent,
868
+ dropEvent,
861
869
  });
862
870
  // stop if there are no changes
863
871
  if (!handler || !tr.steps.length) {
864
872
  return;
865
873
  }
874
+ dropEvent = new DragEvent('drop');
875
+ pasteEvent = new ClipboardEvent('paste');
866
876
  return tr;
867
877
  },
868
878
  });
@@ -1167,7 +1177,7 @@ class Extension {
1167
1177
  return extension;
1168
1178
  }
1169
1179
  extend(extendedConfig = {}) {
1170
- const extension = new Extension(extendedConfig);
1180
+ const extension = new Extension({ ...this.config, ...extendedConfig });
1171
1181
  extension.parent = this;
1172
1182
  this.child = extension;
1173
1183
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
@@ -3970,7 +3980,7 @@ class Mark {
3970
3980
  return extension;
3971
3981
  }
3972
3982
  extend(extendedConfig = {}) {
3973
- const extension = new Mark(extendedConfig);
3983
+ const extension = new Mark({ ...this.config, ...extendedConfig });
3974
3984
  extension.parent = this;
3975
3985
  this.child = extension;
3976
3986
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
@@ -4053,7 +4063,7 @@ class Node {
4053
4063
  return extension;
4054
4064
  }
4055
4065
  extend(extendedConfig = {}) {
4056
- const extension = new Node(extendedConfig);
4066
+ const extension = new Node({ ...this.config, ...extendedConfig });
4057
4067
  extension.parent = this;
4058
4068
  this.child = extension;
4059
4069
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
@@ -4269,8 +4279,8 @@ class NodeView {
4269
4279
  function markPasteRule(config) {
4270
4280
  return new PasteRule({
4271
4281
  find: config.find,
4272
- handler: ({ state, range, match }) => {
4273
- const attributes = callOrReturn(config.getAttributes, undefined, match);
4282
+ handler: ({ state, range, match, pasteEvent, }) => {
4283
+ const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent);
4274
4284
  if (attributes === false || attributes === null) {
4275
4285
  return null;
4276
4286
  }
@@ -4322,8 +4332,8 @@ function isString(value) {
4322
4332
  function nodePasteRule(config) {
4323
4333
  return new PasteRule({
4324
4334
  find: config.find,
4325
- handler({ match, chain, range }) {
4326
- const attributes = callOrReturn(config.getAttributes, undefined, match);
4335
+ handler({ match, chain, range, pasteEvent, }) {
4336
+ const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent);
4327
4337
  if (attributes === false || attributes === null) {
4328
4338
  return null;
4329
4339
  }