Hello,I install the svg edit plugin today, but it does't work correctly. when I click the SVG
button, it appear some html code. Then I chage the script.js
file,I comment the first line marked
var svgeditor_path = 'https://cdn.rawgit.com/SVG-Edit/svgedit/stable/editor/'; //online stable
and add flowing code
var svgeditor_path = 'https://unpkg.com/svgedit@7.2.0/dist/editor/';
another change as flowing:
var el = document.createElement('iframe');
//el.setAttribute("src", svgeditor_path + 'svg-editor.html');
el.setAttribute("src", svgeditor_path + 'index.html');
el.setAttribute("id", "svg__edit");
el.setAttribute("name", "svg__edit");
el.setAttribute("frameborder", "0");
el.setAttribute("width", "100%");
el.setAttribute("height", "70%");
el.setAttribute("style", "min-height: 600px;");
insertAfter(el, field);
Then I can edit my svg by the editor, but the button SVG-SAVE
TXT->SVG
SVG->TXT
at the bottom of windows doesn't work. I don't know how to post image,so I post some code here.
I think there are some trouble with those code
var head = document.getElementsByTagName("head")[0];
script = document.createElement('script');
script.type = 'text/javascript';
script.src = svgeditor_path + 'embedapi.js';
head.appendChild(script);
function svgedit_load() {
var field = jQuery('#wiki__text');
if (!field) return;
field = field[0];
var timeout = setTimeout('svgedit_load();', 500); //load ASAP
window.svgedit.setSvgString(field.value) (function(a) {
clearTimeout(timeout);
}
);
}
function svgedit_save(page) {
window.svgedit.getSvgString()(function(data) {
var field = jQuery('#wiki__text');
if (!field) return;
field = field[0];
field.value = data;
if (page) {
field = jQuery('#edbtn__save');
field.click();
}
}) ;
}
function showhide(elem) {
elem.style.display = (elem.style.display == 'none' ? '' : 'none');
}
function insertAfter(newNode, preNode) {
if (preNode.nextSibling)
preNode.parentNode.insertBefore(newNode, preNode.nextSibling);
else
preNode.parentNode(newNode);
}
var svgedit = null;
function svgedit_init() {
var field = jQuery('#wiki__text');
if (!field) return;
field = field[0];
//toggle view
showhide(field);
showhide(jQuery('#tool__bar')[0]);
showhide(jQuery('#edbtn__save')[0]);
//lock
if (jQuery('#svg__edit').length) return;
//create iframe
var el = document.createElement('iframe');
el.setAttribute("src", svgeditor_path + 'svg-editor.html');
el.setAttribute("id", "svg__edit");
el.setAttribute("name", "svg__edit");
el.setAttribute("frameborder", "0");
el.setAttribute("width", "100%");
el.setAttribute("height", "70%");
el.setAttribute("style", "min-height: 600px;");
insertAfter(el, field);
//create save button
field = jQuery('#edbtn__save');
if (!field) return;
field = field[0];
el = document.createElement('input');
el.setAttribute("type", "button");
el.setAttribute("onclick", "svgedit_save(true)");
el.setAttribute("value", "SVG-SAVE");
el.setAttribute("title", "Save SVG to server");
el.setAttribute("class", "button");
field.parentNode.insertBefore(el, field);
el = document.createElement('input');
el.setAttribute("type", "button");
el.setAttribute("onclick", "svgedit_load()");
el.setAttribute("value", "TXT->SVG");
el.setAttribute("title", "Copy SVG from textarea to svg-editor");
el.setAttribute("class", "button");
field.parentNode.insertBefore(el, field);
el = document.createElement('input');
el.setAttribute("type", "button");
el.setAttribute("onclick", "svgedit_save()");
el.setAttribute("value", "SVG->TXT");
el.setAttribute("title", "Copy SVG from svg-editor to textarea");
el.setAttribute("class", "button");
field.parentNode.insertBefore(el, field);
//create embedapi
window.svgedit = new EmbeddedSVGEdit(jQuery('#svg__edit')[0]);
//load image
svgedit_load();
But I'm not too sure.
Can somebody help me .
Thanks a lot!