@ebl-vue/editor-full 2.31.18 → 2.31.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +32 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/i18n/zh-cn.ts +3 -2
- package/src/plugins/code/index.ts +17 -12
- package/src/plugins/outline/index.ts +0 -1
package/package.json
CHANGED
package/src/i18n/zh-cn.ts
CHANGED
|
@@ -80,7 +80,7 @@ const zhCn: I18nConfig = {
|
|
|
80
80
|
},
|
|
81
81
|
link: {
|
|
82
82
|
"Add a link":"添加链接",
|
|
83
|
-
"Save": "
|
|
83
|
+
"Save": "确定",
|
|
84
84
|
"Pasted link is not valid.":"链接地址无效"
|
|
85
85
|
},
|
|
86
86
|
"List": {
|
|
@@ -105,7 +105,8 @@ const zhCn: I18nConfig = {
|
|
|
105
105
|
|
|
106
106
|
"code": {
|
|
107
107
|
"Enter your code": "输入代码",
|
|
108
|
-
"Copied": "已复制"
|
|
108
|
+
"Copied": "已复制",
|
|
109
|
+
"Unable to copy": "复制失败"
|
|
109
110
|
},
|
|
110
111
|
"convertTo": {
|
|
111
112
|
"Convert to": "转化为"
|
|
@@ -508,17 +508,14 @@ export default class CodeTool implements BlockTool {
|
|
|
508
508
|
}
|
|
509
509
|
|
|
510
510
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
if (
|
|
514
|
-
if (navigator.clipboard && window.isSecureContext) {
|
|
515
|
-
try {
|
|
516
|
-
navigator.clipboard.writeText(code).then(() => {
|
|
517
|
-
if (event.target) {
|
|
511
|
+
private showCopyTip(msg: string,event: MouseEvent) {
|
|
512
|
+
const tip = this.api.i18n.t(msg);
|
|
513
|
+
if (event.target) {
|
|
518
514
|
const parentEle = (event.target as HTMLElement).parentElement;
|
|
519
515
|
if (parentEle) {
|
|
520
516
|
const tooltip = parentEle.lastChild as HTMLElement;
|
|
521
517
|
if (tooltip) {
|
|
518
|
+
tooltip.innerHTML = tip;
|
|
522
519
|
tooltip.classList.add('visible');
|
|
523
520
|
setTimeout(() => {
|
|
524
521
|
tooltip.classList.remove('visible');
|
|
@@ -527,13 +524,20 @@ export default class CodeTool implements BlockTool {
|
|
|
527
524
|
}
|
|
528
525
|
}
|
|
529
526
|
}
|
|
527
|
+
}
|
|
528
|
+
private copyCode(code: string, event: MouseEvent) {
|
|
529
|
+
if (this.data.code) {
|
|
530
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
531
|
+
try {
|
|
532
|
+
navigator.clipboard.writeText(code).then(() => {
|
|
533
|
+
this.showCopyTip('Copied',event);
|
|
530
534
|
}).catch((err) => {
|
|
531
|
-
console.error(err);
|
|
532
|
-
|
|
535
|
+
console.error(err);
|
|
536
|
+
this.showCopyTip('Unable to copy',event);
|
|
533
537
|
});
|
|
534
538
|
|
|
535
539
|
} catch (err) {
|
|
536
|
-
|
|
540
|
+
this.showCopyTip('Unable to copy',event);
|
|
537
541
|
}
|
|
538
542
|
} else {
|
|
539
543
|
// 传统方法:使用 textarea 和 execCommand
|
|
@@ -554,9 +558,10 @@ export default class CodeTool implements BlockTool {
|
|
|
554
558
|
textArea.select();
|
|
555
559
|
try {
|
|
556
560
|
document.execCommand('copy');
|
|
557
|
-
document.body.removeChild(textArea);
|
|
561
|
+
document.body.removeChild(textArea);
|
|
562
|
+
this.showCopyTip('Copied',event);
|
|
558
563
|
} catch (err) {
|
|
559
|
-
|
|
564
|
+
this.showCopyTip('Unable to copy',event);
|
|
560
565
|
document.body.removeChild(textArea);
|
|
561
566
|
|
|
562
567
|
}
|