md-editor-v3 5.4.1 → 5.4.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/lib/cjs/chunks/index.cjs +26 -23
- package/lib/es/chunks/index.mjs +26 -23
- package/lib/umd/index.js +71 -71
- package/package.json +1 -1
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -1267,32 +1267,33 @@ const contentProps = {
|
|
|
1267
1267
|
type: String
|
|
1268
1268
|
}
|
|
1269
1269
|
};
|
|
1270
|
-
const
|
|
1270
|
+
const splitNodes = (html) => {
|
|
1271
1271
|
const parser = new DOMParser();
|
|
1272
1272
|
const doc = parser.parseFromString(html, "text/html");
|
|
1273
|
-
return Array.from(doc.body.
|
|
1273
|
+
return Array.from(doc.body.childNodes);
|
|
1274
1274
|
};
|
|
1275
|
-
const compareHtml = (
|
|
1276
|
-
const newNodes = splitHtml(newHtml);
|
|
1277
|
-
const currentNodes = splitHtml(currentHtml);
|
|
1275
|
+
const compareHtml = (newNodes, currentNodes) => {
|
|
1278
1276
|
const updates = [];
|
|
1279
1277
|
const deletes = [];
|
|
1280
|
-
newNodes.forEach((
|
|
1281
|
-
|
|
1278
|
+
newNodes.forEach((newNode, index2) => {
|
|
1279
|
+
const currentNode = currentNodes[index2];
|
|
1280
|
+
if (!currentNode) {
|
|
1282
1281
|
updates.push({
|
|
1283
1282
|
index: index2,
|
|
1284
|
-
newNode
|
|
1283
|
+
newNode
|
|
1285
1284
|
});
|
|
1286
|
-
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
if (newNode.nodeType !== currentNode.nodeType || newNode.textContent !== currentNode.textContent || newNode.nodeType === 1 && newNode.outerHTML !== currentNode.outerHTML) {
|
|
1287
1288
|
updates.push({
|
|
1288
1289
|
index: index2,
|
|
1289
|
-
newNode
|
|
1290
|
+
newNode
|
|
1290
1291
|
});
|
|
1291
1292
|
}
|
|
1292
1293
|
});
|
|
1293
1294
|
if (currentNodes.length > newNodes.length) {
|
|
1294
1295
|
for (let i = newNodes.length; i < currentNodes.length; i++) {
|
|
1295
|
-
deletes.push(i);
|
|
1296
|
+
deletes.push(currentNodes[i]);
|
|
1296
1297
|
}
|
|
1297
1298
|
}
|
|
1298
1299
|
return {
|
|
@@ -1313,37 +1314,39 @@ const UpdateOnDemand = /* @__PURE__ */ vue.defineComponent({
|
|
|
1313
1314
|
const previewTheme = vue.inject("previewTheme");
|
|
1314
1315
|
const showCodeRowNumber = vue.inject("showCodeRowNumber");
|
|
1315
1316
|
const htmlContainer = vue.ref();
|
|
1316
|
-
const firstHtml =
|
|
1317
|
+
const firstHtml = props.html;
|
|
1317
1318
|
const updateHtmlContent = (updates, deletes) => {
|
|
1318
1319
|
if (!htmlContainer.value) return;
|
|
1319
|
-
deletes.
|
|
1320
|
-
|
|
1321
|
-
(_b = (_a = htmlContainer.value) == null ? void 0 : _a.children[index2]) == null ? void 0 : _b.remove();
|
|
1320
|
+
deletes.forEach((node) => {
|
|
1321
|
+
node.remove();
|
|
1322
1322
|
});
|
|
1323
1323
|
updates.forEach(({
|
|
1324
1324
|
index: index2,
|
|
1325
1325
|
newNode
|
|
1326
1326
|
}) => {
|
|
1327
|
-
var _a, _b;
|
|
1328
|
-
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.
|
|
1329
|
-
if (targetNode) {
|
|
1330
|
-
|
|
1327
|
+
var _a, _b, _c;
|
|
1328
|
+
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.childNodes[index2];
|
|
1329
|
+
if (!targetNode) {
|
|
1330
|
+
(_b = htmlContainer.value) == null ? void 0 : _b.appendChild(newNode.cloneNode(true));
|
|
1331
1331
|
} else {
|
|
1332
|
-
(
|
|
1332
|
+
(_c = htmlContainer.value) == null ? void 0 : _c.replaceChild(newNode.cloneNode(true), targetNode);
|
|
1333
1333
|
}
|
|
1334
1334
|
});
|
|
1335
1335
|
};
|
|
1336
|
-
vue.watch(() => props.html, (newHtml
|
|
1336
|
+
vue.watch(() => props.html, (newHtml) => {
|
|
1337
|
+
var _a;
|
|
1338
|
+
const newNodes = splitNodes(newHtml);
|
|
1339
|
+
const currentNodes = Array.from(((_a = htmlContainer.value) == null ? void 0 : _a.childNodes) || []);
|
|
1337
1340
|
const {
|
|
1338
1341
|
updates,
|
|
1339
1342
|
deletes
|
|
1340
|
-
} = compareHtml(
|
|
1343
|
+
} = compareHtml(newNodes, currentNodes);
|
|
1341
1344
|
updateHtmlContent(updates, deletes);
|
|
1342
1345
|
});
|
|
1343
1346
|
return () => vue.createVNode("div", {
|
|
1344
1347
|
"id": `${editorId}-preview`,
|
|
1345
1348
|
"class": [`${config.prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${config.prefix}-scrn`],
|
|
1346
|
-
"innerHTML": firstHtml
|
|
1349
|
+
"innerHTML": firstHtml,
|
|
1347
1350
|
"ref": htmlContainer
|
|
1348
1351
|
}, null);
|
|
1349
1352
|
}
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1266,32 +1266,33 @@ const contentProps = {
|
|
|
1266
1266
|
type: String
|
|
1267
1267
|
}
|
|
1268
1268
|
};
|
|
1269
|
-
const
|
|
1269
|
+
const splitNodes = (html) => {
|
|
1270
1270
|
const parser = new DOMParser();
|
|
1271
1271
|
const doc = parser.parseFromString(html, "text/html");
|
|
1272
|
-
return Array.from(doc.body.
|
|
1272
|
+
return Array.from(doc.body.childNodes);
|
|
1273
1273
|
};
|
|
1274
|
-
const compareHtml = (
|
|
1275
|
-
const newNodes = splitHtml(newHtml);
|
|
1276
|
-
const currentNodes = splitHtml(currentHtml);
|
|
1274
|
+
const compareHtml = (newNodes, currentNodes) => {
|
|
1277
1275
|
const updates = [];
|
|
1278
1276
|
const deletes = [];
|
|
1279
|
-
newNodes.forEach((
|
|
1280
|
-
|
|
1277
|
+
newNodes.forEach((newNode, index) => {
|
|
1278
|
+
const currentNode = currentNodes[index];
|
|
1279
|
+
if (!currentNode) {
|
|
1281
1280
|
updates.push({
|
|
1282
1281
|
index,
|
|
1283
|
-
newNode
|
|
1282
|
+
newNode
|
|
1284
1283
|
});
|
|
1285
|
-
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (newNode.nodeType !== currentNode.nodeType || newNode.textContent !== currentNode.textContent || newNode.nodeType === 1 && newNode.outerHTML !== currentNode.outerHTML) {
|
|
1286
1287
|
updates.push({
|
|
1287
1288
|
index,
|
|
1288
|
-
newNode
|
|
1289
|
+
newNode
|
|
1289
1290
|
});
|
|
1290
1291
|
}
|
|
1291
1292
|
});
|
|
1292
1293
|
if (currentNodes.length > newNodes.length) {
|
|
1293
1294
|
for (let i = newNodes.length; i < currentNodes.length; i++) {
|
|
1294
|
-
deletes.push(i);
|
|
1295
|
+
deletes.push(currentNodes[i]);
|
|
1295
1296
|
}
|
|
1296
1297
|
}
|
|
1297
1298
|
return {
|
|
@@ -1312,37 +1313,39 @@ const UpdateOnDemand = /* @__PURE__ */ defineComponent({
|
|
|
1312
1313
|
const previewTheme = inject("previewTheme");
|
|
1313
1314
|
const showCodeRowNumber = inject("showCodeRowNumber");
|
|
1314
1315
|
const htmlContainer = ref();
|
|
1315
|
-
const firstHtml =
|
|
1316
|
+
const firstHtml = props.html;
|
|
1316
1317
|
const updateHtmlContent = (updates, deletes) => {
|
|
1317
1318
|
if (!htmlContainer.value) return;
|
|
1318
|
-
deletes.
|
|
1319
|
-
|
|
1320
|
-
(_b = (_a = htmlContainer.value) == null ? void 0 : _a.children[index]) == null ? void 0 : _b.remove();
|
|
1319
|
+
deletes.forEach((node) => {
|
|
1320
|
+
node.remove();
|
|
1321
1321
|
});
|
|
1322
1322
|
updates.forEach(({
|
|
1323
1323
|
index,
|
|
1324
1324
|
newNode
|
|
1325
1325
|
}) => {
|
|
1326
|
-
var _a, _b;
|
|
1327
|
-
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.
|
|
1328
|
-
if (targetNode) {
|
|
1329
|
-
|
|
1326
|
+
var _a, _b, _c;
|
|
1327
|
+
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.childNodes[index];
|
|
1328
|
+
if (!targetNode) {
|
|
1329
|
+
(_b = htmlContainer.value) == null ? void 0 : _b.appendChild(newNode.cloneNode(true));
|
|
1330
1330
|
} else {
|
|
1331
|
-
(
|
|
1331
|
+
(_c = htmlContainer.value) == null ? void 0 : _c.replaceChild(newNode.cloneNode(true), targetNode);
|
|
1332
1332
|
}
|
|
1333
1333
|
});
|
|
1334
1334
|
};
|
|
1335
|
-
watch(() => props.html, (newHtml
|
|
1335
|
+
watch(() => props.html, (newHtml) => {
|
|
1336
|
+
var _a;
|
|
1337
|
+
const newNodes = splitNodes(newHtml);
|
|
1338
|
+
const currentNodes = Array.from(((_a = htmlContainer.value) == null ? void 0 : _a.childNodes) || []);
|
|
1336
1339
|
const {
|
|
1337
1340
|
updates,
|
|
1338
1341
|
deletes
|
|
1339
|
-
} = compareHtml(
|
|
1342
|
+
} = compareHtml(newNodes, currentNodes);
|
|
1340
1343
|
updateHtmlContent(updates, deletes);
|
|
1341
1344
|
});
|
|
1342
1345
|
return () => createVNode("div", {
|
|
1343
1346
|
"id": `${editorId}-preview`,
|
|
1344
1347
|
"class": [`${prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${prefix}-scrn`],
|
|
1345
|
-
"innerHTML": firstHtml
|
|
1348
|
+
"innerHTML": firstHtml,
|
|
1346
1349
|
"ref": htmlContainer
|
|
1347
1350
|
}, null);
|
|
1348
1351
|
}
|