sheng-tool
    Preparing search index...

    Function copyHTML

    • 复制 HTML,一般用于富文本编辑器的场合。

      该方法依赖 navigator.clipboard.write 和 ClipboardItem 写入 text/html;不支持时会返回 rejected Promise。 这里不提供 textarea 兜底,因为普通文本复制无法保留富文本 MIME。

      Parameters

      • html: string

        被复制的 HTML 字符串

      Returns Promise<void>

      HTML 写入剪贴板后的 Promise

      0.0.21

      (async () => {
      const text = await copyHTML('<ul><li>hello</li><li>world</li></ul>');
      // 此时按 Ctrl / Command + V 到富文本编辑器中即可粘贴「hello」和「world」的有序列表
      }