summernote icon indicating copy to clipboard operation
summernote copied to clipboard

Custom button not working : context is undefined

Open sedovserge opened this issue 7 years ago • 17 comments

Custom button not working in 0.8.12 : context is undefined

Error in 0.8.12 : https://jsfiddle.net/4kq7ws9z/ but same code it works in 0.8.10 : https://jsfiddle.net/8fm5vq50/17/

sedovserge avatar May 22 '19 12:05 sedovserge

The same. 'context' variable is not available in the custom button callback anymore. I used it in context.invoke('editor.saveRange'); and context.invoke('editor.restoreRange'); - Do we still need that anyway?

bariew avatar May 29 '19 05:05 bariew

So by what replacing the context.invoke('editor.insertText', 'hello'); like showed in example page ?

xillibit avatar Jun 08 '19 15:06 xillibit

#3150 seems to be a related issue. I would like to see this fixed as well.

I found a workaround in this older answer on SO:

Instead of context.invoke('editor.insertText', 'hello'); use $('#editorID').summernote('editor.insertText', 'hello');

It works, but I would hardly call this a good permanent solution...

TOPVeric avatar Jun 27 '19 07:06 TOPVeric

The change happened in v0.8.12 (7b2a514) in response to a different bug. But I can't figure out how to use insertText with the new version.

lstarky avatar Jul 19 '19 16:07 lstarky

https://summernote.org/deep-dive/#insertion-api As this has been open for some time now, and I hope you were able to resolve your issue, I'll close this. If it's still an issue, please reopen or create a new issue.

DennisSuitters avatar Oct 06 '19 05:10 DennisSuitters

Please also update the documentation.

d1rty-pixel avatar Oct 09 '19 07:10 d1rty-pixel

The documentation shows how to insert different things. What do you think needs updating? Or, if you have a better way to explain the current explainations you are welcome to do a PR fixing those. You can do that here: https://github.com/summernote/summernote.github.io

DennisSuitters avatar Oct 09 '19 07:10 DennisSuitters

The documentation on custom buttons refer to the context parameter (which is undefined), which makes the given example not work. See https://summernote.org/deep-dive/#custom-button

d1rty-pixel avatar Oct 09 '19 09:10 d1rty-pixel

FYI: this bug has been fixed in https://github.com/summernote/summernote/pull/3284 (which reverted commit https://github.com/summernote/summernote/commit/7b2a514f5d53edeffcb8c67cde30eb59381d7f75), but it's still on the develop branch.

TOPVeric avatar Oct 09 '19 09:10 TOPVeric

Thanks @TOPVeric for mentioning that. Could we please make sure we are using the develop branch version, and that issue isn't persistent there.

DennisSuitters avatar Oct 09 '19 09:10 DennisSuitters

FYI: this bug has been fixed in #3284 (which reverted commit 7b2a514), but it's still on the develop branch.

Can you please merge this into the original code, because I have downloaded the summernote-bs4.js and not from any branch.

invinciblemuffi avatar Oct 14 '19 13:10 invinciblemuffi

FYI: this bug has been fixed in #3284 (which reverted commit 7b2a514), but it's still on the develop branch.

Can you please merge this into the original code, because I have downloaded the summernote-bs4.js and not from any branch.

I'm not one of the developers, I'm just following this issue since I'm having problems with this bug as well.

TOPVeric avatar Oct 14 '19 13:10 TOPVeric

Not sure when the develop branch will be merged to master, you can clone the development branch, install npm in the clone and build the project, then grab the files you need out of the dist/ folder,

DennisSuitters avatar Oct 14 '19 13:10 DennisSuitters

Thanks for the quick response.

invinciblemuffi avatar Oct 14 '19 14:10 invinciblemuffi

Just to make sure: I assume the Closed status doesn't mean this won't eventually reach master right? We do need this feature, but we can stay on an older version for now. So there is no rush, I just want to make sure this will eventually reach master and the nuget package.

eriksteinebach avatar Oct 16 '19 15:10 eriksteinebach

Just to make sure: I assume the Closed status doesn't mean this won't eventually reach master right? We do need this feature, but we can stay on an older version for now. So there is no rush, I just want to make sure this will eventually reach master and the nuget package.

AFAIK, closed only means that this issue is closed/resolved. The solution has been merged into the develop branch, which will eventually be merged into master and published to npm as a new version. I don't know when that will be though.

TOPVeric avatar Oct 17 '19 07:10 TOPVeric

You can if you wish, clone the develop branch, and build the project to get the latest changes. Install and running NPM instructions can b found here https://github.com/summernote/summernote/blob/develop/.github/CONTRIBUTING.md

DennisSuitters avatar Oct 17 '19 09:10 DennisSuitters