GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 395 forks source link

Issue with new tool in toolbox #399

Closed tokuduzcc closed 7 years ago

tokuduzcc commented 7 years ago

Hello,

Firstly I would like to thank you for this amazing tools. It really satisfies most of my needs, but currently I am struggling with adding new tool, correctly with adding certain tags.

Scenario: Adding new tool as simple as it can.

class ContentTools.Tools.Test extends ContentTools.Tools.Heading

    # Convert the current text block to a subheading (e.g <q>foo</q>)

    ContentTools.ToolShelf.stow(@, 'quote')

    @label = 'Quote'
    @icon = 'quote'
    @tagName = 'q'

It all works fine, extending Heading, overriding apply and adding custom css class. When in edit mode i can substitute my q tag with h1 or any predefined tag, as well as reverse. This go bad when i save article (it still have styling), go back in edit mode and my text can't be edited. It got class ce-element--type-static and i guess that is the problem since ti can't get focus. I am assuming that I need to register my new tag somewhere but I have problems with that. If you could help me or provide some info I would be grateful. Code snippet below works fine.

class ContentTools.Tools.Test extends ContentTools.Tools.Heading

    # Convert the current text block to a subheading (e.g <q>foo</q>)

    ContentTools.ToolShelf.stow(@, 'quote')

    @label = 'Quote'
    @icon = 'quote'
    @tagName = 'blockquote'

And one additional question, is it posible to include new font on new element style?

Thank you

anthonyjb commented 7 years ago

Hi @tokuduz,

ContentEdit.TagNames.get().register(ContentEdit.Text, 'q')

Ant