rme 0.2.3-alpha.1 → 0.2.3-alpha.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.
- package/dist/index.mjs +22 -59
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5340,7 +5340,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
5340
5340
|
font-size: small;
|
|
5341
5341
|
border-radius: ${(props) => props.theme.smallBorderRadius};
|
|
5342
5342
|
cursor: pointer;
|
|
5343
|
-
z-index:
|
|
5343
|
+
z-index: 10;
|
|
5344
5344
|
color: ${(props) => props.theme.labelFontColor};
|
|
5345
5345
|
background: ${(props) => props.theme.hoverColor};
|
|
5346
5346
|
}
|
|
@@ -7899,10 +7899,12 @@ var ClipboardExtension = class extends PlainExtension2 {
|
|
|
7899
7899
|
if (node) {
|
|
7900
7900
|
if ((node.type.name === "html_image" || node.type.name === "md_image") && node.attrs.src) {
|
|
7901
7901
|
this.processImageNode(node, view);
|
|
7902
|
+
view.dispatch(view.state.tr.replaceSelectionWith(node, true));
|
|
7902
7903
|
} else {
|
|
7903
|
-
this.processMarkdownImageSyntax(
|
|
7904
|
+
this.processMarkdownImageSyntax(node, view).then(() => {
|
|
7905
|
+
view.dispatch(view.state.tr.replaceSelectionWith(node, true));
|
|
7906
|
+
});
|
|
7904
7907
|
}
|
|
7905
|
-
view.dispatch(view.state.tr.replaceSelectionWith(node, true));
|
|
7906
7908
|
return true;
|
|
7907
7909
|
}
|
|
7908
7910
|
this.processImagesInSliceAsync(slice, view);
|
|
@@ -7927,55 +7929,31 @@ var ClipboardExtension = class extends PlainExtension2 {
|
|
|
7927
7929
|
/**
|
|
7928
7930
|
* Process markdown image syntax in text nodes and update their src attributes using imageCopyHandler
|
|
7929
7931
|
*/
|
|
7930
|
-
processMarkdownImageSyntax(
|
|
7932
|
+
async processMarkdownImageSyntax(node, view) {
|
|
7931
7933
|
const { imageCopyHandler } = this.options;
|
|
7932
7934
|
if (!imageCopyHandler) return;
|
|
7933
7935
|
const imageRegex = /!\[([^\]]*)\]\(([^\s]+)(?:\s+"([^"]*)")??\)/g;
|
|
7934
|
-
const
|
|
7935
|
-
|
|
7936
|
-
if (node.isText && node.text) {
|
|
7936
|
+
const processTextNode = async (n2) => {
|
|
7937
|
+
if (n2.isText && n2.text) {
|
|
7937
7938
|
let match;
|
|
7938
7939
|
imageRegex.lastIndex = 0;
|
|
7939
|
-
while ((match = imageRegex.exec(
|
|
7940
|
+
while ((match = imageRegex.exec(n2.text)) !== null) {
|
|
7940
7941
|
const [, , src] = match;
|
|
7941
7942
|
if (src) {
|
|
7942
|
-
|
|
7943
|
+
const newSrc = await imageCopyHandler(src);
|
|
7944
|
+
if (newSrc && newSrc !== src) {
|
|
7945
|
+
n2.text = n2.text.replace(src, newSrc);
|
|
7946
|
+
}
|
|
7943
7947
|
}
|
|
7944
7948
|
}
|
|
7945
7949
|
}
|
|
7946
|
-
if (
|
|
7947
|
-
|
|
7950
|
+
if (n2.content && n2.content.size > 0) {
|
|
7951
|
+
n2.content.forEach((child) => {
|
|
7948
7952
|
processTextNode(child);
|
|
7949
7953
|
});
|
|
7950
7954
|
}
|
|
7951
7955
|
};
|
|
7952
|
-
|
|
7953
|
-
if (foundUrls.size > 0) {
|
|
7954
|
-
this.setupImageConversionMonitor(view, foundUrls);
|
|
7955
|
-
}
|
|
7956
|
-
}
|
|
7957
|
-
/**
|
|
7958
|
-
* Monitor document changes for converted image nodes
|
|
7959
|
-
*/
|
|
7960
|
-
setupImageConversionMonitor(view, urlsToMonitor) {
|
|
7961
|
-
const { imageCopyHandler } = this.options;
|
|
7962
|
-
if (!imageCopyHandler) return;
|
|
7963
|
-
const checkForConvertedImages = () => {
|
|
7964
|
-
const { doc } = view.state;
|
|
7965
|
-
const processedUrls = /* @__PURE__ */ new Set();
|
|
7966
|
-
doc.descendants((node) => {
|
|
7967
|
-
if ((node.type.name === "html_image" || node.type.name === "md_image") && node.attrs.src) {
|
|
7968
|
-
const src = node.attrs.src;
|
|
7969
|
-
if (urlsToMonitor.has(src) && !processedUrls.has(src)) {
|
|
7970
|
-
processedUrls.add(src);
|
|
7971
|
-
this.processImageNode(node, view);
|
|
7972
|
-
}
|
|
7973
|
-
}
|
|
7974
|
-
return true;
|
|
7975
|
-
});
|
|
7976
|
-
};
|
|
7977
|
-
setTimeout(checkForConvertedImages, 0);
|
|
7978
|
-
setTimeout(checkForConvertedImages, 100);
|
|
7956
|
+
await processTextNode(node);
|
|
7979
7957
|
}
|
|
7980
7958
|
/**
|
|
7981
7959
|
* Process a single image node asynchronously and update its src attribute using imageCopyHandler
|
|
@@ -7986,7 +7964,7 @@ var ClipboardExtension = class extends PlainExtension2 {
|
|
|
7986
7964
|
node.attrs["data-rme-loading"] = "true";
|
|
7987
7965
|
imageCopyHandler(node.attrs.src).then((newSrc) => {
|
|
7988
7966
|
if (newSrc && newSrc !== node.attrs.src) {
|
|
7989
|
-
this.updateImageNodeSrc(view, node
|
|
7967
|
+
this.updateImageNodeSrc(view, node, newSrc);
|
|
7990
7968
|
}
|
|
7991
7969
|
}).catch((error) => {
|
|
7992
7970
|
console.warn("imageCopyHandler failed:", error);
|
|
@@ -8040,27 +8018,11 @@ var ClipboardExtension = class extends PlainExtension2 {
|
|
|
8040
8018
|
/**
|
|
8041
8019
|
* Update image node src attribute in the document
|
|
8042
8020
|
*/
|
|
8043
|
-
updateImageNodeSrc(view,
|
|
8021
|
+
updateImageNodeSrc(view, node, newSrc) {
|
|
8044
8022
|
const { state, dispatch } = view;
|
|
8045
|
-
const { doc } = state;
|
|
8046
8023
|
let tr = state.tr;
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
if ((node.type.name === "html_image" || node.type.name === "md_image") && node.attrs.src === oldSrc) {
|
|
8050
|
-
const newAttrs = {
|
|
8051
|
-
...node.attrs,
|
|
8052
|
-
src: newSrc,
|
|
8053
|
-
"data-rme-loading": null
|
|
8054
|
-
};
|
|
8055
|
-
tr = tr.setNodeMarkup(pos, void 0, newAttrs);
|
|
8056
|
-
updated = true;
|
|
8057
|
-
}
|
|
8058
|
-
return true;
|
|
8059
|
-
});
|
|
8060
|
-
if (updated) {
|
|
8061
|
-
tr = tr.setMeta("addToHistory", false);
|
|
8062
|
-
dispatch(tr);
|
|
8063
|
-
}
|
|
8024
|
+
node.attrs.src = newSrc;
|
|
8025
|
+
dispatch(tr);
|
|
8064
8026
|
}
|
|
8065
8027
|
};
|
|
8066
8028
|
ClipboardExtension = __decorateClass([
|
|
@@ -17452,7 +17414,7 @@ function ImageNodeView(props) {
|
|
|
17452
17414
|
},
|
|
17453
17415
|
`${node.attrs.src}`
|
|
17454
17416
|
);
|
|
17455
|
-
return /* @__PURE__ */ jsx13("div", { ref: popoverRef, children: /* @__PURE__ */ jsx13(
|
|
17417
|
+
return /* @__PURE__ */ jsx13("div", { ref: popoverRef, style: { position: "relative", zIndex: selected ? 10 : "auto" }, children: /* @__PURE__ */ jsx13(
|
|
17456
17418
|
Popover2,
|
|
17457
17419
|
{
|
|
17458
17420
|
customContent: /* @__PURE__ */ jsx13(
|
|
@@ -17470,6 +17432,7 @@ function ImageNodeView(props) {
|
|
|
17470
17432
|
placement: "top-start",
|
|
17471
17433
|
onStoreChange: handleStoreChange,
|
|
17472
17434
|
toggleOnClick: true,
|
|
17435
|
+
style: { zIndex: 11 },
|
|
17473
17436
|
children: Main
|
|
17474
17437
|
}
|
|
17475
17438
|
) });
|