@ckeditor/ckeditor5-link 48.5.2 → 48.5.3
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.
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -78,9 +78,10 @@ var AutomaticLinkDecorators = class {
|
|
|
78
78
|
if (!data.attributeKey.startsWith("link")) return;
|
|
79
79
|
if (data.attributeKey == "linkHref" && !conversionApi.consumable.test(data.item, "attribute:linkHref")) return;
|
|
80
80
|
if (!data.item.is("selection") && !conversionApi.schema.isInline(data.item)) return;
|
|
81
|
-
for (const decorator of this._definitions) if (decorator.callback(data.item.getAttribute("linkHref")) && !this._conflictChecker?.(decorator, data.item) && isApplyingConverter)
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
for (const decorator of this._definitions) if (decorator.callback(data.item.getAttribute("linkHref")) && !this._conflictChecker?.(decorator, data.item) && isApplyingConverter) {
|
|
82
|
+
if (data.item.is("selection")) conversionApi.writer.wrap(conversionApi.writer.document.selection.getFirstRange(), elementCreator(decorator, conversionApi.writer));
|
|
83
|
+
else conversionApi.writer.wrap(conversionApi.mapper.toViewRange(data.range), elementCreator(decorator, conversionApi.writer));
|
|
84
|
+
} else conversionApi.writer.unwrap(conversionApi.mapper.toViewRange(data.range), elementCreator(decorator, conversionApi.writer));
|
|
84
85
|
};
|
|
85
86
|
};
|
|
86
87
|
dispatcher.on("attribute", createConverter(false), { priority: priorities.high - 1 });
|
|
@@ -2992,12 +2993,13 @@ function downcastImageLink(editor) {
|
|
|
2992
2993
|
const linkInImage = Array.from(viewFigure.getChildren()).find((child) => child.is("element", "a"));
|
|
2993
2994
|
const viewImage = imageUtils.findViewImgElement(viewFigure);
|
|
2994
2995
|
const viewImgOrPicture = viewImage.parent.is("element", "picture") ? viewImage.parent : viewImage;
|
|
2995
|
-
if (linkInImage)
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
2996
|
+
if (linkInImage) {
|
|
2997
|
+
if (data.attributeNewValue) writer.setAttribute("href", data.attributeNewValue, linkInImage);
|
|
2998
|
+
else {
|
|
2999
|
+
writer.move(writer.createRangeOn(viewImgOrPicture), writer.createPositionAt(viewFigure, 0));
|
|
3000
|
+
writer.remove(linkInImage);
|
|
3001
|
+
}
|
|
3002
|
+
} else {
|
|
3001
3003
|
const linkElement = writer.createContainerElement("a", { href: data.attributeNewValue });
|
|
3002
3004
|
writer.insert(writer.createPositionAt(viewFigure, 0), linkElement);
|
|
3003
3005
|
writer.move(writer.createRangeOn(viewImgOrPicture), writer.createPositionAt(linkElement, 0));
|