Update to latest WebODF pullbox branch
Noticable changes: * focus returns to canvas after usage of zoom tool or paragraph style dialog * Default paragraph style is listed with normal paragraph styles * Cursor is not hidden, but shown non-blinking if tool is used
This commit is contained in:
parent
0f1b1d5018
commit
a7ad5632cb
1
js/3rdparty/webodf/editor/Editor.js
vendored
1
js/3rdparty/webodf/editor/Editor.js
vendored
@ -110,7 +110,6 @@ define("webodf/editor/Editor", [
|
|||||||
pendingEditorReadyCallback = editorReadyCallback;
|
pendingEditorReadyCallback = editorReadyCallback;
|
||||||
|
|
||||||
odfCanvas.load(initialDocumentUrl);
|
odfCanvas.load(initialDocumentUrl);
|
||||||
odfCanvas.setEditable(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
96
js/3rdparty/webodf/editor/EditorSession.js
vendored
96
js/3rdparty/webodf/editor/EditorSession.js
vendored
@ -66,7 +66,7 @@ define("webodf/editor/EditorSession", [
|
|||||||
var EditorSession = function EditorSession(session, localMemberId, config) {
|
var EditorSession = function EditorSession(session, localMemberId, config) {
|
||||||
var self = this,
|
var self = this,
|
||||||
currentParagraphNode = null,
|
currentParagraphNode = null,
|
||||||
currentNamedStyleName = null,
|
currentCommonStyleName = null,
|
||||||
currentStyleName = null,
|
currentStyleName = null,
|
||||||
caretManager,
|
caretManager,
|
||||||
odtDocument = session.getOdtDocument(),
|
odtDocument = session.getOdtDocument(),
|
||||||
@ -79,8 +79,8 @@ define("webodf/editor/EditorSession", [
|
|||||||
EditorSession.signalMemberRemoved,
|
EditorSession.signalMemberRemoved,
|
||||||
EditorSession.signalCursorMoved,
|
EditorSession.signalCursorMoved,
|
||||||
EditorSession.signalParagraphChanged,
|
EditorSession.signalParagraphChanged,
|
||||||
EditorSession.signalCommonParagraphStyleCreated,
|
EditorSession.signalCommonStyleCreated,
|
||||||
EditorSession.signalCommonParagraphStyleDeleted,
|
EditorSession.signalCommonStyleDeleted,
|
||||||
EditorSession.signalParagraphStyleModified,
|
EditorSession.signalParagraphStyleModified,
|
||||||
EditorSession.signalUndoStackChanged]);
|
EditorSession.signalUndoStackChanged]);
|
||||||
|
|
||||||
@ -113,24 +113,31 @@ define("webodf/editor/EditorSession", [
|
|||||||
|
|
||||||
function checkParagraphStyleName() {
|
function checkParagraphStyleName() {
|
||||||
var newStyleName,
|
var newStyleName,
|
||||||
newNamedStyleName;
|
newCommonStyleName;
|
||||||
|
|
||||||
newStyleName = currentParagraphNode.getAttributeNS(textns, 'style-name');
|
newStyleName = currentParagraphNode.getAttributeNS(textns, 'style-name');
|
||||||
|
|
||||||
if (newStyleName !== currentStyleName) {
|
if (newStyleName !== currentStyleName) {
|
||||||
currentStyleName = newStyleName;
|
currentStyleName = newStyleName;
|
||||||
// check if named style is still the same
|
// check if common style is still the same
|
||||||
newNamedStyleName = formatting.getFirstNamedParentStyleNameOrSelf(newStyleName);
|
newCommonStyleName = formatting.getFirstCommonParentStyleNameOrSelf(newStyleName);
|
||||||
if (!newNamedStyleName) {
|
if (!newCommonStyleName) {
|
||||||
// TODO: how to handle default styles?
|
// Default style, empty-string name
|
||||||
return;
|
currentCommonStyleName = newStyleName = currentStyleName = "";
|
||||||
}
|
|
||||||
// a named style
|
|
||||||
if (newNamedStyleName !== currentNamedStyleName) {
|
|
||||||
currentNamedStyleName = newNamedStyleName;
|
|
||||||
self.emit(EditorSession.signalParagraphChanged, {
|
self.emit(EditorSession.signalParagraphChanged, {
|
||||||
type: 'style',
|
type: 'style',
|
||||||
node: currentParagraphNode,
|
node: currentParagraphNode,
|
||||||
styleName: currentNamedStyleName
|
styleName: currentCommonStyleName
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// a common style
|
||||||
|
if (newCommonStyleName !== currentCommonStyleName) {
|
||||||
|
currentCommonStyleName = newCommonStyleName;
|
||||||
|
self.emit(EditorSession.signalParagraphChanged, {
|
||||||
|
type: 'style',
|
||||||
|
node: currentParagraphNode,
|
||||||
|
styleName: currentCommonStyleName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,11 +229,11 @@ define("webodf/editor/EditorSession", [
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onStyleCreated(newStyleName) {
|
function onStyleCreated(newStyleName) {
|
||||||
self.emit(EditorSession.signalCommonParagraphStyleCreated, newStyleName);
|
self.emit(EditorSession.signalCommonStyleCreated, newStyleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onStyleDeleted(styleName) {
|
function onStyleDeleted(styleName) {
|
||||||
self.emit(EditorSession.signalCommonParagraphStyleDeleted, styleName);
|
self.emit(EditorSession.signalCommonStyleDeleted, styleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onParagraphStyleModified(styleName) {
|
function onParagraphStyleModified(styleName) {
|
||||||
@ -289,7 +296,7 @@ define("webodf/editor/EditorSession", [
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.getCurrentParagraphStyle = function () {
|
this.getCurrentParagraphStyle = function () {
|
||||||
return currentNamedStyleName;
|
return currentCommonStyleName;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -316,7 +323,7 @@ define("webodf/editor/EditorSession", [
|
|||||||
|
|
||||||
this.setCurrentParagraphStyle = function (value) {
|
this.setCurrentParagraphStyle = function (value) {
|
||||||
var op;
|
var op;
|
||||||
if (currentNamedStyleName !== value) {
|
if (currentCommonStyleName !== value) {
|
||||||
op = new ops.OpSetParagraphStyle();
|
op = new ops.OpSetParagraphStyle();
|
||||||
op.init({
|
op.init({
|
||||||
memberid: localMemberId,
|
memberid: localMemberId,
|
||||||
@ -341,8 +348,17 @@ define("webodf/editor/EditorSession", [
|
|||||||
session.enqueue(op);
|
session.enqueue(op);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a style name and returns the corresponding paragraph style
|
||||||
|
* element. If the style name is an empty string, the default style
|
||||||
|
* is returned.
|
||||||
|
* @param {!string} styleName
|
||||||
|
* @return {Element}
|
||||||
|
*/
|
||||||
this.getParagraphStyleElement = function (styleName) {
|
this.getParagraphStyleElement = function (styleName) {
|
||||||
return odtDocument.getParagraphStyleElement(styleName);
|
return (styleName === "")
|
||||||
|
? formatting.getDefaultStyleElement('paragraph')
|
||||||
|
: odtDocument.getParagraphStyleElement(styleName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -354,8 +370,26 @@ define("webodf/editor/EditorSession", [
|
|||||||
return formatting.isStyleUsed(styleElement);
|
return formatting.isStyleUsed(styleElement);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getDefaultParagraphStyleAttributes () {
|
||||||
|
var styleNode = formatting.getDefaultStyleElement('paragraph');
|
||||||
|
if (styleNode) {
|
||||||
|
return formatting.getInheritedStyleAttributes(styleNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the attributes of a given paragraph style name
|
||||||
|
* (with inheritance). If the name is an empty string,
|
||||||
|
* the attributes of the default style are returned.
|
||||||
|
* @param {!string} styleName
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
this.getParagraphStyleAttributes = function (styleName) {
|
this.getParagraphStyleAttributes = function (styleName) {
|
||||||
return odtDocument.getParagraphStyleAttributes(styleName);
|
return (styleName === "")
|
||||||
|
? getDefaultParagraphStyleAttributes()
|
||||||
|
: odtDocument.getParagraphStyleAttributes(styleName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -387,7 +421,7 @@ define("webodf/editor/EditorSession", [
|
|||||||
*/
|
*/
|
||||||
this.cloneParagraphStyle = function (styleName, newStyleDisplayName) {
|
this.cloneParagraphStyle = function (styleName, newStyleDisplayName) {
|
||||||
var newStyleName = uniqueParagraphStyleNCName(newStyleDisplayName),
|
var newStyleName = uniqueParagraphStyleNCName(newStyleDisplayName),
|
||||||
styleNode = odtDocument.getParagraphStyleElement(styleName),
|
styleNode = self.getParagraphStyleElement(styleName),
|
||||||
formatting = odtDocument.getFormatting(),
|
formatting = odtDocument.getFormatting(),
|
||||||
op, setProperties, attributes, i;
|
op, setProperties, attributes, i;
|
||||||
|
|
||||||
@ -406,10 +440,11 @@ define("webodf/editor/EditorSession", [
|
|||||||
|
|
||||||
setProperties['style:display-name'] = newStyleDisplayName;
|
setProperties['style:display-name'] = newStyleDisplayName;
|
||||||
|
|
||||||
op = new ops.OpAddParagraphStyle();
|
op = new ops.OpAddStyle();
|
||||||
op.init({
|
op.init({
|
||||||
memberid: localMemberId,
|
memberid: localMemberId,
|
||||||
styleName: newStyleName,
|
styleName: newStyleName,
|
||||||
|
styleFamily: 'paragraph',
|
||||||
setProperties: setProperties
|
setProperties: setProperties
|
||||||
});
|
});
|
||||||
session.enqueue(op);
|
session.enqueue(op);
|
||||||
@ -419,10 +454,11 @@ define("webodf/editor/EditorSession", [
|
|||||||
|
|
||||||
this.deleteStyle = function (styleName) {
|
this.deleteStyle = function (styleName) {
|
||||||
var op;
|
var op;
|
||||||
op = new ops.OpRemoveParagraphStyle();
|
op = new ops.OpRemoveStyle();
|
||||||
op.init({
|
op.init({
|
||||||
memberid: localMemberId,
|
memberid: localMemberId,
|
||||||
styleName: styleName
|
styleName: styleName,
|
||||||
|
styleFamily: 'paragraph'
|
||||||
});
|
});
|
||||||
session.enqueue(op);
|
session.enqueue(op);
|
||||||
};
|
};
|
||||||
@ -522,8 +558,8 @@ define("webodf/editor/EditorSession", [
|
|||||||
odtDocument.unsubscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded);
|
odtDocument.unsubscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded);
|
||||||
odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved);
|
odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved);
|
||||||
odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved);
|
odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved);
|
||||||
odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated);
|
odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated);
|
||||||
odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted);
|
odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted);
|
||||||
odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified);
|
odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified);
|
||||||
odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph);
|
odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph);
|
||||||
odtDocument.unsubscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified);
|
odtDocument.unsubscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified);
|
||||||
@ -564,8 +600,8 @@ define("webodf/editor/EditorSession", [
|
|||||||
odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded);
|
odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded);
|
||||||
odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved);
|
odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved);
|
||||||
odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved);
|
odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved);
|
||||||
odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated);
|
odtDocument.subscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated);
|
||||||
odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted);
|
odtDocument.subscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted);
|
||||||
odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified);
|
odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified);
|
||||||
odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph);
|
odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph);
|
||||||
odtDocument.subscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified);
|
odtDocument.subscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified);
|
||||||
@ -578,8 +614,8 @@ define("webodf/editor/EditorSession", [
|
|||||||
/**@const*/EditorSession.signalMemberRemoved = "memberRemoved";
|
/**@const*/EditorSession.signalMemberRemoved = "memberRemoved";
|
||||||
/**@const*/EditorSession.signalCursorMoved = "cursorMoved";
|
/**@const*/EditorSession.signalCursorMoved = "cursorMoved";
|
||||||
/**@const*/EditorSession.signalParagraphChanged = "paragraphChanged";
|
/**@const*/EditorSession.signalParagraphChanged = "paragraphChanged";
|
||||||
/**@const*/EditorSession.signalCommonParagraphStyleCreated = "styleCreated";
|
/**@const*/EditorSession.signalCommonStyleCreated = "styleCreated";
|
||||||
/**@const*/EditorSession.signalCommonParagraphStyleDeleted = "styleDeleted";
|
/**@const*/EditorSession.signalCommonStyleDeleted = "styleDeleted";
|
||||||
/**@const*/EditorSession.signalParagraphStyleModified = "paragraphStyleModified";
|
/**@const*/EditorSession.signalParagraphStyleModified = "paragraphStyleModified";
|
||||||
/**@const*/EditorSession.signalUndoStackChanged = "signalUndoStackChanged";
|
/**@const*/EditorSession.signalUndoStackChanged = "signalUndoStackChanged";
|
||||||
|
|
||||||
|
12
js/3rdparty/webodf/editor/Tools.js
vendored
12
js/3rdparty/webodf/editor/Tools.js
vendored
@ -116,29 +116,32 @@ define("webodf/editor/Tools", [
|
|||||||
|
|
||||||
// Simple Style Selector [B, I, U, S]
|
// Simple Style Selector [B, I, U, S]
|
||||||
if (args.directStylingEnabled) {
|
if (args.directStylingEnabled) {
|
||||||
simpleStyles = new SimpleStyles(onToolDone, function (widget) {
|
simpleStyles = new SimpleStyles(function (widget) {
|
||||||
widget.placeAt(toolbar);
|
widget.placeAt(toolbar);
|
||||||
widget.startup();
|
widget.startup();
|
||||||
});
|
});
|
||||||
sessionSubscribers.push(simpleStyles);
|
sessionSubscribers.push(simpleStyles);
|
||||||
|
simpleStyles.onToolDone = onToolDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paragraph direct alignment buttons
|
// Paragraph direct alignment buttons
|
||||||
if (args.directStylingEnabled) {
|
if (args.directStylingEnabled) {
|
||||||
paragraphAlignment = new ParagraphAlignment(onToolDone, function (widget) {
|
paragraphAlignment = new ParagraphAlignment(function (widget) {
|
||||||
widget.placeAt(toolbar);
|
widget.placeAt(toolbar);
|
||||||
widget.startup();
|
widget.startup();
|
||||||
});
|
});
|
||||||
sessionSubscribers.push(paragraphAlignment);
|
sessionSubscribers.push(paragraphAlignment);
|
||||||
|
paragraphAlignment.onToolDone = onToolDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Paragraph Style Selector
|
// Paragraph Style Selector
|
||||||
currentStyle = new CurrentStyle(onToolDone, function (widget) {
|
currentStyle = new CurrentStyle(function (widget) {
|
||||||
widget.placeAt(toolbar);
|
widget.placeAt(toolbar);
|
||||||
widget.startup();
|
widget.startup();
|
||||||
});
|
});
|
||||||
sessionSubscribers.push(currentStyle);
|
sessionSubscribers.push(currentStyle);
|
||||||
|
currentStyle.onToolDone = onToolDone;
|
||||||
|
|
||||||
// Zoom Level Selector
|
// Zoom Level Selector
|
||||||
zoomSlider = new ZoomSlider(function (widget) {
|
zoomSlider = new ZoomSlider(function (widget) {
|
||||||
@ -146,6 +149,7 @@ define("webodf/editor/Tools", [
|
|||||||
widget.startup();
|
widget.startup();
|
||||||
});
|
});
|
||||||
sessionSubscribers.push(zoomSlider);
|
sessionSubscribers.push(zoomSlider);
|
||||||
|
zoomSlider.onToolDone = onToolDone;
|
||||||
|
|
||||||
// Load
|
// Load
|
||||||
if (loadOdtFile) {
|
if (loadOdtFile) {
|
||||||
@ -174,6 +178,7 @@ define("webodf/editor/Tools", [
|
|||||||
},
|
},
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
saveOdtFile();
|
saveOdtFile();
|
||||||
|
onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
saveButton.placeAt(toolbar);
|
saveButton.placeAt(toolbar);
|
||||||
@ -195,6 +200,7 @@ define("webodf/editor/Tools", [
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
sessionSubscribers.push(paragraphStylesDialog);
|
sessionSubscribers.push(paragraphStylesDialog);
|
||||||
|
paragraphStylesDialog.onToolDone = onToolDone;
|
||||||
|
|
||||||
formatMenuButton = new DropDownButton({
|
formatMenuButton = new DropDownButton({
|
||||||
dropDown: formatDropDownMenu,
|
dropDown: formatDropDownMenu,
|
||||||
|
@ -91,5 +91,6 @@ define({
|
|||||||
size: "Größe",
|
size: "Größe",
|
||||||
color: "Farbe",
|
color: "Farbe",
|
||||||
text: "Text",
|
text: "Text",
|
||||||
background: "Hintergrund"
|
background: "Hintergrund",
|
||||||
|
defaultStyle: "Grundstil"
|
||||||
});
|
});
|
||||||
|
3
js/3rdparty/webodf/editor/nls/myResources.js
vendored
3
js/3rdparty/webodf/editor/nls/myResources.js
vendored
@ -90,7 +90,8 @@ define({
|
|||||||
size: "Size",
|
size: "Size",
|
||||||
color: "Color",
|
color: "Color",
|
||||||
text: "Text",
|
text: "Text",
|
||||||
background: "Background"
|
background: "Background",
|
||||||
|
defaultStyle: "Default Style"
|
||||||
},
|
},
|
||||||
|
|
||||||
de: true,
|
de: true,
|
||||||
|
@ -42,8 +42,9 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
function (ToggleButton, Button) {
|
function (ToggleButton, Button) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var ParagraphAlignment = function (onToolDone, callback) {
|
var ParagraphAlignment = function (callback) {
|
||||||
var widget = {},
|
var self = this,
|
||||||
|
widget = {},
|
||||||
directParagraphStyler,
|
directParagraphStyler,
|
||||||
justifyLeft,
|
justifyLeft,
|
||||||
justifyCenter,
|
justifyCenter,
|
||||||
@ -60,7 +61,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft",
|
iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft",
|
||||||
onChange: function () {
|
onChange: function () {
|
||||||
directParagraphStyler.alignParagraphLeft();
|
directParagraphStyler.alignParagraphLeft();
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter",
|
iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter",
|
||||||
onChange: function () {
|
onChange: function () {
|
||||||
directParagraphStyler.alignParagraphCenter();
|
directParagraphStyler.alignParagraphCenter();
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyRight",
|
iconClass: "dijitEditorIcon dijitEditorIconJustifyRight",
|
||||||
onChange: function () {
|
onChange: function () {
|
||||||
directParagraphStyler.alignParagraphRight();
|
directParagraphStyler.alignParagraphRight();
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyFull",
|
iconClass: "dijitEditorIcon dijitEditorIconJustifyFull",
|
||||||
onChange: function () {
|
onChange: function () {
|
||||||
directParagraphStyler.alignParagraphJustified();
|
directParagraphStyler.alignParagraphJustified();
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,7 +108,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconOutdent",
|
iconClass: "dijitEditorIcon dijitEditorIconOutdent",
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
directParagraphStyler.outdent();
|
directParagraphStyler.outdent();
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconIndent",
|
iconClass: "dijitEditorIcon dijitEditorIconIndent",
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
directParagraphStyler.indent();
|
directParagraphStyler.indent();
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -179,6 +180,8 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onToolDone = function () {};
|
||||||
|
|
||||||
callback(widget);
|
callback(widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,23 +46,40 @@ define("webodf/editor/widgets/paragraphStyles",
|
|||||||
var ParagraphStyles = function (callback) {
|
var ParagraphStyles = function (callback) {
|
||||||
var self = this,
|
var self = this,
|
||||||
editorSession,
|
editorSession,
|
||||||
select;
|
select,
|
||||||
|
translator = document.translator,
|
||||||
|
defaultStyleUIId = ":default";
|
||||||
|
|
||||||
this.widget = function () {
|
this.widget = function () {
|
||||||
return select;
|
return select;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In this widget, we name the default style
|
||||||
|
* (which is referred to as "" in webodf) as
|
||||||
|
* ":default". The ":" is disallowed in an NCName, so this
|
||||||
|
* avoids clashes with other styles.
|
||||||
|
*/
|
||||||
|
|
||||||
this.value = function () {
|
this.value = function () {
|
||||||
return select.get('value');
|
var value = select.get('value');
|
||||||
|
if (value === defaultStyleUIId) {
|
||||||
|
value = "";
|
||||||
|
}
|
||||||
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setValue = function (value) {
|
this.setValue = function (value) {
|
||||||
|
if (value === "") {
|
||||||
|
value = defaultStyleUIId;
|
||||||
|
}
|
||||||
select.set('value', value);
|
select.set('value', value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// events
|
// events
|
||||||
this.onAdd = null;
|
this.onAdd = null;
|
||||||
this.onRemove = null;
|
this.onRemove = null;
|
||||||
|
this.onChange = function () {};
|
||||||
|
|
||||||
function populateStyles() {
|
function populateStyles() {
|
||||||
var i, selectionList, availableStyles;
|
var i, selectionList, availableStyles;
|
||||||
@ -71,7 +88,11 @@ define("webodf/editor/widgets/paragraphStyles",
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectionList = [];
|
// Populate the Default Style always
|
||||||
|
selectionList = [{
|
||||||
|
label: translator("defaultStyle"),
|
||||||
|
value: defaultStyleUIId
|
||||||
|
}];
|
||||||
availableStyles = editorSession ? editorSession.getAvailableParagraphStyles() : [];
|
availableStyles = editorSession ? editorSession.getAvailableParagraphStyles() : [];
|
||||||
|
|
||||||
for (i = 0; i < availableStyles.length; i += 1) {
|
for (i = 0; i < availableStyles.length; i += 1) {
|
||||||
@ -85,29 +106,38 @@ define("webodf/editor/widgets/paragraphStyles",
|
|||||||
select.addOption(selectionList);
|
select.addOption(selectionList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addStyle(newStyleName) {
|
function addStyle(styleInfo) {
|
||||||
var stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
|
var stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
|
||||||
newStyleElement = editorSession.getParagraphStyleElement(newStyleName);
|
newStyleElement;
|
||||||
|
|
||||||
|
if (styleInfo.family !== 'paragraph') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
newStyleElement = editorSession.getParagraphStyleElement(styleInfo.name);
|
||||||
if (select) {
|
if (select) {
|
||||||
select.addOption({
|
select.addOption({
|
||||||
value: newStyleName,
|
value: styleInfo.name,
|
||||||
label: newStyleElement.getAttributeNS(stylens, 'display-name')
|
label: newStyleElement.getAttributeNS(stylens, 'display-name')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.onAdd) {
|
if (self.onAdd) {
|
||||||
self.onAdd(newStyleName);
|
self.onAdd(styleInfo.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeStyle(styleName) {
|
function removeStyle(styleInfo) {
|
||||||
|
if (styleInfo.family !== 'paragraph') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (select) {
|
if (select) {
|
||||||
select.removeOption(styleName);
|
select.removeOption(styleInfo.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.onRemove) {
|
if (self.onRemove) {
|
||||||
self.onRemove(styleName);
|
self.onRemove(styleInfo.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,19 +153,28 @@ define("webodf/editor/widgets/paragraphStyles",
|
|||||||
|
|
||||||
populateStyles();
|
populateStyles();
|
||||||
|
|
||||||
|
// Call ParagraphStyles's onChange handler every time
|
||||||
|
// the select's onchange is called, and pass the value
|
||||||
|
// as reported by ParagraphStyles.value(), because we do not
|
||||||
|
// want to expose the internal naming like ":default" outside this
|
||||||
|
// class.
|
||||||
|
select.onChange = function () {
|
||||||
|
self.onChange(self.value());
|
||||||
|
};
|
||||||
|
|
||||||
return cb();
|
return cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setEditorSession = function(session) {
|
this.setEditorSession = function(session) {
|
||||||
if (editorSession) {
|
if (editorSession) {
|
||||||
editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle);
|
editorSession.unsubscribe(EditorSession.signalCommonStyleCreated, addStyle);
|
||||||
editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle);
|
editorSession.unsubscribe(EditorSession.signalCommonStyleDeleted, removeStyle);
|
||||||
}
|
}
|
||||||
editorSession = session;
|
editorSession = session;
|
||||||
if (editorSession) {
|
if (editorSession) {
|
||||||
editorSession.subscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle);
|
editorSession.subscribe(EditorSession.signalCommonStyleCreated, addStyle);
|
||||||
editorSession.subscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle);
|
editorSession.subscribe(EditorSession.signalCommonStyleDeleted, removeStyle);
|
||||||
populateStyles();
|
populateStyles();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
return function ParagraphStylesDialog(callback) {
|
return function ParagraphStylesDialog(callback) {
|
||||||
var editorSession,
|
var self = this,
|
||||||
|
editorSession,
|
||||||
dialog,
|
dialog,
|
||||||
stylePicker, alignmentPane, fontEffectsPane;
|
stylePicker, alignmentPane, fontEffectsPane;
|
||||||
|
|
||||||
@ -246,7 +247,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
|||||||
function openStyle(value) {
|
function openStyle(value) {
|
||||||
alignmentPane.setStyle(value);
|
alignmentPane.setStyle(value);
|
||||||
fontEffectsPane.setStyle(value);
|
fontEffectsPane.setStyle(value);
|
||||||
if (editorSession.isStyleUsed(editorSession.getParagraphStyleElement(value))) {
|
// If it is a default (nameless) style or is used, make it undeletable.
|
||||||
|
if (value === "" || editorSession.isStyleUsed(editorSession.getParagraphStyleElement(value))) {
|
||||||
deleteButton.domNode.style.display = 'none';
|
deleteButton.domNode.style.display = 'none';
|
||||||
} else {
|
} else {
|
||||||
deleteButton.domNode.style.display = 'block';
|
deleteButton.domNode.style.display = 'block';
|
||||||
@ -273,7 +275,7 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
|||||||
stylePicker.setValue(stylePicker.widget().getOptions(0));
|
stylePicker.setValue(stylePicker.widget().getOptions(0));
|
||||||
};
|
};
|
||||||
|
|
||||||
stylePicker.widget().onChange = openStyle;
|
stylePicker.onChange = openStyle;
|
||||||
stylePicker.setEditorSession(editorSession);
|
stylePicker.setEditorSession(editorSession);
|
||||||
});
|
});
|
||||||
a = new AlignmentPane(function (pane) {
|
a = new AlignmentPane(function (pane) {
|
||||||
@ -300,6 +302,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
|||||||
stylePicker.setValue(currentStyle);
|
stylePicker.setValue(currentStyle);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dialog.onHide = self.onToolDone;
|
||||||
});
|
});
|
||||||
|
|
||||||
tabContainer.startup();
|
tabContainer.startup();
|
||||||
@ -324,6 +328,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onToolDone = function () {};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
makeWidget(function (dialog) {
|
makeWidget(function (dialog) {
|
||||||
return callback(dialog);
|
return callback(dialog);
|
||||||
|
@ -43,8 +43,9 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
function (FontPicker, ToggleButton, NumberSpinner) {
|
function (FontPicker, ToggleButton, NumberSpinner) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var SimpleStyles = function(onToolDone, callback) {
|
var SimpleStyles = function(callback) {
|
||||||
var widget = {},
|
var self = this,
|
||||||
|
widget = {},
|
||||||
directTextStyler,
|
directTextStyler,
|
||||||
boldButton,
|
boldButton,
|
||||||
italicButton,
|
italicButton,
|
||||||
@ -62,7 +63,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconBold",
|
iconClass: "dijitEditorIcon dijitEditorIconBold",
|
||||||
onChange: function (checked) {
|
onChange: function (checked) {
|
||||||
directTextStyler.setBold(checked);
|
directTextStyler.setBold(checked);
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconItalic",
|
iconClass: "dijitEditorIcon dijitEditorIconItalic",
|
||||||
onChange: function (checked) {
|
onChange: function (checked) {
|
||||||
directTextStyler.setItalic(checked);
|
directTextStyler.setItalic(checked);
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconUnderline",
|
iconClass: "dijitEditorIcon dijitEditorIconUnderline",
|
||||||
onChange: function (checked) {
|
onChange: function (checked) {
|
||||||
directTextStyler.setHasUnderline(checked);
|
directTextStyler.setHasUnderline(checked);
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
iconClass: "dijitEditorIcon dijitEditorIconStrikethrough",
|
iconClass: "dijitEditorIcon dijitEditorIconStrikethrough",
|
||||||
onChange: function (checked) {
|
onChange: function (checked) {
|
||||||
directTextStyler.setHasStrikethrough(checked);
|
directTextStyler.setHasStrikethrough(checked);
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -110,8 +111,17 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
smallDelta: 1,
|
smallDelta: 1,
|
||||||
constraints: {min:6, max:96},
|
constraints: {min:6, max:96},
|
||||||
intermediateChanges: true,
|
intermediateChanges: true,
|
||||||
onChange: function(value) {
|
onChange: function (value) {
|
||||||
directTextStyler.setFontSize(value);
|
directTextStyler.setFontSize(value);
|
||||||
|
},
|
||||||
|
onClick: function () {
|
||||||
|
self.onToolDone();
|
||||||
|
},
|
||||||
|
onInput: function () {
|
||||||
|
// Do not process any input in the text box;
|
||||||
|
// even paste events will not be processed
|
||||||
|
// so that no corrupt values can exist
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -120,7 +130,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
fontPickerWidget.setAttribute('disabled', true);
|
fontPickerWidget.setAttribute('disabled', true);
|
||||||
fontPickerWidget.onChange = function(value) {
|
fontPickerWidget.onChange = function(value) {
|
||||||
directTextStyler.setFontName(value);
|
directTextStyler.setFontName(value);
|
||||||
onToolDone();
|
self.onToolDone();
|
||||||
};
|
};
|
||||||
|
|
||||||
widget.children = [boldButton, italicButton, underlineButton, strikethroughButton, fontPickerWidget, fontSizeSpinner];
|
widget.children = [boldButton, italicButton, underlineButton, strikethroughButton, fontPickerWidget, fontSizeSpinner];
|
||||||
@ -182,6 +192,8 @@ define("webodf/editor/widgets/simpleStyles", [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onToolDone = function () {};
|
||||||
|
|
||||||
callback(widget);
|
callback(widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,23 +41,24 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle",
|
|||||||
function (EditorSession) {
|
function (EditorSession) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
return function CurrentStyle(onToolDone, callback) {
|
return function CurrentStyle(callback) {
|
||||||
var editorSession,
|
var self = this,
|
||||||
|
editorSession,
|
||||||
paragraphStyles;
|
paragraphStyles;
|
||||||
|
|
||||||
function selectParagraphStyle(info) {
|
function selectParagraphStyle(info) {
|
||||||
if (paragraphStyles) {
|
if (paragraphStyles) {
|
||||||
if (info.type === 'style') {
|
if (info.type === 'style') {
|
||||||
paragraphStyles.widget().set("value", info.styleName);
|
paragraphStyles.setValue(info.styleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setParagraphStyle(value) {
|
function setParagraphStyle() {
|
||||||
if (editorSession) {
|
if (editorSession) {
|
||||||
editorSession.setCurrentParagraphStyle(value);
|
editorSession.setCurrentParagraphStyle(paragraphStyles.value());
|
||||||
onToolDone();
|
|
||||||
}
|
}
|
||||||
|
self.onToolDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeWidget(callback) {
|
function makeWidget(callback) {
|
||||||
@ -89,6 +90,8 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle",
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onToolDone = function () {};
|
||||||
|
|
||||||
makeWidget(function (widget) {
|
makeWidget(function (widget) {
|
||||||
return callback(widget);
|
return callback(widget);
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,8 @@ define("webodf/editor/widgets/zoomSlider", [], function () {
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
return function ZoomSlider(callback) {
|
return function ZoomSlider(callback) {
|
||||||
var editorSession,
|
var self = this,
|
||||||
|
editorSession,
|
||||||
slider;
|
slider;
|
||||||
|
|
||||||
function makeWidget(callback) {
|
function makeWidget(callback) {
|
||||||
@ -64,8 +65,9 @@ define("webodf/editor/widgets/zoomSlider", [], function () {
|
|||||||
if (editorSession) {
|
if (editorSession) {
|
||||||
editorSession.getOdfCanvas().setZoomLevel(value / 100.0);
|
editorSession.getOdfCanvas().setZoomLevel(value / 100.0);
|
||||||
}
|
}
|
||||||
|
self.onToolDone();
|
||||||
};
|
};
|
||||||
|
|
||||||
return callback(slider);
|
return callback(slider);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -75,6 +77,8 @@ define("webodf/editor/widgets/zoomSlider", [], function () {
|
|||||||
// if (slider) { slider.setValue(editorSession.getOdfCanvas().getZoomLevel() ); TODO!
|
// if (slider) { slider.setValue(editorSession.getOdfCanvas().getZoomLevel() ); TODO!
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onToolDone = function () {};
|
||||||
|
|
||||||
// init
|
// init
|
||||||
makeWidget(function (widget) {
|
makeWidget(function (widget) {
|
||||||
return callback(widget);
|
return callback(widget);
|
||||||
|
933
js/3rdparty/webodf/webodf-debug.js
vendored
933
js/3rdparty/webodf/webodf-debug.js
vendored
File diff suppressed because it is too large
Load Diff
1084
js/3rdparty/webodf/webodf.js
vendored
1084
js/3rdparty/webodf/webodf.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user