From 0238753b9f00aec892b89a4e6feb4eab61b046d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Tue, 3 May 2022 21:30:58 +0800 Subject: [PATCH] feat:paste link element with attribute --- src/editor/utils/clipboard.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/editor/utils/clipboard.ts b/src/editor/utils/clipboard.ts index 687ee4b..a4c3e6e 100644 --- a/src/editor/utils/clipboard.ts +++ b/src/editor/utils/clipboard.ts @@ -102,6 +102,19 @@ export function getElementListByHTML(htmlText: string): IElement[] { elementList.push({ value: '\n' }) + } else if (node.nodeName === 'A') { + const aElement = node as HTMLLinkElement + const value = aElement.innerText + if (value) { + elementList.push({ + type: ElementType.HYPERLINK, + value: '', + valueList: [{ + value + }], + url: aElement.href + }) + } } else { findTextNode(node) if (node.nodeType === 1 && n !== childNodes.length - 1) {