|
|
@@ -11,12 +11,14 @@ import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
|
import mix from '@ckeditor/ckeditor5-utils/src/mix';
|
|
|
|
|
|
/**
|
|
|
- * Class used to handle correct order of
|
|
|
- * {@link module:engine/conversion/buildmodelconverter~ModelConverterBuilder#toHighlight highlights} on
|
|
|
- * elements. When different highlights are applied to same element correct order should be preserved:
|
|
|
+ * Class used to handle correct order of highlights on elements.
|
|
|
+ *
|
|
|
+ * When different highlights are applied to same element correct order should be preserved:
|
|
|
+ *
|
|
|
* * highlight with highest priority should be applied,
|
|
|
* * if two highlights have same priority - sort by CSS class provided in
|
|
|
- * {@link module:engine/conversion/model-to-view-converters~HighlightDescriptor}.
|
|
|
+ * {@link module:engine/conversion/downcast-converters~HighlightDescriptor}.
|
|
|
+ *
|
|
|
* This way, highlight will be applied with the same rules it is applied on texts.
|
|
|
*/
|
|
|
export default class HighlightStack {
|
|
|
@@ -31,7 +33,7 @@ export default class HighlightStack {
|
|
|
* Adds highlight descriptor to the stack.
|
|
|
*
|
|
|
* @fires change:top
|
|
|
- * @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} descriptor
|
|
|
+ * @param {module:engine/conversion/downcast-converters~HighlightDescriptor} descriptor
|
|
|
*/
|
|
|
add( descriptor ) {
|
|
|
const stack = this._stack;
|
|
|
@@ -77,7 +79,7 @@ export default class HighlightStack {
|
|
|
* descriptor with same id is already present.
|
|
|
*
|
|
|
* @private
|
|
|
- * @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} descriptor
|
|
|
+ * @param {module:engine/conversion/downcast-converters~HighlightDescriptor} descriptor
|
|
|
*/
|
|
|
_insertDescriptor( descriptor ) {
|
|
|
const stack = this._stack;
|
|
|
@@ -125,8 +127,8 @@ mix( HighlightStack, EmitterMixin );
|
|
|
|
|
|
// Compares two descriptors by checking their priority and class list.
|
|
|
//
|
|
|
-// @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} a
|
|
|
-// @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} b
|
|
|
+// @param {module:engine/conversion/downcast-converters~HighlightDescriptor} a
|
|
|
+// @param {module:engine/conversion/downcast-converters~HighlightDescriptor} b
|
|
|
// @returns {Boolean} Returns true if both descriptors are defined and have same priority and classes.
|
|
|
function compareDescriptors( a, b ) {
|
|
|
return a && b && a.priority == b.priority && classesToString( a.class ) == classesToString( b.class );
|
|
|
@@ -134,8 +136,8 @@ function compareDescriptors( a, b ) {
|
|
|
|
|
|
// Checks whenever first descriptor should be placed in the stack before second one.
|
|
|
//
|
|
|
-// @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} a
|
|
|
-// @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} b
|
|
|
+// @param {module:engine/conversion/downcast-converters~HighlightDescriptor} a
|
|
|
+// @param {module:engine/conversion/downcast-converters~HighlightDescriptor} b
|
|
|
// @returns {Boolean}
|
|
|
function shouldABeBeforeB( a, b ) {
|
|
|
if ( a.priority > b.priority ) {
|
|
|
@@ -148,7 +150,7 @@ function shouldABeBeforeB( a, b ) {
|
|
|
return classesToString( a.class ) > classesToString( b.class );
|
|
|
}
|
|
|
|
|
|
-// Converts CSS classes passed with {@link module:engine/conversion/model-to-view-converters~HighlightDescriptor} to
|
|
|
+// Converts CSS classes passed with {@link module:engine/conversion/downcast-converters~HighlightDescriptor} to
|
|
|
// sorted string.
|
|
|
//
|
|
|
// @param {String|Array<String>} descriptor
|
|
|
@@ -162,8 +164,8 @@ function classesToString( classes ) {
|
|
|
*
|
|
|
* @event change:top
|
|
|
* @param {Object} data Additional information about the change.
|
|
|
- * @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} [data.newDescriptor] New highlight
|
|
|
+ * @param {module:engine/conversion/downcast-converters~HighlightDescriptor} [data.newDescriptor] New highlight
|
|
|
* descriptor. It will be `undefined` when last descriptor is removed from the stack.
|
|
|
- * @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} [data.oldDescriptor] Old highlight
|
|
|
+ * @param {module:engine/conversion/downcast-converters~HighlightDescriptor} [data.oldDescriptor] Old highlight
|
|
|
* descriptor. It will be `undefined` when first descriptor is added to the stack.
|
|
|
*/
|