Preliminary SVG-edit Support
WYSIWYG SVG editing. Still no support for mixed SVG/MathML content, yet.
This commit is contained in:
parent
954bcb52c2
commit
c3ed5b461b
224 changed files with 32910 additions and 21 deletions
62
public/svg-edit/opera-widget/handlers.js
Normal file
62
public/svg-edit/opera-widget/handlers.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Note: This JavaScript file must be included as the last script on the main HTML editor page to override the open/save handlers
|
||||
$(function() {
|
||||
if(window.opera && window.opera.io && window.opera.io.filesystem) {
|
||||
svgCanvas.setCustomHandlers({
|
||||
'open':function() {
|
||||
try {
|
||||
window.opera.io.filesystem.browseForFile(
|
||||
new Date().getTime(), /* mountpoint name */
|
||||
"", /* default location */
|
||||
function(file) {
|
||||
try {
|
||||
if (file) {
|
||||
fstream = file.open(file, "r");
|
||||
var output = "";
|
||||
while (!fstream.eof) {
|
||||
output += fstream.readLine();
|
||||
}
|
||||
|
||||
svgCanvas.setSvgString(output); /* 'this' is bound to the filestream object here */
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
console.log("Reading file failed.");
|
||||
}
|
||||
},
|
||||
false, /* not persistent */
|
||||
false, /* no multiple selections */
|
||||
"*.svg" /* file extension filter */
|
||||
);
|
||||
}
|
||||
catch(e) {
|
||||
console.log("Open file failed.");
|
||||
}
|
||||
|
||||
},
|
||||
'save':function(window, svg) {
|
||||
try {
|
||||
window.opera.io.filesystem.browseForSave(
|
||||
new Date().getTime(), /* mountpoint name */
|
||||
"", /* default location */
|
||||
function(file) {
|
||||
try {
|
||||
if (file) {
|
||||
var fstream = file.open(file, "w");
|
||||
fstream.write(svg, "UTF-8");
|
||||
fstream.close();
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
console.log("Write to file failed.");
|
||||
}
|
||||
},
|
||||
false /* not persistent */
|
||||
);
|
||||
}
|
||||
catch(e) {
|
||||
console.log("Save file failed.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue