@ckeditor/ckeditor5-link 47.0.0 → 47.1.0-alpha.1
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/build/link.js +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/linkcommand.js +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-link",
|
|
3
|
-
"version": "47.0.
|
|
3
|
+
"version": "47.1.0-alpha.1",
|
|
4
4
|
"description": "Link feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-clipboard": "47.0.
|
|
17
|
-
"@ckeditor/ckeditor5-core": "47.0.
|
|
18
|
-
"@ckeditor/ckeditor5-engine": "47.0.
|
|
19
|
-
"@ckeditor/ckeditor5-icons": "47.0.
|
|
20
|
-
"@ckeditor/ckeditor5-image": "47.0.
|
|
21
|
-
"@ckeditor/ckeditor5-typing": "47.0.
|
|
22
|
-
"@ckeditor/ckeditor5-ui": "47.0.
|
|
23
|
-
"@ckeditor/ckeditor5-utils": "47.0.
|
|
24
|
-
"@ckeditor/ckeditor5-widget": "47.0.
|
|
25
|
-
"ckeditor5": "47.0.
|
|
16
|
+
"@ckeditor/ckeditor5-clipboard": "47.1.0-alpha.1",
|
|
17
|
+
"@ckeditor/ckeditor5-core": "47.1.0-alpha.1",
|
|
18
|
+
"@ckeditor/ckeditor5-engine": "47.1.0-alpha.1",
|
|
19
|
+
"@ckeditor/ckeditor5-icons": "47.1.0-alpha.1",
|
|
20
|
+
"@ckeditor/ckeditor5-image": "47.1.0-alpha.1",
|
|
21
|
+
"@ckeditor/ckeditor5-typing": "47.1.0-alpha.1",
|
|
22
|
+
"@ckeditor/ckeditor5-ui": "47.1.0-alpha.1",
|
|
23
|
+
"@ckeditor/ckeditor5-utils": "47.1.0-alpha.1",
|
|
24
|
+
"@ckeditor/ckeditor5-widget": "47.1.0-alpha.1",
|
|
25
|
+
"ckeditor5": "47.1.0-alpha.1",
|
|
26
26
|
"es-toolkit": "1.39.5"
|
|
27
27
|
},
|
|
28
28
|
"author": "CKSource (http://cksource.com/)",
|
package/src/linkcommand.js
CHANGED
|
@@ -171,13 +171,20 @@ export class LinkCommand extends Command {
|
|
|
171
171
|
}
|
|
172
172
|
// Only if needed.
|
|
173
173
|
if (newText != linkText) {
|
|
174
|
+
const fragment = writer.createDocumentFragment();
|
|
175
|
+
for (const item of range.getItems()) {
|
|
176
|
+
// `extractTextFromLinkRange()` called above guarantees that we operate only on text proxies here.
|
|
177
|
+
const text = item;
|
|
178
|
+
writer.append(writer.createText(text.data, text.getAttributes()), fragment);
|
|
179
|
+
}
|
|
180
|
+
const fragRange = writer.createRangeIn(fragment);
|
|
174
181
|
const changes = findChanges(linkText, newText);
|
|
175
182
|
let insertsLength = 0;
|
|
176
183
|
for (const { offset, actual, expected } of changes) {
|
|
177
184
|
const updatedOffset = offset + insertsLength;
|
|
178
|
-
const subRange = writer.createRange(
|
|
185
|
+
const subRange = writer.createRange(fragRange.start.getShiftedBy(updatedOffset), fragRange.start.getShiftedBy(updatedOffset + actual.length));
|
|
179
186
|
// Collect formatting attributes from replaced text.
|
|
180
|
-
const textNode = getLinkPartTextNode(subRange,
|
|
187
|
+
const textNode = getLinkPartTextNode(subRange, fragRange);
|
|
181
188
|
const attributes = textNode.getAttributes();
|
|
182
189
|
const formattingAttributes = Array
|
|
183
190
|
.from(attributes)
|
|
@@ -187,10 +194,12 @@ export class LinkCommand extends Command {
|
|
|
187
194
|
// Set link attributes before inserting to document to avoid Differ attributes edge case.
|
|
188
195
|
updateLinkAttributes(newTextNode);
|
|
189
196
|
// Replace text with formatting.
|
|
190
|
-
|
|
197
|
+
writer.remove(subRange);
|
|
198
|
+
writer.insert(newTextNode, subRange.start);
|
|
191
199
|
// Sum of all previous inserts.
|
|
192
200
|
insertsLength += expected.length;
|
|
193
201
|
}
|
|
202
|
+
model.insertContent(fragment, range);
|
|
194
203
|
return writer.createRange(range.start, range.start.getShiftedBy(newText.length));
|
|
195
204
|
}
|
|
196
205
|
};
|