cherry-muse 1.0.1 → 1.0.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.
- package/dist/cherry-markdown.core.common.js +1 -1
- package/dist/cherry-markdown.core.js +1 -1
- package/dist/cherry-markdown.engine.core.common.js +1 -1
- package/dist/cherry-markdown.engine.core.esm.js +1 -1
- package/dist/cherry-markdown.engine.core.js +1 -1
- package/dist/cherry-markdown.esm.js +1 -1
- package/dist/cherry-markdown.js +36 -38
- package/dist/cherry-markdown.js.map +1 -1
- package/dist/cherry-markdown.min.js +1 -1
- package/dist/stats.html +1 -1
- package/package.json +7 -10
- package/src/core/hooks/CodeBlock.js +11 -14
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cherry-muse",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Lightweight Cherry Markdown fork with 83% smaller bundle size (800KB vs 4.8MB)",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -46,8 +46,6 @@
|
|
|
46
46
|
"lint": "eslint --plugin file-progress --rule \"file-progress/activate: 1\" --ext .js .",
|
|
47
47
|
"lint:fix": "yarn lint --fix",
|
|
48
48
|
"lint:ci": "eslint --max-warnings=0 --ext .js .",
|
|
49
|
-
"prepare": "husky install",
|
|
50
|
-
"publish": "git push --follow-tags origin main",
|
|
51
49
|
"examples": "serve -p 3000 ."
|
|
52
50
|
},
|
|
53
51
|
"keywords": [
|
|
@@ -84,6 +82,8 @@
|
|
|
84
82
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
85
83
|
"@rollup/plugin-replace": "^2.3.1",
|
|
86
84
|
"@rollup/plugin-terser": "^0.4.3",
|
|
85
|
+
"@types/codemirror": "^0.0.108",
|
|
86
|
+
"@types/dompurify": "^2.2.3",
|
|
87
87
|
"@types/echarts": "4.9.15",
|
|
88
88
|
"@types/glob": "^7.2.0",
|
|
89
89
|
"@types/jest": "^27.0.3",
|
|
@@ -117,6 +117,9 @@
|
|
|
117
117
|
"husky": "~7.0.4",
|
|
118
118
|
"jest": "^27.5.1",
|
|
119
119
|
"jest-diff": "^27.5.1",
|
|
120
|
+
"js-base64": "^3.7.7",
|
|
121
|
+
"js-yaml": "^4.1.0",
|
|
122
|
+
"jsdom": "~19.0.0",
|
|
120
123
|
"lint-staged": "~12.5.0",
|
|
121
124
|
"lodash": "^4.17.20",
|
|
122
125
|
"md5": "^2.2.1",
|
|
@@ -141,13 +144,7 @@
|
|
|
141
144
|
"standard-version": "^9.3.2",
|
|
142
145
|
"virtual-dom": "^2.1.1"
|
|
143
146
|
},
|
|
144
|
-
"dependencies": {
|
|
145
|
-
"@types/codemirror": "^0.0.108",
|
|
146
|
-
"@types/dompurify": "^2.2.3",
|
|
147
|
-
"js-base64": "^3.7.7",
|
|
148
|
-
"js-yaml": "^4.1.0",
|
|
149
|
-
"jsdom": "~19.0.0"
|
|
150
|
-
},
|
|
147
|
+
"dependencies": {},
|
|
151
148
|
"resolutions": {
|
|
152
149
|
"glob-parent": "5.1.2",
|
|
153
150
|
"set-value": "4.0.1",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import ParagraphBase from '@/core/ParagraphBase';
|
|
17
17
|
import Prism from 'prismjs';
|
|
18
|
-
import { escapeHTMLSpecialChar
|
|
18
|
+
import { escapeHTMLSpecialChar } from '@/utils/sanitize';
|
|
19
19
|
import { getTableRule, getCodeBlockRule } from '@/utils/regexp';
|
|
20
20
|
import { prependLineFeedForParagraph } from '@/utils/lineFeed';
|
|
21
21
|
|
|
@@ -625,33 +625,30 @@ export default class CodeBlock extends ParagraphBase {
|
|
|
625
625
|
|
|
626
626
|
$highlightCodeBlock(code, lang, clazz) {
|
|
627
627
|
const language = lang;
|
|
628
|
-
|
|
628
|
+
// 直接使用原始代码,不做 unescapeHTMLSpecialChar,避免破坏代码完整性
|
|
629
|
+
let cacheCode = Prism.highlight(code, Prism.languages[language], language);
|
|
629
630
|
cacheCode = this.renderLineNumber(cacheCode);
|
|
630
631
|
cacheCode = this.wrapCode(cacheCode, language);
|
|
631
632
|
const cherry = this.$engine.$cherry;
|
|
632
|
-
|
|
633
|
-
setTimeout(function () {
|
|
634
|
-
console.log(clazz, cherry.wrapperDom.querySelectorAll(clazz), document.querySelectorAll(clazz));
|
|
635
|
-
}, 20000);
|
|
636
|
-
this.$waitElement(clazz, 0, function (elements) {
|
|
633
|
+
this.$waitElement(cherry.wrapperDom, clazz, 0, (elements) => {
|
|
637
634
|
elements.forEach((codeBlock) => {
|
|
638
635
|
codeBlock.innerHTML = cacheCode;
|
|
639
636
|
});
|
|
640
637
|
});
|
|
641
638
|
}
|
|
642
639
|
|
|
643
|
-
$waitElement(clazz, times, cb) {
|
|
644
|
-
const that = this;
|
|
640
|
+
$waitElement(container, clazz, times, cb) {
|
|
645
641
|
if (times > 100) {
|
|
646
|
-
console.warn(
|
|
642
|
+
console.warn(`${clazz} not found after ${times} retries`);
|
|
647
643
|
return;
|
|
648
644
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
645
|
+
const elements = container.querySelectorAll(clazz);
|
|
646
|
+
if (elements.length === 0) {
|
|
647
|
+
setTimeout(() => {
|
|
648
|
+
this.$waitElement(container, clazz, times + 1, cb);
|
|
652
649
|
}, 500);
|
|
653
650
|
} else {
|
|
654
|
-
cb(
|
|
651
|
+
cb(elements);
|
|
655
652
|
}
|
|
656
653
|
}
|
|
657
654
|
|