diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e1374b8fb5a02b82b824bc031cb58af14d8d091..e768f4e0cb489fc0b6ab86d1d3aa7263e1566fec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ - 文件上传、图片上传、图片裁剪上传、html、轮播图、签名、消息占位、文件表格列组件支持启用无权限模式,上传文件夹需拼接'$'字符,也不需要计算下载凭证 - 新增行内AI工具调用信息 +- markdown新增编辑器参数tocpos,可使markdown目录相对于屏幕定位 + +### Fixed + +- 修复markdown编辑态初始时目录未呈现的问题 ## [0.7.41-alpha.43] - 2025-12-02 diff --git a/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.scss b/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.scss index 779ca93b39151a78c9ae0e0131a8a004bd2f8907..c3232b11967492e8cc964b9b2ee8788bb2db97ed 100644 --- a/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.scss +++ b/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.scss @@ -10,6 +10,8 @@ $markdown: ( color-dark-toc-text: getCssVar(color, fill, 0), color-toc-header-text: getCssVar(color, text, 0), color-dark-mardown-border: rgb(var(#{getCssVarName(grey,2)})), + color-fixed-toc-text: getCssVar(color, black), + color-fixed-toc-arrow-text: getCssVar(color, primary), spacing-manual-toolbar-height: 32px, spacing-manual-toolbar-gap: getCssVar('spacing',base), spacing-manual-toolbar-item-padding: 0 getCssVar('spacing',base), @@ -259,6 +261,18 @@ $markdown: ( border-left: none; } + .cherry-flex-toc__fixed{ + color: getCssVar(markdown, color-fixed-toc-text); + + &.cherry-flex-toc__pure .cherry-toc-head{ + color: getCssVar(markdown,color-fixed-toc-arrow-text); + } + + &:hover{ + z-index: 100; + } + } + .theme__light, .theme__dark { color: getCssVar(form-item, text-color); diff --git a/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.tsx b/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.tsx index 6ad5f2af8bdf6962a5cfaf32ebd0d5dba59d434f..3380f8e06ba085cdebcc6435421d56a268308975 100644 --- a/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.tsx +++ b/src/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.tsx @@ -122,6 +122,11 @@ const IBizMarkDown: any = defineComponent({ // AI 聊天实例 let chatInstance: any; + // 目录位置 + let tocPos: 'absolute' | 'fixed' = 'absolute'; + if (c?.editorparams?.tocpos) { + tocPos = c.editorparams.tocpos === 'fixed' ? 'fixed' : 'absolute'; + } const [AIMenu, AIChart] = initCustomMenu(c as MarkDownEditorController, { props, chatInstance, @@ -505,7 +510,7 @@ const IBizMarkDown: any = defineComponent({ updateLocationHash: false, // 要不要更新URL的hash defaultModel: 'pure', // pure: 精简模式/缩略模式,只有一排小点; full: 完整模式,会展示所有标题 showAutoNumber: true, // 是否显示自增序号 - position: 'absolute', // 悬浮目录的悬浮方式。当滚动条在cherry内部时,用absolute;当滚动条在cherry外部时,用fixed + position: tocPos, // 悬浮目录的悬浮方式。当滚动条在cherry内部时,用absolute;当滚动条在cherry外部时,用fixed cssText: '', // 自定义样式 }, }, @@ -528,6 +533,10 @@ const IBizMarkDown: any = defineComponent({ } as any); // 默认设置一次关闭目录,markdown会记录每次操作过后的状态,存在localStorage里面,不重新设置的话每次打开都会拿缓存里的状态 editor.toggleToc('pure'); + // 初始化重置一次预览区的内容,不然目录拿不到数据 + const html = editor.engine.makeHtml(currentVal.value); + editor.previewer.update(html); + editor.toc.updateTocList(); // 必须使用setTheme,否则previewer区域有样式问题 editor.setTheme(theme.value); if (customTheme) { @@ -756,6 +765,7 @@ const IBizMarkDown: any = defineComponent({ markDownBox, headers, theme, + UIStore, defaultModel, cssVars, isEditing, @@ -787,12 +797,12 @@ const IBizMarkDown: any = defineComponent({ {this.renderFooter()} {this.renderImgPreview()}