Tui.editor: (Doc) better doc for customize Toolbar function (Bold, etc)

Created on 1 Jul 2018  ยท  6Comments  ยท  Source: nhn/tui.editor

1. For example, I don't want to use default toolbar at all.

Let's take Taskade for example. assuming I want copy their UI

image

2. The default way of add toolbar item. the UI is not gonna work

like the following

var editor = new tui.Editor({
        el: document.querySelector('#editSection'),
        previewStyle: 'vertical',
        height: '400px',
        initialEditType: 'markdown',
        useCommandShortcut: true,
        initialValue: content,
        exts: ['scrollSync', 'uml', 'chart', 'mark', 'table', 'taskCounter'],
        toolbarItems: [
          'heading',
          'bold',
          'divider',
          'indent',
          'outdent',
          {
            type: 'button',
            options: {
              name: 'test',
              className: 'custom-button-1',
              event: 'lol',
              tooltip: 'custom button 1'
            }
          },
          {
            type: 'button',
            options: {
              $el: $('<div style="float:left;width:100px;font-size: 10px;text-align:center;line-height: 30px">custom element</div>'),
              name: 'test2',
              className: 'custom-button-2',
              command: 'CustomCommand',
              tooltip: 'custom button 2'
            }
          }
        ]
      });

Code from: https://github.com/nhnent/tui.editor/pull/124

3. I figure out (by reading doc) I could code like following

to make Customize toolbar work (click a button that I build. to make bold text)

//... some not relate code here
    this.editor = new Editor({
      el: document.querySelector("#content"),
      initialEditType: "wysiwyg", 
      hideModeSwitch: true,  
      language: 'zh',
      toolbarItems: [
        'heading',
        'bold',
        'italic',
        'strike',
        'divider',
        'hr',
        'quote',
        'divider',
        'ul',
        'ol',
        // 'task',
        // 'indent',
        // 'outdent',
        // 'divider',
        // 'table',
        'image',
        'link',
        // 'divider',
        // 'code',
        // 'codeblock'
      ],
      // We just remove some menu item here.
    });
//... some not relate code here

And then write our own HTML and JS

take Vue for example

   <button @click='my_bold'>My Bold Button<button>
my_bold(){
    this.editor.exec('Bold')
}

exec is from Doc: http://nhnent.github.io/tui.editor/api/latest/CommandManager.html

this work.

MORE example is better.

So what you guys think? would you guys add more example?

Thanks.

Good First Issue ๐Ÿ™‹โ€โ™€๏ธ ๐Ÿ™‹โ€โ™‚๏ธ Help Wanted ๐Ÿค

Most helpful comment

Yes. I should write a document for this. (maybe you can help on this ๐Ÿ˜‰ )
Thanks for a good example @1c7

I'll mark it as a help wanted.
Feel free to send a PR for it. any of you.

All 6 comments

Yes. I should write a document for this. (maybe you can help on this ๐Ÿ˜‰ )
Thanks for a good example @1c7

I'll mark it as a help wanted.
Feel free to send a PR for it. any of you.

@kyuwoo-choi no problem, Thanks for reply! also thank you for building this text editor.
I am not sure If I have time to PR, but I may.
Thanks again~

you guys can close this issue anytime

Good Job @1c7
Thanks for the contribution ๐ŸŽ‰

@kyuwoo-choi you are welcome~
glad you like it haha

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igasparetto picture igasparetto  ยท  4Comments

bricepepin picture bricepepin  ยท  3Comments

Gilles-GitHub picture Gilles-GitHub  ยท  4Comments

alirizaadiyahsi picture alirizaadiyahsi  ยท  4Comments

dioscuroi picture dioscuroi  ยท  3Comments