@ctzhian/tiptap 2.11.4 → 2.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -175,9 +175,19 @@ export var InlineLinkExtension = Node.create({
|
|
|
175
175
|
return [{
|
|
176
176
|
tag: 'a',
|
|
177
177
|
getAttrs: function getAttrs(dom) {
|
|
178
|
-
var
|
|
179
|
-
var
|
|
180
|
-
var
|
|
178
|
+
var element = dom;
|
|
179
|
+
var href = element.getAttribute('href');
|
|
180
|
+
var dataType = element.getAttribute('type');
|
|
181
|
+
var download = element.getAttribute('download');
|
|
182
|
+
|
|
183
|
+
// 如果 <a> 标签内部包含图片,则视为"图片链接",不解析为 inlineLink,
|
|
184
|
+
// 让内部的 <img> 节点按普通图片逻辑处理,避免丢失图片和文本。
|
|
185
|
+
var hasImageChild = Array.from(element.childNodes).some(function (node) {
|
|
186
|
+
return node.nodeType === 1 && node.tagName.toLowerCase() === 'img';
|
|
187
|
+
});
|
|
188
|
+
if (hasImageChild) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
181
191
|
|
|
182
192
|
// 如果存在 download 属性,认为是附件,不解析为链接
|
|
183
193
|
if (download !== null) {
|
|
@@ -200,12 +210,12 @@ export var InlineLinkExtension = Node.create({
|
|
|
200
210
|
}
|
|
201
211
|
return {
|
|
202
212
|
href: href,
|
|
203
|
-
target:
|
|
204
|
-
class:
|
|
205
|
-
rel:
|
|
206
|
-
title:
|
|
207
|
-
type:
|
|
208
|
-
download:
|
|
213
|
+
target: element.getAttribute('target') || _this.options.HTMLAttributes.target,
|
|
214
|
+
class: element.getAttribute('class') || _this.options.HTMLAttributes.class,
|
|
215
|
+
rel: element.getAttribute('rel'),
|
|
216
|
+
title: element.textContent || element.getAttribute('title'),
|
|
217
|
+
type: element.getAttribute('type') || 'icon',
|
|
218
|
+
download: element.getAttribute('download')
|
|
209
219
|
};
|
|
210
220
|
}
|
|
211
221
|
}];
|