@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.
Files changed (83) hide show
  1. package/LICENSE.md +2 -2
  2. package/build/link.js +3 -3
  3. package/build/link.js.map +1 -0
  4. package/build/translations/el.js +1 -1
  5. package/build/translations/es.js +1 -1
  6. package/build/translations/fi.js +1 -1
  7. package/build/translations/uz.js +1 -0
  8. package/ckeditor5-metadata.json +2 -0
  9. package/lang/translations/ar.po +1 -1
  10. package/lang/translations/ast.po +1 -1
  11. package/lang/translations/az.po +1 -1
  12. package/lang/translations/bg.po +1 -1
  13. package/lang/translations/cs.po +1 -1
  14. package/lang/translations/da.po +1 -1
  15. package/lang/translations/de-ch.po +1 -1
  16. package/lang/translations/de.po +1 -1
  17. package/lang/translations/el.po +7 -7
  18. package/lang/translations/en-au.po +1 -1
  19. package/lang/translations/en-gb.po +1 -1
  20. package/lang/translations/en.po +1 -1
  21. package/lang/translations/eo.po +1 -1
  22. package/lang/translations/es.po +2 -2
  23. package/lang/translations/et.po +1 -1
  24. package/lang/translations/eu.po +1 -1
  25. package/lang/translations/fa.po +1 -1
  26. package/lang/translations/fi.po +3 -3
  27. package/lang/translations/fr.po +1 -1
  28. package/lang/translations/gl.po +1 -1
  29. package/lang/translations/he.po +1 -1
  30. package/lang/translations/hi.po +1 -1
  31. package/lang/translations/hr.po +1 -1
  32. package/lang/translations/hu.po +1 -1
  33. package/lang/translations/id.po +1 -1
  34. package/lang/translations/it.po +1 -1
  35. package/lang/translations/ja.po +1 -1
  36. package/lang/translations/km.po +1 -1
  37. package/lang/translations/kn.po +1 -1
  38. package/lang/translations/ko.po +1 -1
  39. package/lang/translations/ku.po +1 -1
  40. package/lang/translations/lt.po +1 -1
  41. package/lang/translations/lv.po +1 -1
  42. package/lang/translations/nb.po +1 -1
  43. package/lang/translations/ne.po +1 -1
  44. package/lang/translations/nl.po +1 -1
  45. package/lang/translations/no.po +1 -1
  46. package/lang/translations/pl.po +1 -1
  47. package/lang/translations/pt-br.po +1 -1
  48. package/lang/translations/pt.po +1 -1
  49. package/lang/translations/ro.po +1 -1
  50. package/lang/translations/ru.po +1 -1
  51. package/lang/translations/sk.po +1 -1
  52. package/lang/translations/sq.po +1 -1
  53. package/lang/translations/sr-latn.po +1 -1
  54. package/lang/translations/sr.po +1 -1
  55. package/lang/translations/sv.po +1 -1
  56. package/lang/translations/tk.po +1 -1
  57. package/lang/translations/tr.po +1 -1
  58. package/lang/translations/ug.po +1 -1
  59. package/lang/translations/uk.po +1 -1
  60. package/lang/translations/uz.po +53 -0
  61. package/lang/translations/vi.po +1 -1
  62. package/lang/translations/zh-cn.po +1 -1
  63. package/lang/translations/zh.po +1 -1
  64. package/package.json +24 -24
  65. package/src/autolink.js +2 -4
  66. package/src/index.js +1 -1
  67. package/src/link.js +1 -1
  68. package/src/linkcommand.js +1 -1
  69. package/src/linkediting.js +70 -5
  70. package/src/linkimage.js +1 -1
  71. package/src/linkimageediting.js +8 -5
  72. package/src/linkimageui.js +1 -1
  73. package/src/linkui.js +1 -1
  74. package/src/ui/linkactionsview.js +11 -1
  75. package/src/ui/linkformview.js +11 -1
  76. package/src/unlinkcommand.js +1 -1
  77. package/src/utils/automaticdecorators.js +1 -1
  78. package/src/utils/manualdecorator.js +1 -1
  79. package/src/utils.js +12 -1
  80. package/theme/link.css +1 -1
  81. package/theme/linkactions.css +1 -1
  82. package/theme/linkform.css +1 -1
  83. package/theme/linkimage.css +1 -1
package/src/link.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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 input = editor.plugins.get( 'Input' );
645
+ const currentBatch = editor.model.change( writer => writer.batch );
581
646
 
582
- return input.isInput( editor.model.change( writer => writer.batch ) );
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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-2021, CKSource - Frederico Knabben. All rights reserved.
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
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * 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
- * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * 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
- * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * 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
- * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
2
+ * 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