From 063c533a2931926a03f4189e981378295f253166 Mon Sep 17 00:00:00 2001 From: Libin YANG Date: Fri, 13 Dec 2024 06:29:04 +0000 Subject: [PATCH] fix: remove label `p` in label `span` --- .../CodemirrorEditor/EditorHeader/index.vue | 164 +++++------------- 1 file changed, 45 insertions(+), 119 deletions(-) diff --git a/src/components/CodemirrorEditor/EditorHeader/index.vue b/src/components/CodemirrorEditor/EditorHeader/index.vue index c528a9e04..00c77bd6e 100644 --- a/src/components/CodemirrorEditor/EditorHeader/index.vue +++ b/src/components/CodemirrorEditor/EditorHeader/index.vue @@ -126,6 +126,7 @@ function copy() { .replaceAll(`var(--blockquote-background)`, `#f7f7f7`) .replaceAll(`var(--md-primary-color)`, primaryColor.value) .replaceAll(/--md-primary-color:.+?;/g, ``) + .replace(/]*)>]*>(.*?)<\/p><\/span>/g, `$2`) clipboardDiv.focus() @@ -139,7 +140,7 @@ function copy() { // 兼容 Mermaid const nodes = clipboardDiv.querySelectorAll(`.nodeLabel`) - for (const node of nodes) { + nodes.forEach((node) => { const parent = node.parentElement! const xmlns = parent.getAttribute(`xmlns`)! const style = parent.getAttribute(`style`)! @@ -147,10 +148,11 @@ function copy() { section.setAttribute(`xmlns`, xmlns) section.setAttribute(`style`, style) section.innerHTML = parent.innerHTML + const grand = parent.parentElement! - grand.innerHTML = `` - grand.appendChild(section) - } + grand.innerHTML = `` // 清空父元素的内容 + grand.appendChild(section) // 将新的 section 添加到父元素 + }) window.getSelection()!.removeAllRanges() const range = document.createRange() @@ -198,8 +200,7 @@ function customStyle() { 格式 @@ -236,14 +237,9 @@ function customStyle() {

主题

@@ -253,10 +249,7 @@ function customStyle() {

字体

@@ -285,18 +273,12 @@ function customStyle() {

主题色

@@ -359,22 +324,16 @@ function customStyle() {

Mac 代码块

@@ -384,22 +343,16 @@ function customStyle() {

微信外链转底部引用

@@ -409,22 +362,16 @@ function customStyle() {

段落首行缩进

@@ -434,22 +381,16 @@ function customStyle() {

自定义 CSS 面板

@@ -459,22 +400,16 @@ function customStyle() {

编辑区位置

@@ -484,22 +419,16 @@ function customStyle() {

模式

@@ -508,10 +437,7 @@ function customStyle() {

样式配置

-