@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 href = dom.getAttribute('href');
179
- var dataType = dom.getAttribute('type');
180
- var download = dom.getAttribute('download');
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: dom.getAttribute('target') || _this.options.HTMLAttributes.target,
204
- class: dom.getAttribute('class') || _this.options.HTMLAttributes.class,
205
- rel: dom.getAttribute('rel'),
206
- title: dom.textContent || dom.getAttribute('title'),
207
- type: dom.getAttribute('type') || 'icon',
208
- download: dom.getAttribute('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
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "2.11.4",
3
+ "version": "2.11.5",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",