From 88c9d9c1bb7a80bf2551638299cf9859d0ff0c4a Mon Sep 17 00:00:00 2001 From: huyikai Date: Wed, 21 Feb 2024 15:57:19 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/@huyikai/local-cms/cms/package.json | 1 + .../@huyikai/local-cms/cms/src/views/Editor/index.vue | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/@huyikai/local-cms/cms/package.json b/packages/@huyikai/local-cms/cms/package.json index 8b6c806..ff26e40 100644 --- a/packages/@huyikai/local-cms/cms/package.json +++ b/packages/@huyikai/local-cms/cms/package.json @@ -43,6 +43,7 @@ "@nolebase/markdown-it-element-transform": "^1.20.1", "@rushstack/eslint-patch": "^1.1.4", "@types/jsdom": "^20.0.1", + "@types/markdown-it": "^13.0.7", "@types/markdown-it-anchor": "^7.0.0", "@types/markdown-it-attrs": "^4.1.3", "@types/markdown-it-container": "^2.0.9", diff --git a/packages/@huyikai/local-cms/cms/src/views/Editor/index.vue b/packages/@huyikai/local-cms/cms/src/views/Editor/index.vue index c53f8a0..905cd89 100644 --- a/packages/@huyikai/local-cms/cms/src/views/Editor/index.vue +++ b/packages/@huyikai/local-cms/cms/src/views/Editor/index.vue @@ -116,10 +116,12 @@ const createMarkdownItInstance = async () => { slugify, permalink: anchorPlugin.permalink.linkInsideHeader({ symbol: '​', - renderAttrs: (slug: any, state: any) => { - const idx = state.tokens.findIndex((token: any) => { + renderAttrs: (slug: string, state: any) => { + const idx = state.tokens.findIndex((token: MarkdownIt.Token) => { const attrs = token.attrs; - const id = attrs?.find((attr: any) => attr[0] === 'id'); + const id = attrs?.find( + (attr: [string, string]) => attr[0] === 'id' + ); return id && slug === id[1]; }); const title = state.tokens[idx + 1].content;