Skip to content

Commit

Permalink
refactor: replace the syntax: <sub> with ~~, and <sup> with ^^
Browse files Browse the repository at this point in the history
  • Loading branch information
imzbf committed Sep 3, 2024
1 parent d76b945 commit cc18d7d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
"lru-cache": "^10.2.0",
"markdown-it": "^14.0.0",
"markdown-it-image-figures": "^2.1.1",
"markdown-it-sub": "^2.0.0",
"markdown-it-sup": "^2.0.0",
"medium-zoom": "^1.1.0",
"punycode": "^2.3.1",
"xss": "^1.0.15"
Expand Down
3 changes: 2 additions & 1 deletion packages/MdEditor/layouts/Content/composition/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare module 'markdown-it-image-figures';
declare module 'markdown-it-task-lists';
declare module 'markdown-it-codetabs';
declare module 'markdown-it-xss';
declare module 'markdown-it-sub';
declare module 'markdown-it-sup';
12 changes: 12 additions & 0 deletions packages/MdEditor/layouts/Content/composition/useMarkdownIt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
} from 'vue';
import mdit from 'markdown-it';
import ImageFiguresPlugin from 'markdown-it-image-figures';
import SubPlugin from 'markdown-it-sub';
import SupPlugin from 'markdown-it-sup';
import { debounce, randomId } from '@vavt/util';
import bus from '~/utils/event-bus';
import { generateCodeRowNumber } from '~/utils';
Expand Down Expand Up @@ -124,6 +126,16 @@ const useMarkdownIt = (props: ContentPreviewProps, previewOnly: boolean) => {
type: 'xss',
plugin: XSSPlugin,
options: {} as XSSPluginType
},
{
type: 'sub',
plugin: SubPlugin,
options: {}
},
{
type: 'sup',
plugin: SupPlugin,
options: {}
}
];

Expand Down
12 changes: 6 additions & 6 deletions packages/MdEditor/utils/content-help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ export const directive2flag = async (
break;
}
case 'sub': {
targetValue = `<sub>${selectedText}</sub>`;
deviationStart = 5;
deviationEnd = -6;
targetValue = `~${selectedText}~`;
deviationStart = 1;
deviationEnd = -1;
break;
}
case 'sup': {
targetValue = `<sup>${selectedText}</sup>`;
deviationStart = 5;
deviationEnd = -6;
targetValue = `^${selectedText}^`;
deviationStart = 1;
deviationEnd = -1;
break;
}
case 'codeRow': {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2804,6 +2804,16 @@ markdown-it-image-figures@^2.1.1:
resolved "https://registry.npmjs.org/markdown-it-image-figures/-/markdown-it-image-figures-2.1.1.tgz#fd32a2d0cec60ed8c3916d74fea70d5f9b56e4c7"
integrity sha512-mwXSQ2nPeVUzCMIE3HlLvjRioopiqyJLNph0pyx38yf9mpqFDhNGnMpAXF9/A2Xv0oiF2cVyg9xwfF0HNAz05g==

markdown-it-sub@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/markdown-it-sub/-/markdown-it-sub-2.0.0.tgz#10f6c7bbf2faacf71ae1a64c75009c40ef9b2c94"
integrity sha512-iCBKgwCkfQBRg2vApy9vx1C1Tu6D8XYo8NvevI3OlwzBRmiMtsJ2sXupBgEA7PPxiDwNni3qIUkhZ6j5wofDUA==

markdown-it-sup@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/markdown-it-sup/-/markdown-it-sup-2.0.0.tgz#683b9390929f3024fcd5291799c466ce3d367f44"
integrity sha512-5VgmdKlkBd8sgXuoDoxMpiU+BiEt3I49GItBzzw7Mxq9CxvnhE/k09HFli09zgfFDRixDQDfDxi0mgBCXtaTvA==

markdown-it@^14.0.0:
version "14.1.0"
resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz#3c3c5992883c633db4714ccb4d7b5935d98b7d45"
Expand Down

0 comments on commit cc18d7d

Please sign in to comment.