jaredreich / pell

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies
MIT License
11.95k stars 549 forks source link

Can't delete custom elements #210

Open Siccity opened 4 years ago

Siccity commented 4 years ago

Hey, new user here. Loving pell so far!

I added some custom actions for video and others like this:

actions: [
    ...
    'image',
    {
        name: 'video',
        icon: '📹',
        title: 'Video',
        result: () => {
            const url = window.prompt('Enter the video URL')
            if (url) pell.exec('insertHTML', `<video src="` + url + `" width="400" controls>` + 
            'Your browser does not support HTML5 video.' +
            '</video>')
        }
    },
    ...
]

Inserting a video link works perfectly. But if you insert it as the last thing in the input field, you can no longer remove it, or get the cursor to the other side of it anymore. Not even pressing the Delete button can delete it.

xch1029 commented 3 years ago

the reason is that these is none text to interact with. try add &nbsp befor and after of video tag, like this:

result: () => {
    const url = window.prompt('Enter the video URL')
    if (url) pell.exec('insertHTML', `&nbsp<video src="` + url + `" width="400" controls>` + 
    'Your browser does not support HTML5 video.' +
    '</video>&nbsp')
}
xch1029 commented 3 years ago

and if you want to delete this video, you should select video and it's before and after whitespace. It's a litter unfriendly. For now, I'm looking for a better way to deal video

RossMWoods commented 3 years ago

Hi, The character for a non-breaking space needs a semi-colon at the end. i.e. &nbsp; Ross

On Wed, Jul 7, 2021 at 3:15 PM 小华 @.***> wrote:

and if you want to delete this video, you should select video and it's before and after whitespace. It's a litter unfriendly. For now, I'm looking for a better way to deal video

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jaredreich/pell/issues/210#issuecomment-875351543, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANWRHLPRZMY24JUEJZEA7KLTWP5K3ANCNFSM4QQS2QEQ .