-
Notifications
You must be signed in to change notification settings - Fork 9
T/1: Initial implementation of Highlight editing without UI. #2
Conversation
…ulation on refresh.
src/highlightcommand.js
Outdated
* @observable | ||
* @readonly | ||
* @member {undefined|String} HighlightCommand#value | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives some docs errors - it should be moved probably to the class constructor or use full module name.
src/highlightcommand.js
Outdated
import Command from '@ckeditor/ckeditor5-core/src/command'; | ||
|
||
/** | ||
* The highlight command. It is used by the {@link module:highlight/highlight~HighlightEditing highlight feature} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gives some docs errors, probably wrong module in @link
.
src/highlightediting.js
Outdated
const data = editor.data; | ||
const editing = editor.editing; | ||
|
||
editor.config.define( 'highlight', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be defined inside the class constructor?
src/highlightediting.js
Outdated
.for( data.viewToModel ) | ||
.fromElement( 'mark' ) | ||
.toAttribute( viewElement => { | ||
const viewClassNames = [ ...viewElement.getClassNames() ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could be simplified to:
const viewClassNames = [ ...viewElement.getClassNames() ];
for( const className of viewClassNames ) {
if ( configuredClasses.indexOf( className ) > -1 ) {
return { key: 'highlight', value: className };
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing:
for( const className of viewElement.getClassNames() ) {}
We'd take advantage of generators and save extra ms ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ma2ciek 👏 yeah... I've disabled thinking apparently :D
src/highlightediting.js
Outdated
* @property {String} title The user-readable title of the option. | ||
* @property {String} color Color used for highlighter. Should be coherent with CSS class definition. | ||
* @property {'marker'|'pen'} type The type of highlighter. Either "marker" - will use #color as background name | ||
* of the view element that will be used to represent the model element in the view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like pen
option description is missing.
src/highlightediting.js
Outdated
* | ||
* Read more in {@link module:highlight/highlightediting~HighlightEditingConfig}. | ||
* | ||
* @member {module:highlight/highlightediting~HighlightEditingConfig} module:core/editor/editorconfig~EditorConfig#alignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alignment => highlight
src/highlightediting.js
Outdated
] ); | ||
|
||
// Allow highlight attribute on all elements | ||
editor.document.schema.allow( { name: '$inline', attributes: 'highlight', inside: '$block' } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basic styles contains this workaround. It probably should be included here as well.
Suggested merge commit message (convention)
Feature: Initial implementation of highlight editing. Closes ckeditor/ckeditor5#2597.
Additional information
This PR comes with changes in other packages branches:
Merge commit message for related branches:
Feature: Introduce ckeditor5-highlight package.
Misc
Markers
were used in view - only<mark>
elements.