mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-25 11:48:21 +01:00
image insert
This commit is contained in:
parent
a033ea21c5
commit
0eee08855c
@ -34,7 +34,7 @@ afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button:hover, afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button.btactive button
|
||||
afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button:hover, afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button.btactive
|
||||
{
|
||||
border: 1px solid #759DC0;
|
||||
background-color: transparent;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
main() {
|
||||
// load session class
|
||||
if (!OpenPage.editorSession) {
|
||||
if (!OpenPage.EditorSession) {
|
||||
require(["webodf/editor/EditorSession"], function(ES) {
|
||||
return OpenPage.EditorSession = ES;
|
||||
});
|
||||
@ -79,12 +79,10 @@
|
||||
el.classList.add("notranslate");
|
||||
this.userid = "localuser";
|
||||
this.canvas = new odf.OdfCanvas(el);
|
||||
this.documentChanged = function(e) {
|
||||
return console.log(e);
|
||||
};
|
||||
this.metaChanged = function(e) {
|
||||
return console.log(e);
|
||||
};
|
||||
this.documentChanged = function(e) {};
|
||||
//console.log e
|
||||
this.metaChanged = function(e) {};
|
||||
//console.log e
|
||||
this.textStylingChanged = function(e) {
|
||||
return me.updateToolbar(e);
|
||||
};
|
||||
@ -124,6 +122,13 @@
|
||||
me.eventSubscriptions.addFrameSubscription(me.editorSession, OpenPage.EditorSession.signalParagraphStyleModified, function() {
|
||||
return me.updateHyperlinkButtons();
|
||||
});
|
||||
|
||||
//image controller
|
||||
me.imageController = me.editorSession.sessionController.getImageController();
|
||||
//imageController.subscribe(gui.ImageController.enabledChanged, enableButtons)
|
||||
|
||||
//text controller
|
||||
me.textController = me.editorSession.sessionController.getTextController();
|
||||
me.editorSession.sessionController.setUndoManager(new gui.TrivialUndoManager());
|
||||
me.editorSession.sessionController.getUndoManager().subscribe(gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged);
|
||||
me.editorSession.sessionController.getMetadataController().subscribe(gui.MetadataController.signalMetadataChanged, me.metaChanged);
|
||||
@ -311,6 +316,53 @@
|
||||
return this.hyperlinkController.removeHyperlinks();
|
||||
}
|
||||
|
||||
undo(e) {
|
||||
return this.editorSession.undo();
|
||||
}
|
||||
|
||||
redo(e) {
|
||||
return this.editorSession.redo();
|
||||
}
|
||||
|
||||
image(e) {
|
||||
var me;
|
||||
me = this;
|
||||
return this.openDialog("FileDiaLog", function(d, n, p) {
|
||||
var fp;
|
||||
fp = p.asFileHandler();
|
||||
return fp.asFileHandler().read(function(data) {
|
||||
var blob, reader;
|
||||
blob = new Blob([data], {
|
||||
type: fp.info.mime
|
||||
});
|
||||
reader = new FileReader();
|
||||
reader.onloadend = function() {
|
||||
var hiddenImage;
|
||||
if (reader.readyState !== 2) {
|
||||
return me.error(__("Couldnt load image {0}", p));
|
||||
}
|
||||
// insert the image to document
|
||||
hiddenImage = new Image();
|
||||
hiddenImage.style.position = "absolute";
|
||||
hiddenImage.style.left = "-99999px";
|
||||
document.body.appendChild(hiddenImage);
|
||||
hiddenImage.onload = function() {
|
||||
var content;
|
||||
content = reader.result.substring(reader.result.indexOf(",") + 1);
|
||||
//insert image
|
||||
me.textController.removeCurrentSelection();
|
||||
me.imageController.insertImage(fp.info.mime, content, hiddenImage.width, hiddenImage.height);
|
||||
return document.body.removeChild(hiddenImage);
|
||||
};
|
||||
return hiddenImage.src = reader.result;
|
||||
};
|
||||
return reader.readAsDataURL(blob);
|
||||
}, "binary");
|
||||
}, __("Select image file"), {
|
||||
mimes: ["image/.*"]
|
||||
});
|
||||
}
|
||||
|
||||
closeDocument() {
|
||||
var me, op;
|
||||
// finish editing
|
||||
@ -354,7 +406,9 @@
|
||||
return me.notify("Document closed");
|
||||
});
|
||||
me.session = void 0;
|
||||
return me.directFormattingCtl = void 0;
|
||||
me.directFormattingCtl = void 0;
|
||||
me.textController = void 0;
|
||||
return me.imageController = void 0;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -4,7 +4,7 @@ class OpenPage extends this.OS.GUI.BaseApplication
|
||||
|
||||
main: () ->
|
||||
# load session class
|
||||
if not OpenPage.editorSession
|
||||
if not OpenPage.EditorSession
|
||||
require ["webodf/editor/EditorSession"], (ES) ->
|
||||
OpenPage.EditorSession = ES
|
||||
@eventSubscriptions = new core.EventSubscriptions()
|
||||
@ -56,9 +56,9 @@ class OpenPage extends this.OS.GUI.BaseApplication
|
||||
@userid = "localuser"
|
||||
@canvas = new odf.OdfCanvas(el)
|
||||
@documentChanged = (e) ->
|
||||
console.log e
|
||||
#console.log e
|
||||
@metaChanged = (e) ->
|
||||
console.log e
|
||||
#console.log e
|
||||
@textStylingChanged = (e) ->
|
||||
me.updateToolbar e
|
||||
#@canvas.enableAnnotations(true, true)
|
||||
@ -90,7 +90,14 @@ class OpenPage extends this.OS.GUI.BaseApplication
|
||||
me.eventSubscriptions.addFrameSubscription me.editorSession, OpenPage.EditorSession.signalCursorMoved, ()-> me.updateHyperlinkButtons()
|
||||
me.eventSubscriptions.addFrameSubscription me.editorSession, OpenPage.EditorSession.signalParagraphChanged, ()-> me.updateHyperlinkButtons()
|
||||
me.eventSubscriptions.addFrameSubscription me.editorSession, OpenPage.EditorSession.signalParagraphStyleModified, ()-> me.updateHyperlinkButtons()
|
||||
|
||||
|
||||
#image controller
|
||||
me.imageController = me.editorSession.sessionController.getImageController()
|
||||
#imageController.subscribe(gui.ImageController.enabledChanged, enableButtons)
|
||||
|
||||
#text controller
|
||||
me.textController = me.editorSession.sessionController.getTextController()
|
||||
|
||||
me.editorSession.sessionController.setUndoManager new gui.TrivialUndoManager()
|
||||
me.editorSession.sessionController.getUndoManager().subscribe gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged
|
||||
me.editorSession.sessionController.getMetadataController().subscribe gui.MetadataController.signalMetadataChanged, me.metaChanged
|
||||
@ -220,6 +227,38 @@ class OpenPage extends this.OS.GUI.BaseApplication
|
||||
unlink: (e) ->
|
||||
@hyperlinkController.removeHyperlinks()
|
||||
|
||||
undo: (e) ->
|
||||
@editorSession.undo()
|
||||
|
||||
redo: (e) ->
|
||||
@editorSession.redo()
|
||||
|
||||
image: (e) ->
|
||||
me = @
|
||||
@openDialog "FileDiaLog", (d, n, p) ->
|
||||
fp = p.asFileHandler()
|
||||
fp.asFileHandler().read (data) ->
|
||||
blob = new Blob [data], { type: fp.info.mime }
|
||||
reader = new FileReader()
|
||||
reader.onloadend = () ->
|
||||
return me.error __("Couldnt load image {0}", p) if reader.readyState isnt 2
|
||||
# insert the image to document
|
||||
hiddenImage = new Image()
|
||||
hiddenImage.style.position = "absolute"
|
||||
hiddenImage.style.left = "-99999px"
|
||||
document.body.appendChild hiddenImage
|
||||
hiddenImage.onload = () ->
|
||||
content = reader.result.substring(reader.result.indexOf(",") + 1)
|
||||
#insert image
|
||||
me.textController.removeCurrentSelection()
|
||||
me.imageController.insertImage fp.info.mime, content, hiddenImage.width, hiddenImage.height
|
||||
document.body.removeChild hiddenImage
|
||||
hiddenImage.src = reader.result
|
||||
|
||||
reader.readAsDataURL blob
|
||||
, "binary"
|
||||
, __("Select image file"), { mimes: ["image/.*"] }
|
||||
|
||||
closeDocument: () ->
|
||||
# finish editing
|
||||
return unless @editorSession and @session
|
||||
@ -252,6 +291,8 @@ class OpenPage extends this.OS.GUI.BaseApplication
|
||||
me.notify "Document closed"
|
||||
me.session = undefined
|
||||
me.directFormattingCtl = undefined
|
||||
me.textController = undefined
|
||||
me.imageController = undefined
|
||||
#
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button:hover, afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button.btactive button
|
||||
afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button:hover, afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button.btactive
|
||||
{
|
||||
border: 1px solid #759DC0;
|
||||
background-color: transparent;
|
||||
|
Loading…
Reference in New Issue
Block a user