md-editor-v3 5.4.1 → 5.4.2
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 +46 -15
- package/lib/es/chunks/index.mjs +46 -15
- package/lib/umd/index.js +10 -10
- package/package.json +1 -1
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -1267,26 +1267,45 @@ 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
1275
|
const compareHtml = (newHtml, currentHtml) => {
|
|
1276
|
-
const newNodes =
|
|
1277
|
-
const currentNodes =
|
|
1276
|
+
const newNodes = splitNodes(newHtml);
|
|
1277
|
+
const currentNodes = splitNodes(currentHtml);
|
|
1278
1278
|
const updates = [];
|
|
1279
1279
|
const deletes = [];
|
|
1280
|
-
newNodes.forEach((
|
|
1281
|
-
|
|
1280
|
+
newNodes.forEach((newNode, index2) => {
|
|
1281
|
+
const currentNode = currentNodes[index2];
|
|
1282
|
+
if (!currentNode) {
|
|
1282
1283
|
updates.push({
|
|
1283
1284
|
index: index2,
|
|
1284
|
-
newNode:
|
|
1285
|
+
newNode: newNode.nodeType === 3 ? newNode.textContent || "" : newNode.outerHTML,
|
|
1286
|
+
isText: newNode.nodeType === 3
|
|
1285
1287
|
});
|
|
1286
|
-
} else if (
|
|
1288
|
+
} else if (newNode.nodeType === 3 && currentNode.nodeType === 3) {
|
|
1289
|
+
if (newNode.textContent !== currentNode.textContent) {
|
|
1290
|
+
updates.push({
|
|
1291
|
+
index: index2,
|
|
1292
|
+
newNode: newNode.textContent || "",
|
|
1293
|
+
isText: true
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
} else if (newNode.nodeType !== 3 && currentNode.nodeType !== 3) {
|
|
1297
|
+
if (currentNode.outerHTML !== newNode.outerHTML) {
|
|
1298
|
+
updates.push({
|
|
1299
|
+
index: index2,
|
|
1300
|
+
newNode: newNode.outerHTML,
|
|
1301
|
+
isText: false
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
} else {
|
|
1287
1305
|
updates.push({
|
|
1288
1306
|
index: index2,
|
|
1289
|
-
newNode:
|
|
1307
|
+
newNode: newNode.nodeType === 3 ? newNode.textContent || "" : newNode.outerHTML,
|
|
1308
|
+
isText: newNode.nodeType === 3
|
|
1290
1309
|
});
|
|
1291
1310
|
}
|
|
1292
1311
|
});
|
|
@@ -1318,18 +1337,30 @@ const UpdateOnDemand = /* @__PURE__ */ vue.defineComponent({
|
|
|
1318
1337
|
if (!htmlContainer.value) return;
|
|
1319
1338
|
deletes.reverse().forEach((index2) => {
|
|
1320
1339
|
var _a, _b;
|
|
1321
|
-
(_b = (_a = htmlContainer.value) == null ? void 0 : _a.
|
|
1340
|
+
(_b = (_a = htmlContainer.value) == null ? void 0 : _a.childNodes[index2]) == null ? void 0 : _b.remove();
|
|
1322
1341
|
});
|
|
1323
1342
|
updates.forEach(({
|
|
1324
1343
|
index: index2,
|
|
1325
|
-
newNode
|
|
1344
|
+
newNode,
|
|
1345
|
+
isText
|
|
1326
1346
|
}) => {
|
|
1327
|
-
var _a
|
|
1328
|
-
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.
|
|
1347
|
+
var _a;
|
|
1348
|
+
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.childNodes[index2];
|
|
1329
1349
|
if (targetNode) {
|
|
1330
|
-
|
|
1350
|
+
if (isText) {
|
|
1351
|
+
targetNode.textContent = newNode;
|
|
1352
|
+
} else {
|
|
1353
|
+
targetNode.outerHTML = newNode;
|
|
1354
|
+
}
|
|
1331
1355
|
} else {
|
|
1332
|
-
(
|
|
1356
|
+
if (htmlContainer.value) {
|
|
1357
|
+
if (isText) {
|
|
1358
|
+
const textNode = document.createTextNode(newNode);
|
|
1359
|
+
htmlContainer.value.appendChild(textNode);
|
|
1360
|
+
} else {
|
|
1361
|
+
htmlContainer.value.insertAdjacentHTML("beforeend", newNode);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1333
1364
|
}
|
|
1334
1365
|
});
|
|
1335
1366
|
};
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1266,26 +1266,45 @@ 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
1274
|
const compareHtml = (newHtml, currentHtml) => {
|
|
1275
|
-
const newNodes =
|
|
1276
|
-
const currentNodes =
|
|
1275
|
+
const newNodes = splitNodes(newHtml);
|
|
1276
|
+
const currentNodes = splitNodes(currentHtml);
|
|
1277
1277
|
const updates = [];
|
|
1278
1278
|
const deletes = [];
|
|
1279
|
-
newNodes.forEach((
|
|
1280
|
-
|
|
1279
|
+
newNodes.forEach((newNode, index) => {
|
|
1280
|
+
const currentNode = currentNodes[index];
|
|
1281
|
+
if (!currentNode) {
|
|
1281
1282
|
updates.push({
|
|
1282
1283
|
index,
|
|
1283
|
-
newNode:
|
|
1284
|
+
newNode: newNode.nodeType === 3 ? newNode.textContent || "" : newNode.outerHTML,
|
|
1285
|
+
isText: newNode.nodeType === 3
|
|
1284
1286
|
});
|
|
1285
|
-
} else if (
|
|
1287
|
+
} else if (newNode.nodeType === 3 && currentNode.nodeType === 3) {
|
|
1288
|
+
if (newNode.textContent !== currentNode.textContent) {
|
|
1289
|
+
updates.push({
|
|
1290
|
+
index,
|
|
1291
|
+
newNode: newNode.textContent || "",
|
|
1292
|
+
isText: true
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
} else if (newNode.nodeType !== 3 && currentNode.nodeType !== 3) {
|
|
1296
|
+
if (currentNode.outerHTML !== newNode.outerHTML) {
|
|
1297
|
+
updates.push({
|
|
1298
|
+
index,
|
|
1299
|
+
newNode: newNode.outerHTML,
|
|
1300
|
+
isText: false
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
} else {
|
|
1286
1304
|
updates.push({
|
|
1287
1305
|
index,
|
|
1288
|
-
newNode:
|
|
1306
|
+
newNode: newNode.nodeType === 3 ? newNode.textContent || "" : newNode.outerHTML,
|
|
1307
|
+
isText: newNode.nodeType === 3
|
|
1289
1308
|
});
|
|
1290
1309
|
}
|
|
1291
1310
|
});
|
|
@@ -1317,18 +1336,30 @@ const UpdateOnDemand = /* @__PURE__ */ defineComponent({
|
|
|
1317
1336
|
if (!htmlContainer.value) return;
|
|
1318
1337
|
deletes.reverse().forEach((index) => {
|
|
1319
1338
|
var _a, _b;
|
|
1320
|
-
(_b = (_a = htmlContainer.value) == null ? void 0 : _a.
|
|
1339
|
+
(_b = (_a = htmlContainer.value) == null ? void 0 : _a.childNodes[index]) == null ? void 0 : _b.remove();
|
|
1321
1340
|
});
|
|
1322
1341
|
updates.forEach(({
|
|
1323
1342
|
index,
|
|
1324
|
-
newNode
|
|
1343
|
+
newNode,
|
|
1344
|
+
isText
|
|
1325
1345
|
}) => {
|
|
1326
|
-
var _a
|
|
1327
|
-
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.
|
|
1346
|
+
var _a;
|
|
1347
|
+
const targetNode = (_a = htmlContainer.value) == null ? void 0 : _a.childNodes[index];
|
|
1328
1348
|
if (targetNode) {
|
|
1329
|
-
|
|
1349
|
+
if (isText) {
|
|
1350
|
+
targetNode.textContent = newNode;
|
|
1351
|
+
} else {
|
|
1352
|
+
targetNode.outerHTML = newNode;
|
|
1353
|
+
}
|
|
1330
1354
|
} else {
|
|
1331
|
-
(
|
|
1355
|
+
if (htmlContainer.value) {
|
|
1356
|
+
if (isText) {
|
|
1357
|
+
const textNode = document.createTextNode(newNode);
|
|
1358
|
+
htmlContainer.value.appendChild(textNode);
|
|
1359
|
+
} else {
|
|
1360
|
+
htmlContainer.value.insertAdjacentHTML("beforeend", newNode);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1332
1363
|
}
|
|
1333
1364
|
});
|
|
1334
1365
|
};
|