@ckeditor/ckeditor5-link 31.0.0 → 33.0.0
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/LICENSE.md +2 -2
- package/build/link.js +3 -3
- package/build/link.js.map +1 -0
- package/build/translations/el.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/uz.js +1 -0
- package/ckeditor5-metadata.json +2 -0
- package/lang/translations/ar.po +1 -1
- package/lang/translations/ast.po +1 -1
- package/lang/translations/az.po +1 -1
- package/lang/translations/bg.po +1 -1
- package/lang/translations/cs.po +1 -1
- package/lang/translations/da.po +1 -1
- package/lang/translations/de-ch.po +1 -1
- package/lang/translations/de.po +1 -1
- package/lang/translations/el.po +7 -7
- package/lang/translations/en-au.po +1 -1
- package/lang/translations/en-gb.po +1 -1
- package/lang/translations/en.po +1 -1
- package/lang/translations/eo.po +1 -1
- package/lang/translations/es.po +2 -2
- package/lang/translations/et.po +1 -1
- package/lang/translations/eu.po +1 -1
- package/lang/translations/fa.po +1 -1
- package/lang/translations/fi.po +3 -3
- package/lang/translations/fr.po +1 -1
- package/lang/translations/gl.po +1 -1
- package/lang/translations/he.po +1 -1
- package/lang/translations/hi.po +1 -1
- package/lang/translations/hr.po +1 -1
- package/lang/translations/hu.po +1 -1
- package/lang/translations/id.po +1 -1
- package/lang/translations/it.po +1 -1
- package/lang/translations/ja.po +1 -1
- package/lang/translations/km.po +1 -1
- package/lang/translations/kn.po +1 -1
- package/lang/translations/ko.po +1 -1
- package/lang/translations/ku.po +1 -1
- package/lang/translations/lt.po +1 -1
- package/lang/translations/lv.po +1 -1
- package/lang/translations/nb.po +1 -1
- package/lang/translations/ne.po +1 -1
- package/lang/translations/nl.po +1 -1
- package/lang/translations/no.po +1 -1
- package/lang/translations/pl.po +1 -1
- package/lang/translations/pt-br.po +1 -1
- package/lang/translations/pt.po +1 -1
- package/lang/translations/ro.po +1 -1
- package/lang/translations/ru.po +1 -1
- package/lang/translations/sk.po +1 -1
- package/lang/translations/sq.po +1 -1
- package/lang/translations/sr-latn.po +1 -1
- package/lang/translations/sr.po +1 -1
- package/lang/translations/sv.po +1 -1
- package/lang/translations/tk.po +1 -1
- package/lang/translations/tr.po +1 -1
- package/lang/translations/ug.po +1 -1
- package/lang/translations/uk.po +1 -1
- package/lang/translations/uz.po +53 -0
- package/lang/translations/vi.po +1 -1
- package/lang/translations/zh-cn.po +1 -1
- package/lang/translations/zh.po +1 -1
- package/package.json +24 -24
- package/src/autolink.js +2 -4
- package/src/index.js +1 -1
- package/src/link.js +1 -1
- package/src/linkcommand.js +1 -1
- package/src/linkediting.js +70 -5
- package/src/linkimage.js +1 -1
- package/src/linkimageediting.js +8 -5
- package/src/linkimageui.js +1 -1
- package/src/linkui.js +1 -1
- package/src/ui/linkactionsview.js +11 -1
- package/src/ui/linkformview.js +11 -1
- package/src/unlinkcommand.js +1 -1
- package/src/utils/automaticdecorators.js +1 -1
- package/src/utils/manualdecorator.js +1 -1
- package/src/utils.js +12 -1
- package/theme/link.css +1 -1
- package/theme/linkactions.css +1 -1
- package/theme/linkform.css +1 -1
- package/theme/linkimage.css +1 -1
package/src/link.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/linkcommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/linkediting.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -11,12 +11,12 @@ import { Plugin } from 'ckeditor5/src/core';
|
|
|
11
11
|
import { MouseObserver } from 'ckeditor5/src/engine';
|
|
12
12
|
import { Input, TwoStepCaretMovement, inlineHighlight, findAttributeRange } from 'ckeditor5/src/typing';
|
|
13
13
|
import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
|
|
14
|
-
import { keyCodes } from 'ckeditor5/src/utils';
|
|
14
|
+
import { keyCodes, env } from 'ckeditor5/src/utils';
|
|
15
15
|
|
|
16
16
|
import LinkCommand from './linkcommand';
|
|
17
17
|
import UnlinkCommand from './unlinkcommand';
|
|
18
18
|
import ManualDecorator from './utils/manualdecorator';
|
|
19
|
-
import { createLinkElement, ensureSafeUrl, getLocalizedDecorators, normalizeDecorators } from './utils';
|
|
19
|
+
import { createLinkElement, ensureSafeUrl, getLocalizedDecorators, normalizeDecorators, openLink } from './utils';
|
|
20
20
|
|
|
21
21
|
import '../theme/link.css';
|
|
22
22
|
|
|
@@ -107,6 +107,9 @@ export default class LinkEditing extends Plugin {
|
|
|
107
107
|
// Setup highlight over selected link.
|
|
108
108
|
inlineHighlight( editor, 'linkHref', 'a', HIGHLIGHT_CLASS );
|
|
109
109
|
|
|
110
|
+
// Handle link following by CTRL+click or ALT+ENTER
|
|
111
|
+
this._enableLinkOpen();
|
|
112
|
+
|
|
110
113
|
// Change the attributes of the selection in certain situations after the link was inserted into the document.
|
|
111
114
|
this._enableInsertContentSelectionAttributesFixer();
|
|
112
115
|
|
|
@@ -220,6 +223,68 @@ export default class LinkEditing extends Plugin {
|
|
|
220
223
|
} );
|
|
221
224
|
}
|
|
222
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Attaches handlers for {@link module:engine/view/document~Document#event:enter} and
|
|
228
|
+
* {@link module:engine/view/document~Document#event:click} to enable link following.
|
|
229
|
+
*
|
|
230
|
+
* @private
|
|
231
|
+
*/
|
|
232
|
+
_enableLinkOpen() {
|
|
233
|
+
const editor = this.editor;
|
|
234
|
+
const view = editor.editing.view;
|
|
235
|
+
const viewDocument = view.document;
|
|
236
|
+
const modelDocument = editor.model.document;
|
|
237
|
+
|
|
238
|
+
this.listenTo( viewDocument, 'click', ( evt, data ) => {
|
|
239
|
+
const shouldOpen = env.isMac ? data.domEvent.metaKey : data.domEvent.ctrlKey;
|
|
240
|
+
|
|
241
|
+
if ( !shouldOpen ) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
let clickedElement = data.domTarget;
|
|
246
|
+
|
|
247
|
+
if ( clickedElement.tagName.toLowerCase() != 'a' ) {
|
|
248
|
+
clickedElement = clickedElement.closest( 'a' );
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if ( !clickedElement ) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const url = clickedElement.getAttribute( 'href' );
|
|
256
|
+
|
|
257
|
+
if ( !url ) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
evt.stop();
|
|
262
|
+
data.preventDefault();
|
|
263
|
+
|
|
264
|
+
openLink( url );
|
|
265
|
+
}, { context: '$capture' } );
|
|
266
|
+
|
|
267
|
+
this.listenTo( viewDocument, 'enter', ( evt, data ) => {
|
|
268
|
+
const selection = modelDocument.selection;
|
|
269
|
+
|
|
270
|
+
const selectedElement = selection.getSelectedElement();
|
|
271
|
+
|
|
272
|
+
const url = selectedElement ?
|
|
273
|
+
selectedElement.getAttribute( 'linkHref' ) :
|
|
274
|
+
selection.getAttribute( 'linkHref' );
|
|
275
|
+
|
|
276
|
+
const shouldOpen = url && data.domEvent.altKey;
|
|
277
|
+
|
|
278
|
+
if ( !shouldOpen ) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
evt.stop();
|
|
283
|
+
|
|
284
|
+
openLink( url );
|
|
285
|
+
}, { context: 'a' } );
|
|
286
|
+
}
|
|
287
|
+
|
|
223
288
|
/**
|
|
224
289
|
* Starts listening to {@link module:engine/model/model~Model#event:insertContent} and corrects the model
|
|
225
290
|
* selection attributes if the selection is at the end of a link after inserting the content.
|
|
@@ -577,9 +642,9 @@ function shouldCopyAttributes( model ) {
|
|
|
577
642
|
// @params {module:core/editor/editor~Editor} editor
|
|
578
643
|
// @returns {Boolean}
|
|
579
644
|
function isTyping( editor ) {
|
|
580
|
-
const
|
|
645
|
+
const currentBatch = editor.model.change( writer => writer.batch );
|
|
581
646
|
|
|
582
|
-
return
|
|
647
|
+
return currentBatch.isTyping;
|
|
583
648
|
}
|
|
584
649
|
|
|
585
650
|
// Returns an array containing names of the attributes allowed on `$text` that describes the link item.
|
package/src/linkimage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/linkimageediting.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -44,10 +44,6 @@ export default class LinkImageEditing extends Plugin {
|
|
|
44
44
|
schema.extend( 'imageBlock', { allowAttributes: [ 'linkHref' ] } );
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if ( editor.plugins.has( 'ImageInlineEditing' ) ) {
|
|
48
|
-
schema.extend( 'imageInline', { allowAttributes: [ 'linkHref' ] } );
|
|
49
|
-
}
|
|
50
|
-
|
|
51
47
|
editor.conversion.for( 'upcast' ).add( upcastLink( editor ) );
|
|
52
48
|
editor.conversion.for( 'downcast' ).add( downcastImageLink( editor ) );
|
|
53
49
|
|
|
@@ -256,6 +252,7 @@ function downcastImageLinkManualDecorator( decorator ) {
|
|
|
256
252
|
// @private
|
|
257
253
|
// @returns {Function}
|
|
258
254
|
function upcastImageLinkManualDecorator( editor, decorator ) {
|
|
255
|
+
const isImageInlinePluginLoaded = editor.plugins.has( 'ImageInlineEditing' );
|
|
259
256
|
const imageUtils = editor.plugins.get( 'ImageUtils' );
|
|
260
257
|
|
|
261
258
|
return dispatcher => {
|
|
@@ -269,6 +266,12 @@ function upcastImageLinkManualDecorator( editor, decorator ) {
|
|
|
269
266
|
return;
|
|
270
267
|
}
|
|
271
268
|
|
|
269
|
+
const blockImageView = imageInLink.findAncestor( element => imageUtils.isBlockImageView( element ) );
|
|
270
|
+
|
|
271
|
+
if ( isImageInlinePluginLoaded && !blockImageView ) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
272
275
|
const matcher = new Matcher( decorator._createPattern() );
|
|
273
276
|
const result = matcher.match( viewLink );
|
|
274
277
|
|
package/src/linkimageui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/linkui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -155,6 +155,16 @@ export default class LinkActionsView extends View {
|
|
|
155
155
|
this.keystrokes.listenTo( this.element );
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* @inheritDoc
|
|
160
|
+
*/
|
|
161
|
+
destroy() {
|
|
162
|
+
super.destroy();
|
|
163
|
+
|
|
164
|
+
this.focusTracker.destroy();
|
|
165
|
+
this.keystrokes.destroy();
|
|
166
|
+
}
|
|
167
|
+
|
|
158
168
|
/**
|
|
159
169
|
* Focuses the fist {@link #_focusables} in the actions.
|
|
160
170
|
*/
|
package/src/ui/linkformview.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -200,6 +200,16 @@ export default class LinkFormView extends View {
|
|
|
200
200
|
this.keystrokes.listenTo( this.element );
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* @inheritDoc
|
|
205
|
+
*/
|
|
206
|
+
destroy() {
|
|
207
|
+
super.destroy();
|
|
208
|
+
|
|
209
|
+
this.focusTracker.destroy();
|
|
210
|
+
this.keystrokes.destroy();
|
|
211
|
+
}
|
|
212
|
+
|
|
203
213
|
/**
|
|
204
214
|
* Focuses the fist {@link #_focusables} in the form.
|
|
205
215
|
*/
|
package/src/unlinkcommand.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
package/src/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* @module link/utils
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/* global window */
|
|
11
|
+
|
|
10
12
|
import { upperFirst } from 'lodash-es';
|
|
11
13
|
|
|
12
14
|
const ATTRIBUTE_WHITESPACES = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex
|
|
@@ -171,3 +173,12 @@ export function addLinkProtocolIfApplicable( link, defaultProtocol ) {
|
|
|
171
173
|
|
|
172
174
|
return link && isProtocolNeeded ? protocol + link : link;
|
|
173
175
|
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Opens the link in a new browser tab.
|
|
179
|
+
*
|
|
180
|
+
* @param {String} link
|
|
181
|
+
*/
|
|
182
|
+
export function openLink( link ) {
|
|
183
|
+
window.open( link, '_blank', 'noopener' );
|
|
184
|
+
}
|
package/theme/link.css
CHANGED
package/theme/linkactions.css
CHANGED
package/theme/linkform.css
CHANGED
package/theme/linkimage.css
CHANGED