Skip to content

nw跨平台 编辑器粘贴 用例大全 #2

@fritx

Description

@fritx

Paste to NW.js 0.12.3

Paste from MacOS 10.11 Windows 7
web纯文 html?+text html?+text
web单图 text+image (text为url) html+image
web单图base64 text+image (text为data-url) html+image
web图文 html+text html+text
qq纯文 text html?+text
qq单图 file html+image (image:result为空 ⚠️)
qq图文 text+image (image为其中一张图片 ⚠️) html+text
excel表格 html+text+rtf+image html+text+rtf+image
email图文 html+text+rtf html+text+rtf
桌面图标 text+image (文件名+图标) -
mac备忘录单图 html+image (html为空 text为\uFFFC) -

⚠️ 有些png粘贴后会出现图片花了的情况 应该是webkit本身的bug


Data Expression Value
types e.clipboardData.types ['text/plain'|'text/html'|'Files', ..]
items e.clipboardData.items [{ kind: 'string'|'file', type: 'text/*'|'image/*' }, ..]
html e.clipboardData.getData('text/html') '<html></html>'
text e.clipboardData.getData('text/plain') 'text string'
blob item.getAsFile() <blob>
result reader.readAsBinaryString(blob); reader.onload = e => e.target.result <binary string>

https://zh.wikipedia.org/wiki/RTF
https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types
https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions