@tiptap/core 2.1.10 → 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 CHANGED
@@ -757,7 +757,7 @@ const pasteRuleMatcherHandler = (text, find) => {
757
757
  });
758
758
  };
759
759
  function run(config) {
760
- const { editor, state, from, to, rule, } = config;
760
+ const { editor, state, from, to, rule, pasteEvent, dropEvent, } = config;
761
761
  const { commands, chain, can } = new CommandManager({
762
762
  editor,
763
763
  state,
@@ -788,6 +788,8 @@ function run(config) {
788
788
  commands,
789
789
  chain,
790
790
  can,
791
+ pasteEvent,
792
+ dropEvent,
791
793
  });
792
794
  handlers.push(handler);
793
795
  });
@@ -805,6 +807,8 @@ function pasteRulesPlugin(props) {
805
807
  let dragSourceElement = null;
806
808
  let isPastedFromProseMirror = false;
807
809
  let isDroppedFromProseMirror = false;
810
+ let pasteEvent = new ClipboardEvent('paste');
811
+ let dropEvent = new DragEvent('drop');
808
812
  const plugins = rules.map(rule => {
809
813
  return new state.Plugin({
810
814
  // we register a global drag handler to track the current drag source element
@@ -824,13 +828,15 @@ function pasteRulesPlugin(props) {
824
828
  },
825
829
  props: {
826
830
  handleDOMEvents: {
827
- drop: view => {
831
+ drop: (view, event) => {
828
832
  isDroppedFromProseMirror = dragSourceElement === view.dom.parentElement;
833
+ dropEvent = event;
829
834
  return false;
830
835
  },
831
- paste: (view, event) => {
836
+ paste: (_view, event) => {
832
837
  var _a;
833
838
  const html = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text/html');
839
+ pasteEvent = event;
834
840
  isPastedFromProseMirror = !!(html === null || html === void 0 ? void 0 : html.includes('data-pm-slice'));
835
841
  return false;
836
842
  },
@@ -862,11 +868,15 @@ function pasteRulesPlugin(props) {
862
868
  from: Math.max(from - 1, 0),
863
869
  to: to.b - 1,
864
870
  rule,
871
+ pasteEvent,
872
+ dropEvent,
865
873
  });
866
874
  // stop if there are no changes
867
875
  if (!handler || !tr.steps.length) {
868
876
  return;
869
877
  }
878
+ dropEvent = new DragEvent('drop');
879
+ pasteEvent = new ClipboardEvent('paste');
870
880
  return tr;
871
881
  },
872
882
  });
@@ -4273,8 +4283,8 @@ class NodeView {
4273
4283
  function markPasteRule(config) {
4274
4284
  return new PasteRule({
4275
4285
  find: config.find,
4276
- handler: ({ state, range, match }) => {
4277
- const attributes = callOrReturn(config.getAttributes, undefined, match);
4286
+ handler: ({ state, range, match, pasteEvent, }) => {
4287
+ const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent);
4278
4288
  if (attributes === false || attributes === null) {
4279
4289
  return null;
4280
4290
  }
@@ -4326,8 +4336,8 @@ function isString(value) {
4326
4336
  function nodePasteRule(config) {
4327
4337
  return new PasteRule({
4328
4338
  find: config.find,
4329
- handler({ match, chain, range }) {
4330
- const attributes = callOrReturn(config.getAttributes, undefined, match);
4339
+ handler({ match, chain, range, pasteEvent, }) {
4340
+ const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent);
4331
4341
  if (attributes === false || attributes === null) {
4332
4342
  return null;
4333
4343
  }