CKEditor external file browser - javascript

I'm trying to return file url from external file browser to CKEditor but I'm receiving error which is:
[09:02:18.038] TypeError: A._.filebrowserSe is undefined # http://www.xxx.pl/yyy/js/ckeditor/ckeditor.js:56
I'm using this code:
window.parent.opener.CKEDITOR.tools.callFunction(number,url);
Does anyone know how to solve this issue?

Here is an answer: How can you integrate a custom file browser/uploader with CKEditor?
You should to receive GET parameter called CKEditorFuncNum.
I use it such way in php:
window.parent.CKEDITOR.tools.callFunction(<?=intval($_REQUEST['CKEditorFuncNum'])?>, url, message);

Related

How to read json files using javascript without using require

Whenever i tried to read my json file using the require function and using my js file from the browser an error shows " require function is not defined" so i want another method to read the json file , and if you can plz mention how to read, update, delete, insert to the json file
as i mention before i have tried using the require function , and also using the import function but using it make the situation worse since whenever i tried to use any function through the html an error shows say
"Uncaught ReferenceError: Login is not defined
at HTMLButtonElement.onclick"

Uncaught SyntaxError: expected expression, got '<' using ckeditor

I have downloaded the ckeditor4 via online builder and put the file in public folder in my project. I have the cheditor4-vue integration, but want to use the local editor instead of the CDN, so I followed the documentation and put the :url-editor in the ckeditor html tag and put the path to the ckeditor.js file in editorConfig. Now when I run my application I get the error massage Uncaught SyntaxError: expected expression, got '<' in the console. Could it be that the app is serving index.html instead of the ckeditor.js that I am pointing with my path?
One more thing, if I put the path to the ckeditor.js file in the browser, I get the content of it, like I would expect the app to do.
I got same error message before
Are you using plugin named image2?
extraPlugins: "image2,..."
If you did, remove image2 and change plugin from here: https://ckeditor.com/cke4/addon/image2
Add plugin like this way:
CKEDITOR.plugins.addExternal(
"image2",
"/static/xxx/image2/plugin.js"
);
...and dont use ckeditor default imageUpload plugin
Its work for me. No more error messages after this.
Sorry. My english so badly.
Hope this helps!

JavaScript audio file not playing on flask server

The error i am getting is :
Uncaught (in promise) DOMException: Failed to load because no supported source was found.
path of audio file is correct !
My code :
image of code
as mdn says, the constructor expects url (DOMString) to https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement/Audio
so, maybe it will be better to pass the url like localhost:3000/src/audio/your_file.mp3 to show browser what to load from server, also check if this file is accessible

Openning in a new tab an HTML file returned from the server instead of dowloading it

Im using the following JS code to fetch an HTML file embedded in the server response:
$window.open('some url...');
The file is returned in the response body and being downloaded to the computer's file system.
I wish to open the file in a new tab in the browser (Chrome) rather than dowloading it.
Thanks
i think you should try it by calling function like this :-
function myFunction() {
window.open("..some url");
}
if it still download there is must be some other problem with your code
The Content-Disposition tells the browser to treat a file as a download.
Remove that header.

Chrome Extension get local json with jQuery

I have a json with some data for a Chrome extension I'm making. The extension uses jQuery. I'm trying to read the data in my javascript though it doesn't work. I'm using jQuery.getJSON:
console.log("Start loading sets");
$.getJSON("AllSets.json", function (data) {
console.log("done");
});
I get the "Start loading sets" call, but not "done". I read the getJSON is actually to get a JSON from a server using http, so that could explain why it doesn't work for local jsons. So what should I use to read the included json?
Thanks!
To access a resource in your extension from a content script, first add it to the "web_accessible_resources" section of your manifest, then use chrome.extension.getUrl() to get a link to it. Then you can use an XMLHttpRequest (or your preferred wrapper around it) as usual.

Categories

Resources