@trafica/editor 1.0.46 → 1.0.47
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 +22 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8517,19 +8517,17 @@ function EditorCore({
|
|
|
8517
8517
|
e.preventDefault();
|
|
8518
8518
|
const path = JSON.parse(fig.dataset.imagePath);
|
|
8519
8519
|
setSelectedImagePath(path);
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
};
|
|
8532
|
-
}
|
|
8520
|
+
const imgEl = fig.querySelector("img");
|
|
8521
|
+
const rect = imgEl == null ? void 0 : imgEl.getBoundingClientRect();
|
|
8522
|
+
imageDragRef.current = {
|
|
8523
|
+
imagePath: path,
|
|
8524
|
+
startX: e.clientX,
|
|
8525
|
+
startY: e.clientY,
|
|
8526
|
+
active: false,
|
|
8527
|
+
ghostW: Math.min((rect == null ? void 0 : rect.width) || 300, 320),
|
|
8528
|
+
ghostH: Math.min((rect == null ? void 0 : rect.height) || 200, 200),
|
|
8529
|
+
ghostSrc: (imgEl == null ? void 0 : imgEl.src) || ""
|
|
8530
|
+
};
|
|
8533
8531
|
return;
|
|
8534
8532
|
}
|
|
8535
8533
|
setSelectedImagePath(null);
|
|
@@ -8919,14 +8917,19 @@ function moveImageInDoc(imagePath, targetIndex, engine) {
|
|
|
8919
8917
|
const state = engine.getState();
|
|
8920
8918
|
const imageNode = getNodeAtPath(state.doc, imagePath);
|
|
8921
8919
|
if (!imageNode) return;
|
|
8922
|
-
const
|
|
8923
|
-
const
|
|
8924
|
-
let adj = targetIndex
|
|
8925
|
-
|
|
8926
|
-
|
|
8920
|
+
const isTopLevel = imagePath.length === 1;
|
|
8921
|
+
const topLevelIndex = imagePath[0];
|
|
8922
|
+
let adj = targetIndex;
|
|
8923
|
+
if (isTopLevel) {
|
|
8924
|
+
if (targetIndex > topLevelIndex) adj = targetIndex - 1;
|
|
8925
|
+
adj = Math.max(0, Math.min(state.doc.children.length - 1, adj));
|
|
8926
|
+
if (adj === topLevelIndex) return;
|
|
8927
|
+
} else {
|
|
8928
|
+
adj = Math.max(0, Math.min(state.doc.children.length, adj));
|
|
8929
|
+
}
|
|
8927
8930
|
const tr = createTransaction();
|
|
8928
8931
|
tr.steps.push({ type: "delete_node", path: imagePath });
|
|
8929
|
-
tr.steps.push({ type: "insert_node", parentPath, index: adj, node: imageNode });
|
|
8932
|
+
tr.steps.push({ type: "insert_node", parentPath: [], index: adj, node: imageNode });
|
|
8930
8933
|
engine.dispatch(tr);
|
|
8931
8934
|
}
|
|
8932
8935
|
var BLOCK_TAGS = "p|h[1-6]|ul|ol|li|blockquote|pre|figure|table|thead|tbody|tr|th|td";
|