Browse Source

Unify inlineHighlight function name,

as suggested at https://github.com/ckeditor/ckeditor5/pull/7546#discussion_r454276759.
Tomek Wytrębowicz 5 years ago
parent
commit
eb6dc862ba

+ 2 - 2
packages/ckeditor5-link/src/linkediting.js

@@ -10,7 +10,7 @@
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import MouseObserver from '@ckeditor/ckeditor5-engine/src/view/observer/mouseobserver';
 import TwoStepCaretMovement from '@ckeditor/ckeditor5-typing/src/twostepcaretmovement';
-import setupLinkHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
+import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
 import LinkCommand from './linkcommand';
 import UnlinkCommand from './unlinkcommand';
 import AutomaticDecorators from './utils/automaticdecorators';
@@ -104,7 +104,7 @@ export default class LinkEditing extends Plugin {
 		twoStepCaretMovementPlugin.registerAttribute( 'linkHref' );
 
 		// Setup highlight over selected link.
-		setupLinkHighlight( editor, 'linkHref', 'a', HIGHLIGHT_CLASS );
+		inlineHighlight( editor, 'linkHref', 'a', HIGHLIGHT_CLASS );
 
 		// Change the attributes of the selection in certain situations after the link was inserted into the document.
 		this._enableInsertContentSelectionAttributesFixer();

+ 9 - 1
packages/ckeditor5-typing/src/utils/inlinehighlight.js

@@ -21,12 +21,20 @@ import findAttributeRange from './findattributerange';
  *
  * This way, adding and removing the highlight does not interfere with conversion.
  *
+ * Usage:
+ *
+ *		import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
+ *
+ *		// Make `ck-link_selected` class be applied on an `a` element
+ *		// whenever the corresponding `linkHref` attribute element is selected.
+ *		inlineHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );
+ *
  * @param {module:core/editor/editor~Editor} editor The editor instance.
  * @param {String} attributeName The attribute name to check.
  * @param {String} tagName The tagName of a view item.
  * @param {String} className The class name to apply in the view.
  */
-export default function setupLinkHighlight( editor, attributeName, tagName, className ) {
+export default function inlineHighlight( editor, attributeName, tagName, className ) {
 	const view = editor.editing.view;
 	const highlightedElements = new Set();
 

+ 2 - 2
packages/ckeditor5-typing/tests/utils/inlinehighlight.js

@@ -2,7 +2,7 @@
  * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
-import setupHighlight from '../../src/utils/inlinehighlight';
+import inlineHighlight from '../../src/utils/inlinehighlight';
 
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
@@ -35,7 +35,7 @@ describe( 'LinkEditing', () => {
 			} } );
 
 		// Setup highlight over selected link.
-		setupHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );
+		inlineHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );
 	} );
 
 	afterEach( async () => {