Comments (3)
@alanwillms thank you very much for this tip! Is there a way to do that within the library? Maybe we should write a js module like I did with Editable that will handle this? Is there a way to access the button with a different selector?
from yii2-ckeditor-widget.
@tonydspaniard, this only works as long as our Upload
tab is the third matched element, i.e. you only have a single widget on the page with default image plugin. It breaks if you have multiple widgets loaded or, as in my particular case, when you load the widget several times via ajax (e.g. when the user wants to edit the content). If several widgets are added without reloading the page, eq(2)
matches the old Upload
tab instead of the new one. It also breaks if you use a different image plugin which has a different number of tabs.
The following modification seems to be generic enough to cover multiple widgets on the same page, different languages (thanks, @mbv) and different image plugins, as long as the id
of an Upload
tab starts with cke_Upload_
. There would also be several forms (including old ones) on the page, so it iterates over them all to add a token if missing:
yii & $(document).off('click', '.cke_dialog_tabs a[id^="cke_Upload_"]').on('click', '.cke_dialog_tabs a[id^="cke_Upload_"]', function () {
var $forms = $('.cke_dialog_ui_input_file iframe').contents().find('form');
var csrfName = yii.getCsrfParam();
$forms.each(function () {
if (!$(this).find('input[name=' + csrfName + ']').length) {
var csrfTokenInput = $('<input/>').attr({
'type': 'hidden',
'name': csrfName
}).val(yii.getCsrfToken());
$(this).append(csrfTokenInput);
}
});
});
from yii2-ckeditor-widget.
@nirvana-msu do you mind providing a PR for that change? I would be more than happy to merge it (but please, make sure tests pass, I have been forced not to merge others due to that issue)
thanks!
from yii2-ckeditor-widget.
Related Issues (20)
- Problem in sending CSRF token HOT 1
- Unable to change default font HOT 2
- Problem in adding extra plugin HOT 3
- Class 'dosamigos\ckeditor\CKEditor' not found HOT 5
- how can I do a custom preset or remove some buttons from basic? HOT 1
- Several features are not available HOT 1
- pastefromword button is not showing up HOT 1
- Any plan to include full ckeditor release instead of just the standard one? HOT 2
- Simpy can't upload image HOT 3
- Not all buttons are showing in full preset mode HOT 15
- Installation failed, requirements could not be resolved to an installable set of packages HOT 7
- Align button not showing up HOT 3
- CKEditor inside yii2-dynamicform
- Easy Image Plugin HOT 1
- Removing Div tag automatically
- How to install KC finder? HOT 2
- How to prevent tag stripping? HOT 1
- Help Needed
- Upload to private directory
- how to fix this error, i tryna use basic template but come this error in console
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-ckeditor-widget.