Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding custom plugin to config renders all other plugins implicitly included as not found #202

Closed
MRB60 opened this issue Feb 6, 2020 · 8 comments
Labels
Milestone

Comments

@MRB60
Copy link

MRB60 commented Feb 6, 2020

Thanks for your efforts on this!
Note: I think this is not a bug but since I am not using js modules (no import/export) and accessing suneditor via
"https://cdn.jsdelivr.net/npm/suneditor@2.25.0/dist/suneditor.min.js", I am simply not sure what the best way is to solve my issue.
When adding a new custom plugin:
plugins: [custom_plugin_submenu],
all other plugins included with "buttonList" shown an error: not found (although buttons are there).
Is there instead a possibility to add a custom plugin to the list of already defined ones (defined via buttonList)?

And perhaps a documentation issue on submenu plugin example: one need to add class="se-submenu" to the submenu html code. The Eventlistener does not trigger otherwise.

@JiHong88
Copy link
Owner

JiHong88 commented Feb 9, 2020

Hi @MRB60

Thank you.
I'll modify the example :)

Is it correct to code like the example?
Can you show me your code?

@MRB60
Copy link
Author

MRB60 commented Feb 9, 2020

It is a very simple custom submenu where one can insert/paste in an <iframe> map from Google maps or OSM (with some regex checks).
This part now works fine for me;
` setSubmenu: function () {
const listDiv = this.util.createElement('DIV');

    listDiv.className = 'se-submenu se-list-layer';
    /* se-submenu must be included otherwise onClick does not work */
    listDiv.innerHTML = '' +
                '<div class="se-list-inner se-list-align">&nbsp;Karten<br>&nbsp;HTML einfügen:' +
                '   <ul class="se-list-basic">' +
                '       <li><input class="se-input-form" type="text" style="width: 100%; border: 1px solid #CCC;" /></li>' +
                '       <li><button id="se-maps-button" type="button" class="se-btn se-tooltip">' +
                '           <span>OK</span>' +
                '           <span class="se-tooltip-inner">' +
                '               <span class="se-tooltip-text">Einfügen</span>' +
                '           </span>' +
                '       </button></li>' +
                '   </ul>' +
                '</div>';
    return listDiv;
},

`

@JiHong88
Copy link
Owner

JiHong88 commented Feb 9, 2020

Yup, "se-submenu" is a required class name.
Then does it work well now?

@MRB60
Copy link
Author

MRB60 commented Feb 9, 2020

Yes the submenu works fine.
Please also reflect on my first issue; adding my custom plugin makes all other plugins unavailable (defined in buttonList). So this does not work (from the example):
plugins: [pluginObject], buttonList: [ ['undo', 'redo', 'image'], ...
The pluginObject is callable but the ones in buttonList no more.
Note that I do not use a js module so not import/export directly possible.

@JiHong88
Copy link
Owner

JiHong88 commented Feb 9, 2020

How exactly did you put the button list?
Did you put it in this format?
The error is not reproduced :(

buttonList: [
    ['undo', 'redo', 'image'],
    [
        {
            name: 'custom_plugin_submenu', 
            dataCommand: 'custom_plugin_submenu',
            buttonClass:'', 
            title:'Custom plugin of the submenu', 
            dataDisplay:'submenu',
            innerHTML:'<i class="se-icon-add"></i>'
        }
    ]
]

@MRB60
Copy link
Author

MRB60 commented Feb 9, 2020

OK.
maps is the name of the plugin, plugin defined as const maps = { ...
Thus no import in this case.

Config looks as follows:

		lang: SUNEDITOR_LANG['de'],
		plugins: [maps], // makes all other plugins to fail - q in github
		buttonList: [
		    ['undo', 'redo', 'image'],
		    [
		        {
		            name: 'maps', 
		            dataCommand: 'maps',
		            buttonClass:'', 
		            title:'Custom plugin of the submenu', 
		            dataDisplay:'submenu',
		            innerHTML:'<i class="se-icon-add"></i>'
		        }
		    ]
		],
		showPathLabel : false,
		charCounter : true,

:
etc.
Error when clicking on image button:

suneditor.min.js:1 jsdelivr.comUncaught Error: [SUNEDITOR.core.callPlugin.fail] The called plugin does not exist or is in an invalid format. (pluginName:"image")
at Object.callPlugin (suneditor.min.js:1)
at HTMLDivElement.onClick_toolbar (suneditor.min.js:1)
callPlugin @ suneditor.min.js:1
onClick_toolbar @ suneditor.min.js:1:

@MRB60
Copy link
Author

MRB60 commented Feb 9, 2020

I found the problem.
I am setting config after create:
let suneditor = SUNEDITOR.create(...
suneditor.setOptions(editorconfig);

This does not work with custom plugins.
Works:
let suneditor = SUNEDITOR.create((document.getElementById('suneditor') || 'suneditor'), editorconfig);

@JiHong88 JiHong88 added the bug label Feb 11, 2020
@JiHong88 JiHong88 added this to the 2.26.0 milestone Mar 4, 2020
@JiHong88 JiHong88 closed this as completed Mar 4, 2020
@JiHong88
Copy link
Owner

The 2.26.0 version has been updated.
If there is an issue, please register as a new issue.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants