Update to current WebODF pullbox branch. Closes #13

pull/1/head
Friedrich W. H. Kossebau 11 years ago
parent 3614295e1e
commit dd4d49d408

@ -44,8 +44,10 @@ define("webodf/editor/EditorSession", [
return [ "../../webodf/lib" ]; return [ "../../webodf/lib" ];
}; };
runtime.loadClass("core.DomUtils");
runtime.loadClass("ops.OdtDocument"); runtime.loadClass("ops.OdtDocument");
runtime.loadClass("ops.Session"); runtime.loadClass("ops.Session");
runtime.loadClass("odf.Namespaces");
runtime.loadClass("odf.OdfCanvas"); runtime.loadClass("odf.OdfCanvas");
runtime.loadClass("gui.CaretManager"); runtime.loadClass("gui.CaretManager");
runtime.loadClass("gui.Caret"); runtime.loadClass("gui.Caret");
@ -69,10 +71,11 @@ define("webodf/editor/EditorSession", [
currentStyleName = null, currentStyleName = null,
caretManager, caretManager,
odtDocument = session.getOdtDocument(), odtDocument = session.getOdtDocument(),
textns = "urn:oasis:names:tc:opendocument:xmlns:text:1.0", textns = odf.Namespaces.textns,
fontStyles = document.createElement('style'), fontStyles = document.createElement('style'),
formatting = odtDocument.getFormatting(), formatting = odtDocument.getFormatting(),
styleHelper = new gui.StyleHelper(formatting), styleHelper = new gui.StyleHelper(formatting),
domUtils = new core.DomUtils(),
eventNotifier = new core.EventNotifier([ eventNotifier = new core.EventNotifier([
EditorSession.signalMemberAdded, EditorSession.signalMemberAdded,
EditorSession.signalMemberRemoved, EditorSession.signalMemberRemoved,
@ -89,6 +92,15 @@ define("webodf/editor/EditorSession", [
this.sessionView = new gui.SessionView(config.viewOptions, session, caretManager); this.sessionView = new gui.SessionView(config.viewOptions, session, caretManager);
this.availableFonts = []; this.availableFonts = [];
function isTrueForSelection(predicate) {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return predicate(cursor.getSelectedRange());
}
/* /*
* @return {Array.{!string}} * @return {Array.{!string}}
*/ */
@ -192,11 +204,15 @@ define("webodf/editor/EditorSession", [
} }
function trackCurrentParagraph(info) { function trackCurrentParagraph(info) {
if (info.paragraphElement !== currentParagraphNode) { var cursor = odtDocument.getCursor(localMemberId),
return; range = cursor && cursor.getSelectedRange(),
paragraphRange = odtDocument.getDOM().createRange();
paragraphRange.selectNode(info.paragraphElement);
if ((range && domUtils.rangesIntersect(range, paragraphRange)) || info.paragraphElement === currentParagraphNode) {
self.emit(EditorSession.signalParagraphChanged, info);
checkParagraphStyleName();
} }
self.emit(EditorSession.signalParagraphChanged, info); paragraphRange.detach();
checkParagraphStyleName();
} }
function onCursorAdded(cursor) { function onCursorAdded(cursor) {
@ -283,41 +299,15 @@ define("webodf/editor/EditorSession", [
return formatting.getAvailableParagraphStyles(); return formatting.getAvailableParagraphStyles();
}; };
this.isBold = function () { this.isBold = isTrueForSelection.bind(self, styleHelper.isBold);
var cursor = odtDocument.getCursor(localMemberId); this.isItalic = isTrueForSelection.bind(self, styleHelper.isItalic);
// no own cursor yet/currently added? this.hasUnderline = isTrueForSelection.bind(self, styleHelper.hasUnderline);
if (!cursor) { this.hasStrikeThrough = isTrueForSelection.bind(self, styleHelper.hasStrikeThrough);
return false;
}
return styleHelper.isBold(cursor.getSelectedRange());
};
this.isItalic = function () { this.isAlignedLeft = isTrueForSelection.bind(self, styleHelper.isAlignedLeft);
var cursor = odtDocument.getCursor(localMemberId); this.isAlignedCenter = isTrueForSelection.bind(self, styleHelper.isAlignedCenter);
// no own cursor yet/currently added? this.isAlignedRight = isTrueForSelection.bind(self, styleHelper.isAlignedRight);
if (!cursor) { this.isAlignedJustified = isTrueForSelection.bind(self, styleHelper.isAlignedJustified);
return false;
}
return styleHelper.isItalic(cursor.getSelectedRange());
};
this.hasUnderline = function () {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return styleHelper.hasUnderline(cursor.getSelectedRange());
};
this.hasStrikeThrough = function () {
var cursor = odtDocument.getCursor(localMemberId);
// no own cursor yet/currently added?
if (!cursor) {
return false;
}
return styleHelper.hasStrikeThrough(cursor.getSelectedRange());
};
this.getCurrentParagraphStyle = function () { this.getCurrentParagraphStyle = function () {
return currentNamedStyleName; return currentNamedStyleName;

@ -56,14 +56,14 @@ define("webodf/editor/MemberListView",
*/ */
function updateAvatarButton(memberId, memberDetails) { function updateAvatarButton(memberId, memberDetails) {
var node = memberListDiv.firstChild; var node = memberListDiv.firstChild;
if (memberDetails === null) {
// 'null' here means finally unknown member // this takes care of incorrectly implemented MemberModels,
// (and not that the data is still loading) // which might end up returning undefined member data
memberDetails = { if (!memberDetails) {
memberid: memberId, fullname: "Unknown", runtime.log("MemberModel sent undefined data for member \"" + memberId + "\".");
color: "black", imageurl: "avatar-joe.png" return;
};
} }
while (node) { while (node) {
if (node.memberId === memberId) { if (node.memberId === memberId) {
node = node.firstChild; node = node.firstChild;

@ -41,12 +41,13 @@ define("webodf/editor/Tools", [
"dijit/form/Button", "dijit/form/Button",
"dijit/form/DropDownButton", "dijit/form/DropDownButton",
"dijit/Toolbar", "dijit/Toolbar",
"webodf/editor/widgets/paragraphAlignment",
"webodf/editor/widgets/simpleStyles", "webodf/editor/widgets/simpleStyles",
"webodf/editor/widgets/undoRedoMenu", "webodf/editor/widgets/undoRedoMenu",
"webodf/editor/widgets/toolbarWidgets/currentStyle", "webodf/editor/widgets/toolbarWidgets/currentStyle",
"webodf/editor/widgets/paragraphStylesDialog", "webodf/editor/widgets/paragraphStylesDialog",
"webodf/editor/widgets/zoomSlider"], "webodf/editor/widgets/zoomSlider"],
function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, SimpleStyles, UndoRedoMenu, CurrentStyle, ParagraphStylesDialog, ZoomSlider) { function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, ParagraphAlignment, SimpleStyles, UndoRedoMenu, CurrentStyle, ParagraphStylesDialog, ZoomSlider) {
"use strict"; "use strict";
return function Tools(args) { return function Tools(args) {
@ -60,26 +61,18 @@ define("webodf/editor/Tools", [
paragraphStylesMenuItem, paragraphStylesDialog, simpleStyles, currentStyle, paragraphStylesMenuItem, paragraphStylesDialog, simpleStyles, currentStyle,
zoomSlider, zoomSlider,
undoRedoMenu, undoRedoMenu,
editorSession; editorSession,
paragraphAlignment,
sessionSubscribers = [];
this.setEditorSession = function(session) { function setEditorSession(session) {
editorSession = session; editorSession = session;
if (undoRedoMenu) { sessionSubscribers.forEach(function (subscriber) {
undoRedoMenu.setEditorSession(session); subscriber.setEditorSession(editorSession);
} });
if (simpleStyles) { }
simpleStyles.setEditorSession(session);
} this.setEditorSession = setEditorSession;
if (currentStyle) {
currentStyle.setEditorSession(session);
}
if (zoomSlider) {
zoomSlider.setEditorSession(session);
}
if (paragraphStylesDialog) {
paragraphStylesDialog.setEditorSession(session);
}
};
/** /**
* @param {!function(!Object=)} callback, passing an error object in case of error * @param {!function(!Object=)} callback, passing an error object in case of error
@ -101,7 +94,7 @@ define("webodf/editor/Tools", [
widget.placeAt(toolbar); widget.placeAt(toolbar);
widget.startup(); widget.startup();
}); });
undoRedoMenu.setEditorSession(editorSession); sessionSubscribers.push(undoRedoMenu);
} }
// Simple Style Selector [B, I, U, S] // Simple Style Selector [B, I, U, S]
@ -110,22 +103,32 @@ define("webodf/editor/Tools", [
widget.placeAt(toolbar); widget.placeAt(toolbar);
widget.startup(); widget.startup();
}); });
simpleStyles.setEditorSession(editorSession); sessionSubscribers.push(simpleStyles);
} }
// Paragraph direct alignment buttons
if (args.directStylingEnabled) {
paragraphAlignment = new ParagraphAlignment(function (widget) {
widget.placeAt(toolbar);
widget.startup();
});
sessionSubscribers.push(paragraphAlignment);
}
// Paragraph Style Selector // Paragraph Style Selector
currentStyle = new CurrentStyle(function (widget) { currentStyle = new CurrentStyle(function (widget) {
widget.placeAt(toolbar); widget.placeAt(toolbar);
widget.startup(); widget.startup();
}); });
currentStyle.setEditorSession(editorSession); sessionSubscribers.push(currentStyle);
// Zoom Level Selector // Zoom Level Selector
zoomSlider = new ZoomSlider(function (widget) { zoomSlider = new ZoomSlider(function (widget) {
widget.placeAt(toolbar); widget.placeAt(toolbar);
widget.startup(); widget.startup();
}); });
zoomSlider.setEditorSession(editorSession); sessionSubscribers.push(zoomSlider);
// Load // Load
if (loadOdtFile) { if (loadOdtFile) {
@ -174,7 +177,7 @@ define("webodf/editor/Tools", [
} }
}; };
}); });
paragraphStylesDialog.setEditorSession(editorSession); sessionSubscribers.push(paragraphStylesDialog);
formatMenuButton = new DropDownButton({ formatMenuButton = new DropDownButton({
dropDown: formatDropDownMenu, dropDown: formatDropDownMenu,
@ -215,6 +218,8 @@ define("webodf/editor/Tools", [
}); });
closeButton.placeAt(toolbar); closeButton.placeAt(toolbar);
} }
setEditorSession(editorSession);
}); });
}; };

@ -41,6 +41,12 @@ define({
edit: "Bearbeiten", edit: "Bearbeiten",
view: "Ansicht", view: "Ansicht",
annotate: "Kommentieren", annotate: "Kommentieren",
justifyLeft: "Linksbündig",
justifyCenter: "Zentriert",
justifyRight: "Rechtsbündig",
justifyFull: "Blocksatz",
indent: "Einzug erhöhen",
outdent: "Einzug vermindern",
clone: "Kopiere", clone: "Kopiere",
create: "Erzeuge", create: "Erzeuge",
delete: "Entferne", delete: "Entferne",

@ -40,6 +40,12 @@ define({
edit: "Edit", edit: "Edit",
view: "View", view: "View",
annotate: "Annotate", annotate: "Annotate",
justifyLeft: "Align Left",
justifyCenter: "Centered",
justifyRight: "Align Right",
justifyFull: "Justified",
indent: "Increase Indent",
outdent: "Decrease Indent",
clone: "Clone", clone: "Clone",
create: "Create", create: "Create",
delete: "Delete", delete: "Delete",

@ -226,6 +226,14 @@ define("webodf/editor/server/pullbox/MemberModel", [], function () {
if (memberData) { if (memberData) {
// data available from cache // data available from cache
subscriber(memberId, memberData); subscriber(memberId, memberData);
} else {
// pass temporary data
subscriber(memberId, {
memberid: memberId,
fullname: "Unknown",
color: "black",
imageurl: ""
});
} }
}; };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save