md-editor-v3 4.15.1-2 → 4.15.1-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.
@@ -12,7 +12,6 @@ const TaskListPlugin = require("markdown-it-task-lists");
12
12
  const XSSPlugin = require("markdown-it-xss");
13
13
  const index = require("./index4.cjs");
14
14
  const lruCache = require("lru-cache");
15
- const markdownIt = require("~/utils/markdown-it");
16
15
  const userZoom = (props, html) => {
17
16
  const editorId = vue.inject("editorId");
18
17
  const { noImgZoomIn } = props;
@@ -265,6 +264,19 @@ const MermaidPlugin = (md, options) => {
265
264
  };
266
265
  };
267
266
  const MermaidPlugin$1 = MermaidPlugin;
267
+ const mergeAttrs = (token, addAttrs) => {
268
+ const tmpAttrs = token.attrs ? token.attrs.slice() : [];
269
+ addAttrs.forEach((addAttr) => {
270
+ const i = token.attrIndex(addAttr[0]);
271
+ if (i < 0) {
272
+ tmpAttrs.push(addAttr);
273
+ } else {
274
+ tmpAttrs[i] = tmpAttrs[i].slice();
275
+ tmpAttrs[i][1] += ` ${addAttr[1]}`;
276
+ }
277
+ });
278
+ return tmpAttrs;
279
+ };
268
280
  const isValidDelim = (state, pos) => {
269
281
  let can_open = true, can_close = true;
270
282
  const max = state.posMax;
@@ -381,7 +393,7 @@ const KatexPlugin = (md, { katexRef }) => {
381
393
  const katexInline = (tokens, idx, options, env, slf) => {
382
394
  const token = tokens[idx];
383
395
  const tmpToken = {
384
- attrs: markdownIt.mergeAttrs(token, [["class", `${config.prefix}-katex-inline`]])
396
+ attrs: mergeAttrs(token, [["class", `${config.prefix}-katex-inline`]])
385
397
  };
386
398
  if (katexRef.value) {
387
399
  const html = katexRef.value.renderToString(token.content, {
@@ -395,7 +407,7 @@ const KatexPlugin = (md, { katexRef }) => {
395
407
  const katexBlock = (tokens, idx, options, env, slf) => {
396
408
  const token = tokens[idx];
397
409
  const tmpToken = {
398
- attrs: markdownIt.mergeAttrs(token, [["class", `${config.prefix}-katex-block`]])
410
+ attrs: mergeAttrs(token, [["class", `${config.prefix}-katex-block`]])
399
411
  };
400
412
  if (katexRef.value) {
401
413
  const html = katexRef.value.renderToString(token.content, {
@@ -590,7 +602,7 @@ const codetabs = (md, _opts) => {
590
602
  const addAttrs2 = [["class", `${config.prefix}-code`]];
591
603
  open2 && addAttrs2.push(["open", ""]);
592
604
  const tmpToken2 = {
593
- attrs: markdownIt.mergeAttrs(tokens[idx], addAttrs2)
605
+ attrs: mergeAttrs(tokens[idx], addAttrs2)
594
606
  };
595
607
  const codeRendered = defaultRender(tokens, idx, options, env, slf);
596
608
  return `<${tagContainer2} ${slf.renderAttrs(tmpToken2)}>
@@ -611,7 +623,7 @@ const codetabs = (md, _opts) => {
611
623
  const addAttrs = [["class", `${config.prefix}-code`]];
612
624
  open && addAttrs.push(["open", ""]);
613
625
  const tmpToken = {
614
- attrs: markdownIt.mergeAttrs(tokens[idx], addAttrs)
626
+ attrs: mergeAttrs(tokens[idx], addAttrs)
615
627
  };
616
628
  for (let i = idx; i < tokens.length; i++) {
617
629
  token = tokens[i];
@@ -11,7 +11,6 @@ import TaskListPlugin from "markdown-it-task-lists";
11
11
  import XSSPlugin from "markdown-it-xss";
12
12
  import { b as generateCodeRowNumber, c as getNextId } from "./index4.mjs";
13
13
  import { LRUCache } from "lru-cache";
14
- import { mergeAttrs } from "~/utils/markdown-it";
15
14
  const userZoom = (props, html) => {
16
15
  const editorId = inject("editorId");
17
16
  const { noImgZoomIn } = props;
@@ -264,6 +263,19 @@ const MermaidPlugin = (md, options) => {
264
263
  };
265
264
  };
266
265
  const MermaidPlugin$1 = MermaidPlugin;
266
+ const mergeAttrs = (token, addAttrs) => {
267
+ const tmpAttrs = token.attrs ? token.attrs.slice() : [];
268
+ addAttrs.forEach((addAttr) => {
269
+ const i = token.attrIndex(addAttr[0]);
270
+ if (i < 0) {
271
+ tmpAttrs.push(addAttr);
272
+ } else {
273
+ tmpAttrs[i] = tmpAttrs[i].slice();
274
+ tmpAttrs[i][1] += ` ${addAttr[1]}`;
275
+ }
276
+ });
277
+ return tmpAttrs;
278
+ };
267
279
  const isValidDelim = (state, pos) => {
268
280
  let can_open = true, can_close = true;
269
281
  const max = state.posMax;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-editor-v3",
3
- "version": "4.15.1-2",
3
+ "version": "4.15.1-3",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "vue",