From b46e8f1654b88987e104c7a85c2d1dce16188388 Mon Sep 17 00:00:00 2001 From: dudu Date: Sat, 16 Dec 2023 13:11:13 +0800 Subject: [PATCH] remove: highlight lines --- package-lock.json | 17 ----------------- package.json | 9 +-------- src/markdown/markdown.entry.ts | 27 --------------------------- webpack.config.mjs | 8 ++------ 4 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 src/markdown/markdown.entry.ts diff --git a/package-lock.json b/package-lock.json index a5de3e7c..54a4d217 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "0.0.1", "license": "LICENSE.txt", "dependencies": { - "@cnblogs/code-highlight-adapter": "^1.7.1", "@cnblogs/code-quality": "^2.0.2", "@cnblogs/markdown-it-presets": "^1.10.5", "@fluentui/react": "^8.110.11", @@ -794,14 +793,6 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, - "node_modules/@cnblogs/code-highlight-adapter": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/@cnblogs/code-highlight-adapter/-/code-highlight-adapter-1.7.9.tgz", - "integrity": "sha512-OqXCyEK8vGV4uwp3P5b78zJxHWfwbD2MJHU49199Rs197axLqzXAotwDm62DGXhkj4jH/sexz3HkDo7hMkn/yw==", - "dependencies": { - "@cnblogs/load-script-css": "^1.5.1" - } - }, "node_modules/@cnblogs/code-quality": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@cnblogs/code-quality/-/code-quality-2.0.2.tgz", @@ -16452,14 +16443,6 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, - "@cnblogs/code-highlight-adapter": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/@cnblogs/code-highlight-adapter/-/code-highlight-adapter-1.7.9.tgz", - "integrity": "sha512-OqXCyEK8vGV4uwp3P5b78zJxHWfwbD2MJHU49199Rs197axLqzXAotwDm62DGXhkj4jH/sexz3HkDo7hMkn/yw==", - "requires": { - "@cnblogs/load-script-css": "^1.5.1" - } - }, "@cnblogs/code-quality": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@cnblogs/code-quality/-/code-quality-2.0.2.tgz", diff --git a/package.json b/package.json index 9d5d02c2..a34459a1 100644 --- a/package.json +++ b/package.json @@ -41,13 +41,7 @@ ], "main": "./dist/extension.js", "contributes": { - "markdown.markdownItPlugins": true, - "markdown.previewScripts": [ - "./dist/markdown.js" - ], - "markdown.previewStyles": [ - "./dist/assets/styles/highlight-code-lines.css" - ], + "markdown.markdownItPlugins": true, "icons": { "vscode-cnb-date": { "description": "date", @@ -1381,7 +1375,6 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@cnblogs/code-highlight-adapter": "^1.7.1", "@cnblogs/code-quality": "^2.0.2", "@cnblogs/markdown-it-presets": "^1.10.5", "@fluentui/react": "^8.110.11", diff --git a/src/markdown/markdown.entry.ts b/src/markdown/markdown.entry.ts deleted file mode 100644 index 2066bb00..00000000 --- a/src/markdown/markdown.entry.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -import { HighlightersFactory, HljsHighlighter } from '@cnblogs/code-highlight-adapter' - -HighlightersFactory.configCodeHighlightOptions({ enableCodeLineNumber: false }) - -function highlightLines(this: void) { - const bgDefinitionStyleId = 'highlightedLineBackground' - if (document.querySelector(`#${bgDefinitionStyleId}`) === null) { - const style = document.createElement('style') - style.id = bgDefinitionStyleId - style.innerHTML = `:root { --highlighted-line-bg: var(--vscode-diffEditor-insertedTextBackground) }` - document.head.append(style) - } - - const highlighter = new HljsHighlighter() - document.querySelectorAll('pre[class*="language-"][data-lines-highlight]').forEach(preEl => { - const codeEl = preEl.querySelector('code') - if (codeEl === null) return - if (codeEl.firstChild instanceof HTMLDivElement && codeEl.children.length === 1) - codeEl.firstChild.outerHTML = codeEl.firstChild.innerHTML - highlighter.highlightLines(preEl) - }) -} - -window.addEventListener('vscode.markdown.updateContent', highlightLines) -highlightLines() diff --git a/webpack.config.mjs b/webpack.config.mjs index f4f48e0b..17ae6ef0 100644 --- a/webpack.config.mjs +++ b/webpack.config.mjs @@ -52,7 +52,7 @@ export default (env, { mode }) => { target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ mode: mode, // this leaves the source code as close as possible to the original (when packaging we set this to 'production') - entry: { extension: './src/extension.ts', markdown: './src/markdown/markdown.entry.ts' }, // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ + entry: { extension: './src/extension.ts' }, // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ output: { // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ path: path.resolve(__dirname, 'dist'), @@ -104,11 +104,7 @@ export default (env, { mode }) => { //Note:- No wildcard is specified hence will copy all files and folders from: 'src/assets', //Will resolve to RepoDir/src/assets to: 'assets', //Copies all files from above dest to dist/assets - }, - { - from: 'node_modules/@cnblogs/code-highlight-adapter/index.min.css', - to: 'assets/styles/highlight-code-lines.css', - }, + }, { from: 'src/wasm/rs_bg.wasm', to: 'rs_bg.wasm',