rme 0.3.0-beta.62 → 0.3.0-beta.63
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 +35 -3
- package/dist/index.mjs.map +2 -2
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -5807,6 +5807,12 @@ var HandleInputExtension = class extends PlainExtension6 {
|
|
|
5807
5807
|
if (!node.isText || !node.text) {
|
|
5808
5808
|
return true;
|
|
5809
5809
|
}
|
|
5810
|
+
const $pos = newState.doc.resolve(pos);
|
|
5811
|
+
const parent = $pos.parent;
|
|
5812
|
+
const excludeParentNodes = ["math_block", "codeMirror", "reference_def", "html_block", "mermaid_node"];
|
|
5813
|
+
if (excludeParentNodes.includes(parent.type.name)) {
|
|
5814
|
+
return true;
|
|
5815
|
+
}
|
|
5810
5816
|
const text = node.text;
|
|
5811
5817
|
for (const rule7 of this.inputRules) {
|
|
5812
5818
|
let match;
|
|
@@ -6158,12 +6164,15 @@ var HtmlNodeView = class {
|
|
|
6158
6164
|
constructor(node, view, getPos, options) {
|
|
6159
6165
|
this._htmlSrcElt = null;
|
|
6160
6166
|
this.destroying = false;
|
|
6167
|
+
this.options = {};
|
|
6161
6168
|
this.ignoreMutation = () => true;
|
|
6162
6169
|
this._node = node;
|
|
6163
6170
|
this._outerView = view;
|
|
6164
6171
|
this._getPos = getPos;
|
|
6165
6172
|
this.schema = node.type.schema;
|
|
6166
|
-
|
|
6173
|
+
if (options) {
|
|
6174
|
+
this.options = { ...this.options, ...options };
|
|
6175
|
+
}
|
|
6167
6176
|
this.dom = document.createElement("div");
|
|
6168
6177
|
this.dom.classList.add("html-node");
|
|
6169
6178
|
this._htmlRenderElt = document.createElement("p");
|
|
@@ -6221,7 +6230,30 @@ var HtmlNodeView = class {
|
|
|
6221
6230
|
}
|
|
6222
6231
|
this._htmlRenderElt.classList.remove("node-hide");
|
|
6223
6232
|
this._htmlRenderElt.classList.add("node-show");
|
|
6224
|
-
|
|
6233
|
+
const domParser = new DOMParser();
|
|
6234
|
+
const doc = domParser.parseFromString(texString, "text/html");
|
|
6235
|
+
const processNodes = (nodes) => {
|
|
6236
|
+
const nodeArray = Array.from(nodes);
|
|
6237
|
+
nodeArray.forEach((child) => {
|
|
6238
|
+
if (isImageElement(child) && child.src && this.options.handleViewImgSrcUrl) {
|
|
6239
|
+
let targetUrl = child.src;
|
|
6240
|
+
if (child.src.includes(location.origin)) {
|
|
6241
|
+
targetUrl = child.src.split(location.origin)[1];
|
|
6242
|
+
}
|
|
6243
|
+
void this.options.handleViewImgSrcUrl(targetUrl).then((newHref) => {
|
|
6244
|
+
child.src = newHref;
|
|
6245
|
+
});
|
|
6246
|
+
}
|
|
6247
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
6248
|
+
const element = child;
|
|
6249
|
+
if (element.children.length > 0) {
|
|
6250
|
+
processNodes(element.children);
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
this._htmlRenderElt?.appendChild(child);
|
|
6254
|
+
});
|
|
6255
|
+
};
|
|
6256
|
+
processNodes(doc.body.childNodes);
|
|
6225
6257
|
} catch (err) {
|
|
6226
6258
|
}
|
|
6227
6259
|
}
|
|
@@ -12531,7 +12563,7 @@ function extensions(options) {
|
|
|
12531
12563
|
new LineInlineMarkExtension(),
|
|
12532
12564
|
new LineInlineDecorationExtension(),
|
|
12533
12565
|
new MathBlockExtension(codemirrorNodeCommonOptions),
|
|
12534
|
-
new LineHtmlBlockExtension(codemirrorNodeCommonOptions),
|
|
12566
|
+
new LineHtmlBlockExtension({ ...codemirrorNodeCommonOptions, handleViewImgSrcUrl }),
|
|
12535
12567
|
new MermaidBlockExtension(codemirrorNodeCommonOptions),
|
|
12536
12568
|
new MathInlineExtension({}),
|
|
12537
12569
|
new ReferenceDefinitionExtension({}),
|