-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate Tinymce module into a web component #2555
Migrate Tinymce module into a web component #2555
Conversation
daa9338
to
908d795
Compare
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.
After dragndrop the tinymce editor is gone. Making the textarea visible again, reinits the tinymce though
01f9338
to
0953a19
Compare
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.
We still need to element dirty callback
c27b32d
to
7c43edf
Compare
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.
The Element dirty stuff now works, but with every second drag it now exposes the textarea, because it is not hidden anymore. We need to hide it on drag and show it again after drop somehow
6b21493
to
55e43dc
Compare
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.
Works really good now! 👏🏻
@@ -0,0 +1,11 @@ | |||
export function appendSpinner(element, size = "small") { |
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.
I think it makes sense to have this file in alchemy_admin/spinner.js
, not in utils
, because we will convert the spinner as well soon.
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.
I moved the appendSpinner
and removeSpinner
into the web component. We can extract them, if we use these functions anywhere else.
55e43dc
to
136bdb5
Compare
@@ -105,9 +104,6 @@ class window.Alchemy.Dialog | |||
# Initializes the Dialog body | |||
init: -> | |||
Alchemy.GUI.init(@dialog_body) | |||
Alchemy.Tinymce.initWith |
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.
Is there a way with custom elements to get back this behavior? Admittedly it's a rarely used feature, but we would at least tell people how to upgrade.
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.
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 screenshot is now outdated. Can you comment on the PR description how to upgrade this?
...Alchemy.TinymceDefaults, | ||
...this.externalConfig, | ||
locale: Alchemy.locale, | ||
selector: `#${this.textareaId}` |
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.
Can people still override the selector in their custom config?
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.
It is not necessary anymore.
} | ||
} | ||
|
||
set configuration(config) { |
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 setter is named as if it would set the config, but in reality it appends to the default config. Maybe we call it addConfig, additionalConfig or overrideConfig?
Ideally we would allow to set the custom config as attributes on the element itself.
08b4596
to
d252eb8
Compare
9e3455a
to
1e7df79
Compare
bd74431
to
8cca6ec
Compare
@@ -105,9 +104,6 @@ class window.Alchemy.Dialog | |||
# Initializes the Dialog body | |||
init: -> | |||
Alchemy.GUI.init(@dialog_body) | |||
Alchemy.Tinymce.initWith |
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 screenshot is now outdated. Can you comment on the PR description how to upgrade this?
} | ||
|
||
get configuration() { | ||
const externalConfig = {} |
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 is a confusing variable name. what about
const externalConfig = {} | |
const customConfig = {} |
8cca6ec
to
105b8fe
Compare
Instead of multiple initializations and removals let the browser handle the problem. Web components have life cycle hooks to create and destroy the Tinymce editor.
Allow the toolbar and plugin attribute on the tinymce web component. The configuration is read in from the elements.yml and will be available as (escaped) JSON. It is also possible to use a plain string.
The id is not necessary anymore, because the custom configuration is now build in as attributes on the component it self and the previous configuration block is gone.
You need sometimes attributes with underscores, which is uncommon in HTML. For that reason the attributes are casted and will be transform back in the web component. Also a new element with a lot of custom configuration was added to test the Tinymce behavior.
it is increasing the readability and "feels" a bit better. Also removed a method on the richtext - model, which isn't used anymore.
105b8fe
to
93777f1
Compare
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.
Awesome 👏🏻
What is this pull request for?
Instead of multiple initializations and removals let the browser handle the problem. Web components have life cycle hooks to create and destroy the Tinymce editor.
Usage
Each textarea can become a Richtext - Editor. Only add the
is
attribute with the valuealchemy-tinymce
the to textarea. e.g.or add custom configuration to the Tinymce editor. All Tinymce options are supported and can be added as String or as serialized JSON. Attributes that have underscores (_) have to be written with dashes (-). The component will transform them back.
Breaking Change
The old Tinymce editor had to have the
.has_tinymce
- class on the textarea. This is not supported anymore and instead of that the class, theis="alchemy-tinymce"
- attribute has to be added to the textarea.Checklist