Skip to content
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

Editor disabled #35

Merged
merged 6 commits into from
Sep 27, 2019
Merged

Conversation

wilsonge
Copy link

@wilsonge wilsonge commented Sep 26, 2019

Adds ability to toggle editor from disabled mode and back again.

Codemirror is a bit grim here because we set the direct instance into the Joomla.editors stuff so i'm creating a new method in codemirror itself :/ (I know when @dgrammatiko sees this i'm going to be told off :D )

Fixes tags not showing when using html mode

There's still definitely some unwanted behaviour here - for example with the default editor function - the template data looks like:

body:
master: "COM_CONFIG_SENDMAIL_BODY"
translated: "This is a test mail sent using "{METHOD}". Your email settings are correct!"
__proto__: Object
htmlbody: {master: "", translated: ""}
subject:
master: "COM_CONFIG_SENDMAIL_SUBJECT"
translated: "Test mail from {SITENAME}"

This means that the html email is always showing as empty when your in html mode - to me this needs to take the same at least translated and master text as the main body (if not set to a different value in the email constructor)

@dgrammatiko
Copy link

Actually this makes sense, also APIs should and must be enhanced to meet devs needs and as long as we’re not breaking anything we’re good. So, in sort go for it

@Hackwar
Copy link
Owner

Hackwar commented Sep 27, 2019

Thank you!

@Hackwar Hackwar merged commit e5cd50a into Hackwar:j4mailtemplates Sep 27, 2019
@wilsonge
Copy link
Author

The method makes sense but I’m actually modifying the codemirror instance itself. Fairly sure I should be making proxy methods at this point. But as If I can point to this comment in 6 months time it’s all good 😂

@dgrammatiko
Copy link

dgrammatiko commented Sep 28, 2019

but I’m actually modifying the codemirror instance itself

No worries, all the API naming is a complete rip off from the code mirror internals:

/**
   * getValue         Type  Function  Should return the complete data from the editor
   *                                  Example: () => { return this.element.value; }
   * setValue         Type  Function  Should replace the complete data of the editor
    *                                  Example: (text) => { return this.element.value = text; }
    * getSelection     Type  Function  Should return the selected text from the editor
    *                                  Example: function () { return this.selectedText; }
    * disable          Type  Function  Toggles the editor into disabled mode. When the editor is
    *                                  active then everything should be usable. When inactive the
    *                                  editor should be unusable AND disabled for form validation
    *                                  Example: (bool) => { return this.disable = value; }
    * replaceSelection Type  Function  Should replace the selected text of the editor
    *                                  If nothing selected, will insert the data at the cursor
    *                                  Example:
   */

What might be a little odd here is that all the other end points are named in the form of getSomething or setSomething which makes sense as in fact they are getters and setters. So maybe the disable should be something like setState as it is a setter? Or maybe something more unique but still self explanatory? (naming is hard...)

Hackwar pushed a commit that referenced this pull request Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants