GetmeUK / ContentTools

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

Customized tool: Text Align Justify #432

Open Ardius opened 7 years ago

Ardius commented 7 years ago

I made a custom tools for text justify. it's really simple starting from align-right.

class ContentTools.Tools.AlignJustify extends ContentTools.Tools.AlignLeft
    # Apply a class to justify align the contents of the current text block.

    ContentTools.ToolShelf.stow(@, 'align-justify')

    @label = 'Align justify'
    @icon = 'align-justify'
    @className = 'text-justify'
[data-editable] .text-justify {
    text-align: justify;
    text-justify: inter-word;
}

But, to let the tool works correctly, i needed to change also the base class AlignLeft adding AlignJustify class to alignmentClassNames.

        alignmentClassNames = [
            ContentTools.Tools.AlignLeft.className,
            ContentTools.Tools.AlignCenter.className,
            ContentTools.Tools.AlignRight.className,
            ContentTools.Tools.AlignJustify.className
            ]

It works! no problem, my answer is just: why don't insert this tool in standard version? Maybe you could let it disabled (comment) in DEFAULT_TOOLS (in namespaces.coffee)

P.S. ok, i also added icon from icomoon