|
@@ -767,6 +767,33 @@ export default {
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.error('Apply bold failed:', error);
|
|
console.error('Apply bold failed:', error);
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ // 添加自定义粘贴处理方法
|
|
|
|
+ handlePaste(e) {
|
|
|
|
+ try {
|
|
|
|
+ if (!this.editorRef) return;
|
|
|
|
+
|
|
|
|
+ // 阻止默认粘贴行为
|
|
|
|
+ e.preventDefault();
|
|
|
|
+
|
|
|
|
+ // 尝试从剪贴板获取文本
|
|
|
|
+ let text = '';
|
|
|
|
+
|
|
|
|
+ // 使用 clipboardData 获取粘贴内容
|
|
|
|
+ if (e.clipboardData && e.clipboardData.getData) {
|
|
|
|
+ text = e.clipboardData.getData('text/plain');
|
|
|
|
+ } else if (window.clipboardData && window.clipboardData.getData) {
|
|
|
|
+ // IE 兼容
|
|
|
|
+ text = window.clipboardData.getData('Text');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果获取到文本,则执行粘贴
|
|
|
|
+ if (text) {
|
|
|
|
+ this.editorRef.command.executeInsertText(text);
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('Custom paste handler failed:', error);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|