Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/3: Highlight UI Implementation #6

Merged
merged 81 commits into from
Feb 19, 2018
Merged

T/3: Highlight UI Implementation #6

merged 81 commits into from
Feb 19, 2018

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Feb 9, 2018

Suggested merge commit message (convention)

Feature: Implement highlight feature UI and UX. Closes ckeditor/ckeditor5#2595. Closes ckeditor/ckeditor5#2598.


Additional information

  • It's finally done :) Probably toolbar in dropdown need some work - paddings?

jodator and others added 30 commits November 22, 2017 13:01
@oleq
Copy link
Member

oleq commented Feb 16, 2018

Switching to another highlight removes the previous one when one decides to continue typing:
kapture 2018-02-16 at 16 23 50

```js
ClassicEditor
.create( document.querySelector( '#editor' ), {
highlight: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the highlight feature dropdown uses a basic ToolbarView, I wonder if we could simply make the highlight configuration compatible with the toolbar config. I mean here a support for toolbar separators (|), that developers may want to use to group the buttons if only to separate pens from markers. WDYT?

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting idea. How would the config need to look then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed-up with the options:

ClassicEditor
	.create( document.querySelector( '#snippet-custom-highlight-options' ), {
		toolbar: {
			items: [
				'headings', '|', 'highlightDropdown', 'bulletedList', 'numberedList', 'undo', 'redo'
			],
			viewportTopOffset: 60
		},
		highlight: {
			options: [
				{ model: 'greenMarker', class: 'marker-green', ... },
				{ model: 'bluePen', class: 'pen-blue', ... },
				'|',
				{ model: 'fooPen', class: 'pen-foo', ... }
				'|',
				'removeHighlight'
			]
		}
	} )
	.then( editor => {
		window.editor = editor;
	} )
	.catch( err => {
		console.error( err.stack );
	} );

Or as a separate property, which makes more sense to me because it doesn't mix up the content logic and the UI.

In such situation, the order in options doesn't matter. We also provide a default toolbar layout, when no specified (and the default is toolbar: [ all options, '|', 'removeHighlight' ])

ClassicEditor
	.create( document.querySelector( '#snippet-custom-highlight-options' ), {
		toolbar: {
			items: [
				'headings', '|', 'highlightDropdown', 'bulletedList', 'numberedList', 'undo', 'redo'
			],
			viewportTopOffset: 60
		},
		highlight: {
			options: [
				{ model: 'greenMarker', class: 'marker-green', ... },
				{ model: 'bluePen', class: 'pen-blue', ... },
				{ model: 'fooPen', class: 'pen-foo', ... }
			],
			toolbar: [ 
				'highlight:greenMarker', 
				'highlight:bluePen', 
				'|', 
				'highlight:fooPen', 
				'|', 
				'removeHighlight' 
			]
		}
	} )
	.then( editor => {
		window.editor = editor;
	} )
	.catch( err => {
		console.error( err.stack );
	} );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oleq AFAIR that was an idea to have UI configurable using button instances (toolbarDropdown) and it should have issue for that. It is also doable the same way for alignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oleq & @Reinmar : https://github.com/ckeditor/ckeditor5-ui/issues/322 & https://github.com/ckeditor/ckeditor5-heading/issues/74#issuecomment-305224952.

The way how alignment & highlight features works (buttons + dropdown) was inspired by that issue & comment - so thus enables it pretty straightforward.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ps> I'd for doing this as a follow up just to see this feature live ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ps> I'd for doing this as a follow up just to see this feature live ;)

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't think that https://github.com/ckeditor/ckeditor5-ui/issues/322 has anything to do with this. Here, in this specific feature, there's more than just wrapping buttons into a dropdown, am I right? The state of the button, the color of the pen, etc, has some custom bindings.

@jodator
Copy link
Contributor Author

jodator commented Feb 19, 2018

Switching to another highlight removes the previous one when one decides to continue typing:

Hmmm the same happens with other attributes as well. Typing over selection does indeed remove that attribute from the model. So It looks like consistent behavior or a bug across editor.

screencast 2018-02-19 13_25_00

/cc @Reinmar, @oleq

@Reinmar
Copy link
Member

Reinmar commented Feb 19, 2018

The question is why in #6 (comment) the selection is changed from collapsed at the end of a highlight to a non-collapsed?

@jodator
Copy link
Contributor Author

jodator commented Feb 19, 2018

I was sure that it was implemented regarding to this: https://github.com/ckeditor/ckeditor5-highlight/issues/3#issuecomment-352456606 but probably I've wrongly remembered how that should work.

So I'll fix that as described in above comment.

@Reinmar
Copy link
Member

Reinmar commented Feb 19, 2018

Hmmm the same happens with other attributes as well. Typing over selection does indeed remove that attribute from the model. So It looks like consistent behavior or a bug across editor.

I initially thought that this is the expected behaviour. And that's why https://github.com/ckeditor/ckeditor5-link/issues/73 requires a special treatment. But then I realised that it works differently in CKEditor 4. Please report it as a general ticket in ckeditor5-typing because we need a research.

@Reinmar
Copy link
Member

Reinmar commented Feb 19, 2018

I was sure that it was implemented regarding to this: #3 (comment) but probably I've wrongly remembered how that should work.

So I'll fix that as described in above comment.

I mean – I may be wrong. Do you see something in Olek's comment which would indicate that the selection should change?

@jodator
Copy link
Contributor Author

jodator commented Feb 19, 2018

I mean – I may be wrong. Do you see something in Olek's comment which would indicate that the selection should change?

To be precise: I've read (remember) how the selection should work with highlight wrong. Or I've mixed examples from collapsed selection with those from with expanded. It was my mistake. I've fixed it to match how it was described in linked comment.

const t = this.editor.t;

return {
'Marker': t( 'Marker' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the yellow marker just "Marker" while the green one is "Green marker"? This is inconsistent and potentially confusing for the user with visual impairments.

The `value` corresponds to the `model` property in configuration object. For the default configuration:
```js
highlight.options = [
{ model: 'marker', class: 'marker', title: 'Marker', color: '#ffff66', type: 'marker' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this marker named using a different convention than the others?


The `value` corresponds to the `model` property in configuration object. For the default configuration:
```js
highlight.options = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to work on the colors because AFAIR the has been chosen without any deeper research.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I handled it in 870c78c.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants