@meowdown/core 0.78.1 → 0.78.3

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -27
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1927,10 +1927,6 @@ function defineEditorCommands() {
1927
1927
 
1928
1928
  //#endregion
1929
1929
  //#region src/extensions/cross-editor-drag.ts
1930
- const mountedViews = /* @__PURE__ */ new Set();
1931
- function findDragSource(target) {
1932
- for (const view of mountedViews) if (view !== target && !view.isDestroyed && view.editable && view.dragging) return view;
1933
- }
1934
1930
  function deleteDraggedContent(view, dragging) {
1935
1931
  const tr = view.state.tr;
1936
1932
  if (dragging.node) {
@@ -1940,41 +1936,41 @@ function deleteDraggedContent(view, dragging) {
1940
1936
  if (!tr.docChanged) return;
1941
1937
  view.dispatch(tr.setMeta("uiEvent", "drop"));
1942
1938
  }
1943
- function handleCrossEditorDrop(target, event, slice, move) {
1944
- if (move || slice.size === 0) return false;
1945
- const source = findDragSource(target);
1946
- if (!source) return false;
1947
- const dragging = source.dragging;
1948
- if (!dragging) return false;
1949
- if (isApple ? event.altKey : event.ctrlKey) return false;
1950
- source.dragging = null;
1951
- const docBeforeDrop = target.state.doc;
1952
- queueMicrotask(() => {
1953
- if (source.isDestroyed || target.isDestroyed) return;
1954
- if (target.state.doc === docBeforeDrop) return;
1955
- deleteDraggedContent(source, dragging);
1956
- });
1957
- return false;
1939
+ /**
1940
+ * Remove the content that a finished drag moved out of `view`. `dropEffect` is
1941
+ * the value the drag source reads on `dragend`.
1942
+ *
1943
+ * @internal
1944
+ */
1945
+ function removeMovedContent(view, dropEffect) {
1946
+ const dragging = view.dragging;
1947
+ if (!dragging || !view.editable || dropEffect !== "move") return;
1948
+ view.dragging = null;
1949
+ deleteDraggedContent(view, dragging);
1958
1950
  }
1959
1951
  function createCrossEditorDragPlugin() {
1960
1952
  return new Plugin({
1961
1953
  key: new PluginKey("meowdown-cross-editor-drag"),
1962
1954
  view: (view) => {
1963
- mountedViews.add(view);
1955
+ const ownerDocument = view.dom.ownerDocument;
1956
+ const handleDragEnd = (event) => {
1957
+ removeMovedContent(view, event.dataTransfer?.dropEffect);
1958
+ };
1959
+ ownerDocument.addEventListener("dragend", handleDragEnd);
1964
1960
  return { destroy: () => {
1965
- mountedViews.delete(view);
1961
+ ownerDocument.removeEventListener("dragend", handleDragEnd);
1966
1962
  } };
1967
- },
1968
- props: { handleDrop: handleCrossEditorDrop }
1963
+ }
1969
1964
  });
1970
1965
  }
1971
1966
  /**
1972
- * Dragging a block from one meowdown editor into another one on the same page
1973
- * moves it: the block leaves the source document once it lands in the target.
1967
+ * Dragging content out of a meowdown editor moves it when the drop target
1968
+ * accepts a move: another meowdown editor on the same page, or one in another
1969
+ * window or tab. The content leaves the source document once the drag ends.
1974
1970
  * Hold Alt (Ctrl on Windows and Linux) to copy instead.
1975
1971
  */
1976
1972
  function defineCrossEditorDrag() {
1977
- return withPriority$1(definePlugin(createCrossEditorDragPlugin()), Priority$1.high);
1973
+ return definePlugin(createCrossEditorDragPlugin());
1978
1974
  }
1979
1975
 
1980
1976
  //#endregion
@@ -4544,7 +4540,7 @@ function docToParagraphMarkdown(doc) {
4544
4540
  paragraphs.push(node.textContent);
4545
4541
  return false;
4546
4542
  });
4547
- return paragraphs.join("\n").replaceAll(/\r\n?/g, "\n").replaceAll(/\n[ \t]*\n+/g, "\n");
4543
+ return paragraphs.join("\n").replaceAll(/\n[ \t]*\n+/g, "\n");
4548
4544
  }
4549
4545
 
4550
4546
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/core",
3
3
  "type": "module",
4
- "version": "0.78.1",
4
+ "version": "0.78.3",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "@floating-ui/dom": "^1.8.0",
27
27
  "@lezer/highlight": "^1.2.3",
28
28
  "@meowdown/embed": "0.3.1",
29
- "@meowdown/markdown": "0.74.0",
29
+ "@meowdown/markdown": "0.76.0",
30
30
  "@ocavue/utils": "^1.8.0",
31
31
  "@post-embed/exporter": "^0.5.0",
32
32
  "@post-embed/schema": "^0.5.2",