md-editor-v3 2.6.0 → 2.7.0-beta.0

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.
@@ -3273,10 +3273,10 @@ class Tokenizer {
3273
3273
  if (!nextChar || nextChar && (prevChar === "" || this.rules.inline.punctuation.exec(prevChar))) {
3274
3274
  const lLength = match[0].length - 1;
3275
3275
  let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
3276
- const endReg = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
3277
- endReg.lastIndex = 0;
3276
+ const endReg2 = match[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
3277
+ endReg2.lastIndex = 0;
3278
3278
  maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
3279
- while ((match = endReg.exec(maskedSrc)) != null) {
3279
+ while ((match = endReg2.exec(maskedSrc)) != null) {
3280
3280
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
3281
3281
  if (!rDelim)
3282
3282
  continue;
@@ -5143,7 +5143,7 @@ const splitHelp = (textarea) => {
5143
5143
  };
5144
5144
  };
5145
5145
  const directive2flag = (direct, selectedText = "", inputArea, params) => {
5146
- var _a, _b, _c, _d, _e;
5146
+ var _a, _b, _c, _d, _e, _f;
5147
5147
  let targetValue = "";
5148
5148
  let deviationStart = 0;
5149
5149
  let deviationEnd = 0;
@@ -5159,8 +5159,8 @@ const directive2flag = (direct, selectedText = "", inputArea, params) => {
5159
5159
  deviationStart = pix.length + 1;
5160
5160
  } else if (direct === "prettier") {
5161
5161
  const prettier = window.prettier || ((_c = (_b = configOption.editorExtensions) == null ? void 0 : _b.prettier) == null ? void 0 : _c.prettierInstance);
5162
- const prettierPlugins = window.prettierPlugins || [
5163
- (_e = (_d = configOption.editorExtensions) == null ? void 0 : _d.prettier) == null ? void 0 : _e.parserMarkdownInstance
5162
+ const prettierPlugins = [
5163
+ ((_d = window.prettierPlugins) == null ? void 0 : _d.markdown) || ((_f = (_e = configOption.editorExtensions) == null ? void 0 : _e.prettier) == null ? void 0 : _f.parserMarkdownInstance)
5164
5164
  ];
5165
5165
  if (!prettier || prettierPlugins[0] === void 0) {
5166
5166
  bus.emit(params.editorId, "errorCatcher", {
@@ -5574,6 +5574,80 @@ var kaTexExtensions = {
5574
5574
  };
5575
5575
  }
5576
5576
  };
5577
+ const alertTypes = [
5578
+ "abstract",
5579
+ "attention",
5580
+ "bug",
5581
+ "caution",
5582
+ "danger",
5583
+ "error",
5584
+ "example",
5585
+ "failure",
5586
+ "hint",
5587
+ "info",
5588
+ "note",
5589
+ "question",
5590
+ "quote",
5591
+ "success",
5592
+ "tip",
5593
+ "warning"
5594
+ ];
5595
+ const startReg = new RegExp(`^!!!\\s+(${alertTypes.join("|")})\\s+(.*)$`);
5596
+ const endReg = /^!!!\s*$/;
5597
+ const Alert = {
5598
+ name: "alert",
5599
+ level: "block",
5600
+ start(src) {
5601
+ var _a;
5602
+ const index2 = (_a = src.match(new RegExp(`(^|[\\r\\n])!!!\\s+(${alertTypes.join("|")})\\s+(.*)`))) == null ? void 0 : _a.index;
5603
+ return index2;
5604
+ },
5605
+ tokenizer(src) {
5606
+ const lines = src.split(/\n/);
5607
+ if (startReg.test(lines[0])) {
5608
+ const section = { x: -1, y: -1 };
5609
+ const sections = [];
5610
+ for (let i = 0, k = lines.length; i < k; i++) {
5611
+ if (startReg.test(lines[i])) {
5612
+ section.x = i;
5613
+ } else if (endReg.test(lines[i])) {
5614
+ section.y = i;
5615
+ if (section.x >= 0) {
5616
+ sections.push(__spreadValues({}, section));
5617
+ section.x = -1;
5618
+ section.y = -1;
5619
+ }
5620
+ }
5621
+ }
5622
+ if (sections.length) {
5623
+ const section2 = sections[0];
5624
+ const [_, icon, title] = startReg.exec(lines[section2.x]) || [];
5625
+ const text = lines.slice(section2.x + 1, section2.y).join("\n");
5626
+ const raw = lines.slice(section2.x, section2.y + 1).join("\n");
5627
+ const token = {
5628
+ type: "alert",
5629
+ raw,
5630
+ icon,
5631
+ title,
5632
+ text,
5633
+ titleTokens: [],
5634
+ tokens: [],
5635
+ childTokens: ["title", "text"]
5636
+ };
5637
+ this.lexer.inlineTokens(token.title, token.titleTokens);
5638
+ this.lexer.blockTokens(token.text, token.tokens);
5639
+ return token;
5640
+ }
5641
+ }
5642
+ },
5643
+ renderer(token) {
5644
+ const html = `<div class="md-editor-alert md-editor-alert-${token.icon}">
5645
+ <p class="md-editor-alert-title">${this.parser.parseInline(token.titleTokens, null)}</p>
5646
+ ${this.parser.parse(token.tokens)}
5647
+ </div>`;
5648
+ return html;
5649
+ }
5650
+ };
5577
5651
  const useHistory = (props, textAreaRef, completeStatus) => {
5578
5652
  var _a, _b;
5579
5653
  const previewOnly = inject("previewOnly");
@@ -5699,6 +5773,9 @@ const useMarked = (props, mermaidData) => {
5699
5773
  const katexInited = ref(false);
5700
5774
  const heads = ref([]);
5701
5775
  let renderer = new marked.Renderer();
5776
+ marked.use({
5777
+ extensions: [Alert]
5778
+ });
5702
5779
  const markedCode = renderer.code;
5703
5780
  renderer.code = (code, language, isEscaped) => {
5704
5781
  if (!props.noMermaid && language === "mermaid") {
@@ -6581,8 +6658,6 @@ const MdCatalog = defineComponent({
6581
6658
  })]);
6582
6659
  }
6583
6660
  });
6584
- var index = "";
6585
- var all = "";
6586
6661
  const editorProps = () => ({
6587
6662
  modelValue: {
6588
6663
  type: String,
@@ -6747,6 +6822,9 @@ const editorProps = () => ({
6747
6822
  }
6748
6823
  });
6749
6824
  const markedHeadingId = (text) => text;
6825
+ var index = "";
6826
+ var alert = "";
6827
+ var all = "";
6750
6828
  const Editor = defineComponent({
6751
6829
  name: "MdEditorV3",
6752
6830
  props: editorProps(),