pell icon indicating copy to clipboard operation
pell copied to clipboard

Insert HTML code into editor?

Open kvgc opened this issue 3 years ago • 0 comments

Hi, It would be great if a user is able to insert arbitrary HTML into the editor. I can get this functionality by initializing pell as follows:

    const editor = pell.init({
                        element: document.getElementById("tooltip"),
                        onChange: html => {
                        },
                        defaultParagraphSeparator: 'p',
                        styleWithCSS: true,
                        actions: [
                          'bold',
                          'quote',
                          'olist',
                          'ulist',
                          'code',
                          'link',
                          'image',

                          {
                            icon: '✎',
                            title: 'Insert HTML',
                            result: () => {
                              const url = window.prompt('Enter HTML');
                              if (url) document.execCommand('insertHTML',false, url)
                            }
                          },

                        ],
                        classes: {
                          actionbar: 'pell-actionbar',
                          button: 'pell-button',
                          content: 'pell-content',
                          selected: 'pell-button-selected'
                        }
                })

This brings up a prompt for the user to enter the HTML code. Is there a better way to achieve this functionality with pell? Thanks!

kvgc avatar Feb 05 '22 06:02 kvgc