@@ -113,48 +113,50 @@ function copy() {
113
113
toggleDark ()
114
114
}
115
115
116
- solveWeChatImage ()
117
-
118
- const clipboardDiv = document .getElementById (` output` )
119
- clipboardDiv .innerHTML = mergeCss (clipboardDiv .innerHTML )
120
- clipboardDiv .innerHTML = modifyHtmlStructure (clipboardDiv .innerHTML )
121
-
122
- // 调整 katex 公式元素为行内标签,目的是兼容微信公众号渲染
123
- clipboardDiv .innerHTML = clipboardDiv .innerHTML
124
- .replace (
125
- / class="base"( style="display: inline")* / g ,
126
- ` class="base" style="display: inline"` ,
127
- )
116
+ nextTick (() => {
117
+ solveWeChatImage ()
118
+
119
+ const clipboardDiv = document .getElementById (` output` )
120
+ clipboardDiv .innerHTML = mergeCss (clipboardDiv .innerHTML )
121
+ clipboardDiv .innerHTML = modifyHtmlStructure (clipboardDiv .innerHTML )
122
+
123
+ // 调整 katex 公式元素为行内标签,目的是兼容微信公众号渲染
124
+ clipboardDiv .innerHTML = clipboardDiv .innerHTML
125
+ .replace (
126
+ / class="base"( style="display: inline")* / g ,
127
+ ` class="base" style="display: inline"` ,
128
+ )
128
129
// 公众号不支持 position, 转换为等价的 translateY
129
- .replace (/ top:(. *? )em/ g , ` transform: translateY($1em)` )
130
+ .replace (/ top:(. *? )em/ g , ` transform: translateY($1em)` )
130
131
// 适配主题中的颜色变量
131
- .replaceAll (` var(--el-text-color-regular)` , ` #3f3f3f` )
132
- clipboardDiv .focus ()
133
- window .getSelection ().removeAllRanges ()
134
- const range = document .createRange ()
135
-
136
- range .setStartBefore (clipboardDiv .firstChild )
137
- range .setEndAfter (clipboardDiv .lastChild )
138
- window .getSelection ().addRange (range)
139
- document .execCommand (` copy` )
140
- window .getSelection ().removeAllRanges ()
141
- clipboardDiv .innerHTML = output .value
142
-
143
- if (isBeforeDark) {
144
- toggleDark ()
145
- }
132
+ .replaceAll (` var(--el-text-color-regular)` , ` #3f3f3f` )
133
+ clipboardDiv .focus ()
134
+ window .getSelection ().removeAllRanges ()
135
+ const range = document .createRange ()
136
+
137
+ range .setStartBefore (clipboardDiv .firstChild )
138
+ range .setEndAfter (clipboardDiv .lastChild )
139
+ window .getSelection ().addRange (range)
140
+ document .execCommand (` copy` )
141
+ window .getSelection ().removeAllRanges ()
142
+ clipboardDiv .innerHTML = output .value
143
+
144
+ if (isBeforeDark) {
145
+ toggleDark ()
146
+ }
147
+
148
+ // 输出提示
149
+ ElNotification ({
150
+ showClose: true ,
151
+ message: ` 已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴` ,
152
+ offset: 80 ,
153
+ duration: 1600 ,
154
+ type: ` success` ,
155
+ })
146
156
147
- // 输出提示
148
- ElNotification ({
149
- showClose: true ,
150
- message: ` 已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴` ,
151
- offset: 80 ,
152
- duration: 1600 ,
153
- type: ` success` ,
157
+ editorRefresh ()
158
+ emit (` endCopy` )
154
159
})
155
-
156
- editorRefresh ()
157
- emit (` endCopy` )
158
160
}, 350 )
159
161
}
160
162
</script >
0 commit comments