mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
Feat:新增禁止读取和写入用户剪贴板的实例化选项
This commit is contained in:
@@ -221,6 +221,8 @@ export const defaultOpt = {
|
||||
createNodePrefixContent: null,
|
||||
// 添加附加的节点后置内容,后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分
|
||||
createNodePostfixContent: null,
|
||||
// 禁止粘贴用户剪贴板中的数据,禁止将复制的数据写入用户的剪贴板中
|
||||
disabledClipboard: false,
|
||||
|
||||
// 【Select插件】
|
||||
// 多选节点时鼠标移动到边缘时的画布移动偏移量
|
||||
|
||||
@@ -1013,14 +1013,18 @@ class Render {
|
||||
copy() {
|
||||
this.beingCopyData = this.copyNode()
|
||||
if (!this.beingCopyData) return
|
||||
setDataToClipboard(createSmmFormatData(this.beingCopyData))
|
||||
if (!this.mindMap.opt.disabledClipboard) {
|
||||
setDataToClipboard(createSmmFormatData(this.beingCopyData))
|
||||
}
|
||||
}
|
||||
|
||||
// 剪切节点
|
||||
cut() {
|
||||
this.mindMap.execCommand('CUT_NODE', copyData => {
|
||||
this.beingCopyData = copyData
|
||||
setDataToClipboard(createSmmFormatData(copyData))
|
||||
if (!this.mindMap.opt.disabledClipboard) {
|
||||
setDataToClipboard(createSmmFormatData(copyData))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1029,17 +1033,20 @@ class Render {
|
||||
const {
|
||||
errorHandler,
|
||||
handleIsSplitByWrapOnPasteCreateNewNode,
|
||||
handleNodePasteImg
|
||||
handleNodePasteImg,
|
||||
disabledClipboard
|
||||
} = this.mindMap.opt
|
||||
// 读取剪贴板的文字和图片
|
||||
let text = null
|
||||
let text = ''
|
||||
let img = null
|
||||
try {
|
||||
const res = await getDataFromClipboard()
|
||||
text = res.text
|
||||
img = res.img
|
||||
} catch (error) {
|
||||
errorHandler(ERROR_TYPES.READ_CLIPBOARD_ERROR, error)
|
||||
if (!disabledClipboard) {
|
||||
try {
|
||||
const res = await getDataFromClipboard()
|
||||
text = res.text || ''
|
||||
img = res.img || null
|
||||
} catch (error) {
|
||||
errorHandler(ERROR_TYPES.READ_CLIPBOARD_ERROR, error)
|
||||
}
|
||||
}
|
||||
// 检查剪切板数据是否有变化
|
||||
// 通过图片大小来判断图片是否发生变化,可能是不准确的,但是目前没有其他好方法
|
||||
|
||||
Reference in New Issue
Block a user