md-editor-v3 5.4.0-5 → 5.4.1

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.
@@ -2895,8 +2895,7 @@ const Content = /* @__PURE__ */ vue.defineComponent({
2895
2895
  "sanitizeMermaid": props2.sanitizeMermaid,
2896
2896
  "codeFoldable": props2.codeFoldable,
2897
2897
  "autoFoldThreshold": props2.autoFoldThreshold,
2898
- "onRemount": props2.onRemount,
2899
- "htmlUpdateOnDemand": props2.htmlUpdateOnDemand
2898
+ "onRemount": props2.onRemount
2900
2899
  }, null)]), props2.catalogVisible && vue.createVNode(MdCatalog.MdCatalog, {
2901
2900
  "theme": props2.theme,
2902
2901
  "class": `${config.prefix}-catalog-editor ${config.prefix}-catalog-${props2.catalogLayout}`,
@@ -3240,8 +3239,7 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
3240
3239
  (_a = props2.onRemount) == null ? void 0 : _a.call(props2);
3241
3240
  ctx.emit("onRemount");
3242
3241
  },
3243
- "catalogLayout": props2.catalogLayout,
3244
- "htmlUpdateOnDemand": props2.htmlUpdateOnDemand
3242
+ "catalogLayout": props2.catalogLayout
3245
3243
  }, null), props2.footers.length > 0 && vue.createVNode(Footer, {
3246
3244
  "modelValue": props2.modelValue,
3247
3245
  "footers": props2.footers,
@@ -1185,9 +1185,6 @@ const contentPreviewProps = {
1185
1185
  },
1186
1186
  onRemount: {
1187
1187
  type: Function
1188
- },
1189
- htmlUpdateOnDemand: {
1190
- type: Boolean
1191
1188
  }
1192
1189
  };
1193
1190
  const contentProps = {
@@ -1278,14 +1275,30 @@ const splitHtml = (html) => {
1278
1275
  const compareHtml = (newHtml, currentHtml) => {
1279
1276
  const newNodes = splitHtml(newHtml);
1280
1277
  const currentNodes = splitHtml(currentHtml);
1281
- return newNodes.map((node, index2) => {
1282
- var _a;
1283
- return {
1284
- index: index2,
1285
- newNode: node.outerHTML,
1286
- isUpdated: ((_a = currentNodes[index2]) == null ? void 0 : _a.outerHTML) !== node.outerHTML
1287
- };
1288
- }).filter((update) => update.isUpdated);
1278
+ const updates = [];
1279
+ const deletes = [];
1280
+ newNodes.forEach((node, index2) => {
1281
+ if (!currentNodes[index2]) {
1282
+ updates.push({
1283
+ index: index2,
1284
+ newNode: node.outerHTML
1285
+ });
1286
+ } else if (currentNodes[index2].outerHTML !== node.outerHTML) {
1287
+ updates.push({
1288
+ index: index2,
1289
+ newNode: node.outerHTML
1290
+ });
1291
+ }
1292
+ });
1293
+ if (currentNodes.length > newNodes.length) {
1294
+ for (let i = newNodes.length; i < currentNodes.length; i++) {
1295
+ deletes.push(i);
1296
+ }
1297
+ }
1298
+ return {
1299
+ updates,
1300
+ deletes
1301
+ };
1289
1302
  };
1290
1303
  const UpdateOnDemand = /* @__PURE__ */ vue.defineComponent({
1291
1304
  name: "UpdateOnDemand",
@@ -1299,8 +1312,14 @@ const UpdateOnDemand = /* @__PURE__ */ vue.defineComponent({
1299
1312
  const editorId = vue.inject("editorId");
1300
1313
  const previewTheme = vue.inject("previewTheme");
1301
1314
  const showCodeRowNumber = vue.inject("showCodeRowNumber");
1302
- const htmlContainer = vue.ref(null);
1303
- const updateHtmlContent = (updates) => {
1315
+ const htmlContainer = vue.ref();
1316
+ const firstHtml = vue.ref(props.html);
1317
+ const updateHtmlContent = (updates, deletes) => {
1318
+ if (!htmlContainer.value) return;
1319
+ deletes.reverse().forEach((index2) => {
1320
+ var _a, _b;
1321
+ (_b = (_a = htmlContainer.value) == null ? void 0 : _a.children[index2]) == null ? void 0 : _b.remove();
1322
+ });
1304
1323
  updates.forEach(({
1305
1324
  index: index2,
1306
1325
  newNode
@@ -1315,19 +1334,16 @@ const UpdateOnDemand = /* @__PURE__ */ vue.defineComponent({
1315
1334
  });
1316
1335
  };
1317
1336
  vue.watch(() => props.html, (newHtml, oldHtml) => {
1318
- const updates = compareHtml(newHtml, oldHtml || "");
1319
- updateHtmlContent(updates);
1320
- }, {
1321
- immediate: true
1322
- });
1323
- vue.onMounted(() => {
1324
- if (htmlContainer.value) {
1325
- htmlContainer.value.innerHTML = props.html;
1326
- }
1337
+ const {
1338
+ updates,
1339
+ deletes
1340
+ } = compareHtml(newHtml, oldHtml || "");
1341
+ updateHtmlContent(updates, deletes);
1327
1342
  });
1328
1343
  return () => vue.createVNode("div", {
1329
1344
  "id": `${editorId}-preview`,
1330
1345
  "class": [`${config.prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${config.prefix}-scrn`],
1346
+ "innerHTML": firstHtml.value,
1331
1347
  "ref": htmlContainer
1332
1348
  }, null);
1333
1349
  }
@@ -1337,8 +1353,6 @@ const ContentPreview = /* @__PURE__ */ vue.defineComponent({
1337
1353
  props: contentPreviewProps,
1338
1354
  setup(props) {
1339
1355
  const editorId = vue.inject("editorId");
1340
- const previewTheme = vue.inject("previewTheme");
1341
- const showCodeRowNumber = vue.inject("showCodeRowNumber");
1342
1356
  const {
1343
1357
  html,
1344
1358
  key
@@ -1352,14 +1366,9 @@ const ContentPreview = /* @__PURE__ */ vue.defineComponent({
1352
1366
  "id": `${editorId}-preview-wrapper`,
1353
1367
  "class": `${config.prefix}-preview-wrapper`,
1354
1368
  "key": "content-preview-wrapper"
1355
- }, [props.htmlUpdateOnDemand ? vue.createVNode(UpdateOnDemand, {
1369
+ }, [vue.createVNode(UpdateOnDemand, {
1356
1370
  "key": key.value,
1357
1371
  "html": html.value
1358
- }, null) : vue.createVNode("div", {
1359
- "key": key.value,
1360
- "id": `${editorId}-preview`,
1361
- "class": [`${config.prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${config.prefix}-scrn`],
1362
- "innerHTML": html.value
1363
1372
  }, null)]), !props.previewOnly && props.setting.htmlPreview && vue.createVNode("div", {
1364
1373
  "id": `${editorId}-html-wrapper`,
1365
1374
  "class": `${config.prefix}-preview-wrapper`,
@@ -2006,13 +2015,6 @@ const mdPreviewProps = {
2006
2015
  onRemount: {
2007
2016
  type: Function,
2008
2017
  default: void 0
2009
- },
2010
- /**
2011
- * 是否同单层对比,选择性的更新变化的html,流式内容推荐(AI吐字之类的)
2012
- */
2013
- htmlUpdateOnDemand: {
2014
- type: Boolean,
2015
- default: false
2016
2018
  }
2017
2019
  };
2018
2020
  const editorProps = {
@@ -2391,8 +2393,7 @@ const MdPreview = /* @__PURE__ */ vue.defineComponent({
2391
2393
  var _a;
2392
2394
  (_a = props.onRemount) == null ? void 0 : _a.call(props);
2393
2395
  ctx.emit("onRemount");
2394
- },
2395
- "htmlUpdateOnDemand": props.htmlUpdateOnDemand
2396
+ }
2396
2397
  }, null)]);
2397
2398
  };
2398
2399
  }
@@ -2894,8 +2894,7 @@ const Content = /* @__PURE__ */ defineComponent({
2894
2894
  "sanitizeMermaid": props2.sanitizeMermaid,
2895
2895
  "codeFoldable": props2.codeFoldable,
2896
2896
  "autoFoldThreshold": props2.autoFoldThreshold,
2897
- "onRemount": props2.onRemount,
2898
- "htmlUpdateOnDemand": props2.htmlUpdateOnDemand
2897
+ "onRemount": props2.onRemount
2899
2898
  }, null)]), props2.catalogVisible && createVNode(MdCatalog, {
2900
2899
  "theme": props2.theme,
2901
2900
  "class": `${prefix}-catalog-editor ${prefix}-catalog-${props2.catalogLayout}`,
@@ -3239,8 +3238,7 @@ const Editor = /* @__PURE__ */ defineComponent({
3239
3238
  (_a = props2.onRemount) == null ? void 0 : _a.call(props2);
3240
3239
  ctx.emit("onRemount");
3241
3240
  },
3242
- "catalogLayout": props2.catalogLayout,
3243
- "htmlUpdateOnDemand": props2.htmlUpdateOnDemand
3241
+ "catalogLayout": props2.catalogLayout
3244
3242
  }, null), props2.footers.length > 0 && createVNode(Footer, {
3245
3243
  "modelValue": props2.modelValue,
3246
3244
  "footers": props2.footers,
@@ -1184,9 +1184,6 @@ const contentPreviewProps = {
1184
1184
  },
1185
1185
  onRemount: {
1186
1186
  type: Function
1187
- },
1188
- htmlUpdateOnDemand: {
1189
- type: Boolean
1190
1187
  }
1191
1188
  };
1192
1189
  const contentProps = {
@@ -1277,14 +1274,30 @@ const splitHtml = (html) => {
1277
1274
  const compareHtml = (newHtml, currentHtml) => {
1278
1275
  const newNodes = splitHtml(newHtml);
1279
1276
  const currentNodes = splitHtml(currentHtml);
1280
- return newNodes.map((node, index) => {
1281
- var _a;
1282
- return {
1283
- index,
1284
- newNode: node.outerHTML,
1285
- isUpdated: ((_a = currentNodes[index]) == null ? void 0 : _a.outerHTML) !== node.outerHTML
1286
- };
1287
- }).filter((update) => update.isUpdated);
1277
+ const updates = [];
1278
+ const deletes = [];
1279
+ newNodes.forEach((node, index) => {
1280
+ if (!currentNodes[index]) {
1281
+ updates.push({
1282
+ index,
1283
+ newNode: node.outerHTML
1284
+ });
1285
+ } else if (currentNodes[index].outerHTML !== node.outerHTML) {
1286
+ updates.push({
1287
+ index,
1288
+ newNode: node.outerHTML
1289
+ });
1290
+ }
1291
+ });
1292
+ if (currentNodes.length > newNodes.length) {
1293
+ for (let i = newNodes.length; i < currentNodes.length; i++) {
1294
+ deletes.push(i);
1295
+ }
1296
+ }
1297
+ return {
1298
+ updates,
1299
+ deletes
1300
+ };
1288
1301
  };
1289
1302
  const UpdateOnDemand = /* @__PURE__ */ defineComponent({
1290
1303
  name: "UpdateOnDemand",
@@ -1298,8 +1311,14 @@ const UpdateOnDemand = /* @__PURE__ */ defineComponent({
1298
1311
  const editorId = inject("editorId");
1299
1312
  const previewTheme = inject("previewTheme");
1300
1313
  const showCodeRowNumber = inject("showCodeRowNumber");
1301
- const htmlContainer = ref(null);
1302
- const updateHtmlContent = (updates) => {
1314
+ const htmlContainer = ref();
1315
+ const firstHtml = ref(props.html);
1316
+ const updateHtmlContent = (updates, deletes) => {
1317
+ if (!htmlContainer.value) return;
1318
+ deletes.reverse().forEach((index) => {
1319
+ var _a, _b;
1320
+ (_b = (_a = htmlContainer.value) == null ? void 0 : _a.children[index]) == null ? void 0 : _b.remove();
1321
+ });
1303
1322
  updates.forEach(({
1304
1323
  index,
1305
1324
  newNode
@@ -1314,19 +1333,16 @@ const UpdateOnDemand = /* @__PURE__ */ defineComponent({
1314
1333
  });
1315
1334
  };
1316
1335
  watch(() => props.html, (newHtml, oldHtml) => {
1317
- const updates = compareHtml(newHtml, oldHtml || "");
1318
- updateHtmlContent(updates);
1319
- }, {
1320
- immediate: true
1321
- });
1322
- onMounted(() => {
1323
- if (htmlContainer.value) {
1324
- htmlContainer.value.innerHTML = props.html;
1325
- }
1336
+ const {
1337
+ updates,
1338
+ deletes
1339
+ } = compareHtml(newHtml, oldHtml || "");
1340
+ updateHtmlContent(updates, deletes);
1326
1341
  });
1327
1342
  return () => createVNode("div", {
1328
1343
  "id": `${editorId}-preview`,
1329
1344
  "class": [`${prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${prefix}-scrn`],
1345
+ "innerHTML": firstHtml.value,
1330
1346
  "ref": htmlContainer
1331
1347
  }, null);
1332
1348
  }
@@ -1336,8 +1352,6 @@ const ContentPreview = /* @__PURE__ */ defineComponent({
1336
1352
  props: contentPreviewProps,
1337
1353
  setup(props) {
1338
1354
  const editorId = inject("editorId");
1339
- const previewTheme = inject("previewTheme");
1340
- const showCodeRowNumber = inject("showCodeRowNumber");
1341
1355
  const {
1342
1356
  html,
1343
1357
  key
@@ -1351,14 +1365,9 @@ const ContentPreview = /* @__PURE__ */ defineComponent({
1351
1365
  "id": `${editorId}-preview-wrapper`,
1352
1366
  "class": `${prefix}-preview-wrapper`,
1353
1367
  "key": "content-preview-wrapper"
1354
- }, [props.htmlUpdateOnDemand ? createVNode(UpdateOnDemand, {
1368
+ }, [createVNode(UpdateOnDemand, {
1355
1369
  "key": key.value,
1356
1370
  "html": html.value
1357
- }, null) : createVNode("div", {
1358
- "key": key.value,
1359
- "id": `${editorId}-preview`,
1360
- "class": [`${prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${prefix}-scrn`],
1361
- "innerHTML": html.value
1362
1371
  }, null)]), !props.previewOnly && props.setting.htmlPreview && createVNode("div", {
1363
1372
  "id": `${editorId}-html-wrapper`,
1364
1373
  "class": `${prefix}-preview-wrapper`,
@@ -2005,13 +2014,6 @@ const mdPreviewProps = {
2005
2014
  onRemount: {
2006
2015
  type: Function,
2007
2016
  default: void 0
2008
- },
2009
- /**
2010
- * 是否同单层对比,选择性的更新变化的html,流式内容推荐(AI吐字之类的)
2011
- */
2012
- htmlUpdateOnDemand: {
2013
- type: Boolean,
2014
- default: false
2015
2017
  }
2016
2018
  };
2017
2019
  const editorProps = {
@@ -2390,8 +2392,7 @@ const MdPreview = /* @__PURE__ */ defineComponent({
2390
2392
  var _a;
2391
2393
  (_a = props.onRemount) == null ? void 0 : _a.call(props);
2392
2394
  ctx.emit("onRemount");
2393
- },
2394
- "htmlUpdateOnDemand": props.htmlUpdateOnDemand
2395
+ }
2395
2396
  }, null)]);
2396
2397
  };
2397
2398
  }
@@ -245,7 +245,6 @@ declare const Editor: import("vue").DefineComponent<{
245
245
  readonly sanitizeMermaid: (h: string) => Promise<string>;
246
246
  readonly codeFoldable: boolean;
247
247
  readonly autoFoldThreshold: number;
248
- readonly htmlUpdateOnDemand: boolean;
249
248
  readonly onChange: import("./type").ChangeEvent | undefined;
250
249
  readonly onSave: import("./type").SaveEvent | undefined;
251
250
  readonly onUploadImg: import("./type").UploadImgEvent | undefined;
@@ -515,7 +514,6 @@ declare const Editor: import("vue").DefineComponent<{
515
514
  readonly sanitizeMermaid: (h: string) => Promise<string>;
516
515
  readonly codeFoldable: boolean;
517
516
  readonly autoFoldThreshold: number;
518
- readonly htmlUpdateOnDemand: boolean;
519
517
  readonly onChange: import("./type").ChangeEvent | undefined;
520
518
  readonly onSave: import("./type").SaveEvent | undefined;
521
519
  readonly onUploadImg: import("./type").UploadImgEvent | undefined;
@@ -616,6 +614,5 @@ declare const Editor: import("vue").DefineComponent<{
616
614
  sanitizeMermaid: (h: string) => Promise<string>;
617
615
  codeFoldable: boolean;
618
616
  autoFoldThreshold: number;
619
- htmlUpdateOnDemand: boolean;
620
617
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
621
618
  export default Editor;
@@ -20,7 +20,6 @@ declare const ContentPreview: import("vue").DefineComponent<{
20
20
  readonly sanitizeMermaid: ((h: string) => Promise<string>) | undefined;
21
21
  readonly codeFoldable: boolean | undefined;
22
22
  readonly autoFoldThreshold: number | undefined;
23
- readonly htmlUpdateOnDemand: boolean | undefined;
24
23
  }, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
25
24
  readonly previewOnly: boolean;
26
25
  readonly onChange: (v: string) => void;
@@ -39,7 +38,6 @@ declare const ContentPreview: import("vue").DefineComponent<{
39
38
  readonly sanitizeMermaid: ((h: string) => Promise<string>) | undefined;
40
39
  readonly codeFoldable: boolean | undefined;
41
40
  readonly autoFoldThreshold: number | undefined;
42
- readonly htmlUpdateOnDemand: boolean | undefined;
43
41
  }> & Readonly<{}>, {
44
42
  previewOnly: boolean;
45
43
  onChange: (v: string) => void;
@@ -32,7 +32,6 @@ declare const _default: import("vue").DefineComponent<{
32
32
  readonly sanitizeMermaid: ((h: string) => Promise<string>) | undefined;
33
33
  readonly codeFoldable: boolean | undefined;
34
34
  readonly autoFoldThreshold: number | undefined;
35
- readonly htmlUpdateOnDemand: boolean | undefined;
36
35
  readonly autofocus: boolean | undefined;
37
36
  readonly catalogVisible: boolean | undefined;
38
37
  readonly readonly: boolean | undefined;
@@ -71,7 +70,6 @@ declare const _default: import("vue").DefineComponent<{
71
70
  readonly sanitizeMermaid: ((h: string) => Promise<string>) | undefined;
72
71
  readonly codeFoldable: boolean | undefined;
73
72
  readonly autoFoldThreshold: number | undefined;
74
- readonly htmlUpdateOnDemand: boolean | undefined;
75
73
  readonly autofocus: boolean | undefined;
76
74
  readonly catalogVisible: boolean | undefined;
77
75
  readonly readonly: boolean | undefined;
@@ -68,9 +68,6 @@ export declare const contentPreviewProps: {
68
68
  onRemount: {
69
69
  type: PropType<() => void>;
70
70
  };
71
- htmlUpdateOnDemand: {
72
- type: PropType<boolean>;
73
- };
74
71
  };
75
72
  export declare const contentProps: {
76
73
  updateModelValue: {
@@ -211,8 +208,5 @@ export declare const contentProps: {
211
208
  onRemount: {
212
209
  type: PropType<() => void>;
213
210
  };
214
- htmlUpdateOnDemand: {
215
- type: PropType<boolean>;
216
- };
217
211
  };
218
212
  export type ContentProps = Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof contentProps>>>>;
@@ -229,13 +229,6 @@ export declare const mdPreviewProps: {
229
229
  type: PropType<() => void>;
230
230
  default: undefined;
231
231
  };
232
- /**
233
- * 是否同单层对比,选择性的更新变化的html,流式内容推荐(AI吐字之类的)
234
- */
235
- htmlUpdateOnDemand: {
236
- type: PropType<boolean>;
237
- default: boolean;
238
- };
239
232
  };
240
233
  export declare const editorProps: {
241
234
  /**
@@ -747,13 +740,6 @@ export declare const editorProps: {
747
740
  type: PropType<() => void>;
748
741
  default: undefined;
749
742
  };
750
- /**
751
- * 是否同单层对比,选择性的更新变化的html,流式内容推荐(AI吐字之类的)
752
- */
753
- htmlUpdateOnDemand: {
754
- type: PropType<boolean>;
755
- default: boolean;
756
- };
757
743
  };
758
744
  export declare const mdPreviewEmits: EditorEmits;
759
745
  export declare const editorEmits: EditorEmits;
@@ -225,7 +225,6 @@ declare const MdPreview: import("vue").DefineComponent<{
225
225
  readonly sanitizeMermaid: (h: string) => Promise<string>;
226
226
  readonly codeFoldable: boolean;
227
227
  readonly autoFoldThreshold: number;
228
- readonly htmlUpdateOnDemand: boolean;
229
228
  readonly onChange: import("../MdEditor/type").ChangeEvent | undefined;
230
229
  readonly onHtmlChanged: import("../MdEditor/type").HtmlChangedEvent | undefined;
231
230
  readonly onGetCatalog: import("../MdEditor/type").GetCatalogEvent | undefined;
@@ -459,7 +458,6 @@ declare const MdPreview: import("vue").DefineComponent<{
459
458
  readonly sanitizeMermaid: (h: string) => Promise<string>;
460
459
  readonly codeFoldable: boolean;
461
460
  readonly autoFoldThreshold: number;
462
- readonly htmlUpdateOnDemand: boolean;
463
461
  readonly onChange: import("../MdEditor/type").ChangeEvent | undefined;
464
462
  readonly onHtmlChanged: import("../MdEditor/type").HtmlChangedEvent | undefined;
465
463
  readonly onGetCatalog: import("../MdEditor/type").GetCatalogEvent | undefined;
@@ -508,6 +506,5 @@ declare const MdPreview: import("vue").DefineComponent<{
508
506
  sanitizeMermaid: (h: string) => Promise<string>;
509
507
  codeFoldable: boolean;
510
508
  autoFoldThreshold: number;
511
- htmlUpdateOnDemand: boolean;
512
509
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
513
510
  export default MdPreview;