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;
|
||||
|
||||
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 self = this,
|
||||
currentParagraphNode = null,
|
||||
currentNamedStyleName = null,
|
||||
currentCommonStyleName = null,
|
||||
currentStyleName = null,
|
||||
caretManager,
|
||||
odtDocument = session.getOdtDocument(),
|
||||
@ -79,8 +79,8 @@ define("webodf/editor/EditorSession", [
|
||||
EditorSession.signalMemberRemoved,
|
||||
EditorSession.signalCursorMoved,
|
||||
EditorSession.signalParagraphChanged,
|
||||
EditorSession.signalCommonParagraphStyleCreated,
|
||||
EditorSession.signalCommonParagraphStyleDeleted,
|
||||
EditorSession.signalCommonStyleCreated,
|
||||
EditorSession.signalCommonStyleDeleted,
|
||||
EditorSession.signalParagraphStyleModified,
|
||||
EditorSession.signalUndoStackChanged]);
|
||||
|
||||
@ -113,24 +113,31 @@ define("webodf/editor/EditorSession", [
|
||||
|
||||
function checkParagraphStyleName() {
|
||||
var newStyleName,
|
||||
newNamedStyleName;
|
||||
newCommonStyleName;
|
||||
|
||||
newStyleName = currentParagraphNode.getAttributeNS(textns, 'style-name');
|
||||
|
||||
if (newStyleName !== currentStyleName) {
|
||||
currentStyleName = newStyleName;
|
||||
// check if named style is still the same
|
||||
newNamedStyleName = formatting.getFirstNamedParentStyleNameOrSelf(newStyleName);
|
||||
if (!newNamedStyleName) {
|
||||
// TODO: how to handle default styles?
|
||||
return;
|
||||
}
|
||||
// a named style
|
||||
if (newNamedStyleName !== currentNamedStyleName) {
|
||||
currentNamedStyleName = newNamedStyleName;
|
||||
// check if common style is still the same
|
||||
newCommonStyleName = formatting.getFirstCommonParentStyleNameOrSelf(newStyleName);
|
||||
if (!newCommonStyleName) {
|
||||
// Default style, empty-string name
|
||||
currentCommonStyleName = newStyleName = currentStyleName = "";
|
||||
self.emit(EditorSession.signalParagraphChanged, {
|
||||
type: 'style',
|
||||
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) {
|
||||
self.emit(EditorSession.signalCommonParagraphStyleCreated, newStyleName);
|
||||
self.emit(EditorSession.signalCommonStyleCreated, newStyleName);
|
||||
}
|
||||
|
||||
function onStyleDeleted(styleName) {
|
||||
self.emit(EditorSession.signalCommonParagraphStyleDeleted, styleName);
|
||||
self.emit(EditorSession.signalCommonStyleDeleted, styleName);
|
||||
}
|
||||
|
||||
function onParagraphStyleModified(styleName) {
|
||||
@ -289,7 +296,7 @@ define("webodf/editor/EditorSession", [
|
||||
};
|
||||
|
||||
this.getCurrentParagraphStyle = function () {
|
||||
return currentNamedStyleName;
|
||||
return currentCommonStyleName;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -316,7 +323,7 @@ define("webodf/editor/EditorSession", [
|
||||
|
||||
this.setCurrentParagraphStyle = function (value) {
|
||||
var op;
|
||||
if (currentNamedStyleName !== value) {
|
||||
if (currentCommonStyleName !== value) {
|
||||
op = new ops.OpSetParagraphStyle();
|
||||
op.init({
|
||||
memberid: localMemberId,
|
||||
@ -341,8 +348,17 @@ define("webodf/editor/EditorSession", [
|
||||
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) {
|
||||
return odtDocument.getParagraphStyleElement(styleName);
|
||||
return (styleName === "")
|
||||
? formatting.getDefaultStyleElement('paragraph')
|
||||
: odtDocument.getParagraphStyleElement(styleName);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -354,8 +370,26 @@ define("webodf/editor/EditorSession", [
|
||||
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) {
|
||||
return odtDocument.getParagraphStyleAttributes(styleName);
|
||||
return (styleName === "")
|
||||
? getDefaultParagraphStyleAttributes()
|
||||
: odtDocument.getParagraphStyleAttributes(styleName);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -387,7 +421,7 @@ define("webodf/editor/EditorSession", [
|
||||
*/
|
||||
this.cloneParagraphStyle = function (styleName, newStyleDisplayName) {
|
||||
var newStyleName = uniqueParagraphStyleNCName(newStyleDisplayName),
|
||||
styleNode = odtDocument.getParagraphStyleElement(styleName),
|
||||
styleNode = self.getParagraphStyleElement(styleName),
|
||||
formatting = odtDocument.getFormatting(),
|
||||
op, setProperties, attributes, i;
|
||||
|
||||
@ -406,10 +440,11 @@ define("webodf/editor/EditorSession", [
|
||||
|
||||
setProperties['style:display-name'] = newStyleDisplayName;
|
||||
|
||||
op = new ops.OpAddParagraphStyle();
|
||||
op = new ops.OpAddStyle();
|
||||
op.init({
|
||||
memberid: localMemberId,
|
||||
styleName: newStyleName,
|
||||
styleFamily: 'paragraph',
|
||||
setProperties: setProperties
|
||||
});
|
||||
session.enqueue(op);
|
||||
@ -419,10 +454,11 @@ define("webodf/editor/EditorSession", [
|
||||
|
||||
this.deleteStyle = function (styleName) {
|
||||
var op;
|
||||
op = new ops.OpRemoveParagraphStyle();
|
||||
op = new ops.OpRemoveStyle();
|
||||
op.init({
|
||||
memberid: localMemberId,
|
||||
styleName: styleName
|
||||
styleName: styleName,
|
||||
styleFamily: 'paragraph'
|
||||
});
|
||||
session.enqueue(op);
|
||||
};
|
||||
@ -522,8 +558,8 @@ define("webodf/editor/EditorSession", [
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph);
|
||||
odtDocument.unsubscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified);
|
||||
@ -564,8 +600,8 @@ define("webodf/editor/EditorSession", [
|
||||
odtDocument.subscribe(ops.OdtDocument.signalCursorAdded, onCursorAdded);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalCursorRemoved, onCursorRemoved);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalCursorMoved, onCursorMoved);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleCreated, onStyleCreated);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalCommonParagraphStyleDeleted, onStyleDeleted);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph);
|
||||
odtDocument.subscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified);
|
||||
@ -578,8 +614,8 @@ define("webodf/editor/EditorSession", [
|
||||
/**@const*/EditorSession.signalMemberRemoved = "memberRemoved";
|
||||
/**@const*/EditorSession.signalCursorMoved = "cursorMoved";
|
||||
/**@const*/EditorSession.signalParagraphChanged = "paragraphChanged";
|
||||
/**@const*/EditorSession.signalCommonParagraphStyleCreated = "styleCreated";
|
||||
/**@const*/EditorSession.signalCommonParagraphStyleDeleted = "styleDeleted";
|
||||
/**@const*/EditorSession.signalCommonStyleCreated = "styleCreated";
|
||||
/**@const*/EditorSession.signalCommonStyleDeleted = "styleDeleted";
|
||||
/**@const*/EditorSession.signalParagraphStyleModified = "paragraphStyleModified";
|
||||
/**@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]
|
||||
if (args.directStylingEnabled) {
|
||||
simpleStyles = new SimpleStyles(onToolDone, function (widget) {
|
||||
simpleStyles = new SimpleStyles(function (widget) {
|
||||
widget.placeAt(toolbar);
|
||||
widget.startup();
|
||||
});
|
||||
sessionSubscribers.push(simpleStyles);
|
||||
simpleStyles.onToolDone = onToolDone;
|
||||
}
|
||||
|
||||
// Paragraph direct alignment buttons
|
||||
if (args.directStylingEnabled) {
|
||||
paragraphAlignment = new ParagraphAlignment(onToolDone, function (widget) {
|
||||
paragraphAlignment = new ParagraphAlignment(function (widget) {
|
||||
widget.placeAt(toolbar);
|
||||
widget.startup();
|
||||
});
|
||||
sessionSubscribers.push(paragraphAlignment);
|
||||
paragraphAlignment.onToolDone = onToolDone;
|
||||
}
|
||||
|
||||
|
||||
// Paragraph Style Selector
|
||||
currentStyle = new CurrentStyle(onToolDone, function (widget) {
|
||||
currentStyle = new CurrentStyle(function (widget) {
|
||||
widget.placeAt(toolbar);
|
||||
widget.startup();
|
||||
});
|
||||
sessionSubscribers.push(currentStyle);
|
||||
currentStyle.onToolDone = onToolDone;
|
||||
|
||||
// Zoom Level Selector
|
||||
zoomSlider = new ZoomSlider(function (widget) {
|
||||
@ -146,6 +149,7 @@ define("webodf/editor/Tools", [
|
||||
widget.startup();
|
||||
});
|
||||
sessionSubscribers.push(zoomSlider);
|
||||
zoomSlider.onToolDone = onToolDone;
|
||||
|
||||
// Load
|
||||
if (loadOdtFile) {
|
||||
@ -174,6 +178,7 @@ define("webodf/editor/Tools", [
|
||||
},
|
||||
onClick: function () {
|
||||
saveOdtFile();
|
||||
onToolDone();
|
||||
}
|
||||
});
|
||||
saveButton.placeAt(toolbar);
|
||||
@ -195,6 +200,7 @@ define("webodf/editor/Tools", [
|
||||
};
|
||||
});
|
||||
sessionSubscribers.push(paragraphStylesDialog);
|
||||
paragraphStylesDialog.onToolDone = onToolDone;
|
||||
|
||||
formatMenuButton = new DropDownButton({
|
||||
dropDown: formatDropDownMenu,
|
||||
|
@ -91,5 +91,6 @@ define({
|
||||
size: "Größe",
|
||||
color: "Farbe",
|
||||
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",
|
||||
color: "Color",
|
||||
text: "Text",
|
||||
background: "Background"
|
||||
background: "Background",
|
||||
defaultStyle: "Default Style"
|
||||
},
|
||||
|
||||
de: true,
|
||||
|
@ -42,8 +42,9 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
function (ToggleButton, Button) {
|
||||
"use strict";
|
||||
|
||||
var ParagraphAlignment = function (onToolDone, callback) {
|
||||
var widget = {},
|
||||
var ParagraphAlignment = function (callback) {
|
||||
var self = this,
|
||||
widget = {},
|
||||
directParagraphStyler,
|
||||
justifyLeft,
|
||||
justifyCenter,
|
||||
@ -60,7 +61,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyLeft",
|
||||
onChange: function () {
|
||||
directParagraphStyler.alignParagraphLeft();
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -72,7 +73,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyCenter",
|
||||
onChange: function () {
|
||||
directParagraphStyler.alignParagraphCenter();
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -84,7 +85,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyRight",
|
||||
onChange: function () {
|
||||
directParagraphStyler.alignParagraphRight();
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -96,7 +97,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconJustifyFull",
|
||||
onChange: function () {
|
||||
directParagraphStyler.alignParagraphJustified();
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -107,7 +108,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconOutdent",
|
||||
onClick: function () {
|
||||
directParagraphStyler.outdent();
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -118,7 +119,7 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconIndent",
|
||||
onClick: function () {
|
||||
directParagraphStyler.indent();
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -179,6 +180,8 @@ define("webodf/editor/widgets/paragraphAlignment", [
|
||||
});
|
||||
};
|
||||
|
||||
this.onToolDone = function () {};
|
||||
|
||||
callback(widget);
|
||||
};
|
||||
|
||||
|
@ -46,23 +46,40 @@ define("webodf/editor/widgets/paragraphStyles",
|
||||
var ParagraphStyles = function (callback) {
|
||||
var self = this,
|
||||
editorSession,
|
||||
select;
|
||||
select,
|
||||
translator = document.translator,
|
||||
defaultStyleUIId = ":default";
|
||||
|
||||
this.widget = function () {
|
||||
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 () {
|
||||
return select.get('value');
|
||||
var value = select.get('value');
|
||||
if (value === defaultStyleUIId) {
|
||||
value = "";
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
this.setValue = function (value) {
|
||||
if (value === "") {
|
||||
value = defaultStyleUIId;
|
||||
}
|
||||
select.set('value', value);
|
||||
};
|
||||
|
||||
// events
|
||||
this.onAdd = null;
|
||||
this.onRemove = null;
|
||||
this.onChange = function () {};
|
||||
|
||||
function populateStyles() {
|
||||
var i, selectionList, availableStyles;
|
||||
@ -71,7 +88,11 @@ define("webodf/editor/widgets/paragraphStyles",
|
||||
return;
|
||||
}
|
||||
|
||||
selectionList = [];
|
||||
// Populate the Default Style always
|
||||
selectionList = [{
|
||||
label: translator("defaultStyle"),
|
||||
value: defaultStyleUIId
|
||||
}];
|
||||
availableStyles = editorSession ? editorSession.getAvailableParagraphStyles() : [];
|
||||
|
||||
for (i = 0; i < availableStyles.length; i += 1) {
|
||||
@ -85,29 +106,38 @@ define("webodf/editor/widgets/paragraphStyles",
|
||||
select.addOption(selectionList);
|
||||
}
|
||||
|
||||
function addStyle(newStyleName) {
|
||||
function addStyle(styleInfo) {
|
||||
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) {
|
||||
select.addOption({
|
||||
value: newStyleName,
|
||||
value: styleInfo.name,
|
||||
label: newStyleElement.getAttributeNS(stylens, 'display-name')
|
||||
});
|
||||
}
|
||||
|
||||
if (self.onAdd) {
|
||||
self.onAdd(newStyleName);
|
||||
self.onAdd(styleInfo.name);
|
||||
}
|
||||
}
|
||||
|
||||
function removeStyle(styleName) {
|
||||
function removeStyle(styleInfo) {
|
||||
if (styleInfo.family !== 'paragraph') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (select) {
|
||||
select.removeOption(styleName);
|
||||
select.removeOption(styleInfo.name);
|
||||
}
|
||||
|
||||
if (self.onRemove) {
|
||||
self.onRemove(styleName);
|
||||
self.onRemove(styleInfo.name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,19 +153,28 @@ define("webodf/editor/widgets/paragraphStyles",
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
this.setEditorSession = function(session) {
|
||||
if (editorSession) {
|
||||
editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle);
|
||||
editorSession.unsubscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle);
|
||||
editorSession.unsubscribe(EditorSession.signalCommonStyleCreated, addStyle);
|
||||
editorSession.unsubscribe(EditorSession.signalCommonStyleDeleted, removeStyle);
|
||||
}
|
||||
editorSession = session;
|
||||
if (editorSession) {
|
||||
editorSession.subscribe(EditorSession.signalCommonParagraphStyleCreated, addStyle);
|
||||
editorSession.subscribe(EditorSession.signalCommonParagraphStyleDeleted, removeStyle);
|
||||
editorSession.subscribe(EditorSession.signalCommonStyleCreated, addStyle);
|
||||
editorSession.subscribe(EditorSession.signalCommonStyleDeleted, removeStyle);
|
||||
populateStyles();
|
||||
}
|
||||
};
|
||||
|
@ -38,7 +38,8 @@
|
||||
define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
||||
"use strict";
|
||||
return function ParagraphStylesDialog(callback) {
|
||||
var editorSession,
|
||||
var self = this,
|
||||
editorSession,
|
||||
dialog,
|
||||
stylePicker, alignmentPane, fontEffectsPane;
|
||||
|
||||
@ -246,7 +247,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
||||
function openStyle(value) {
|
||||
alignmentPane.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';
|
||||
} else {
|
||||
deleteButton.domNode.style.display = 'block';
|
||||
@ -273,7 +275,7 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
||||
stylePicker.setValue(stylePicker.widget().getOptions(0));
|
||||
};
|
||||
|
||||
stylePicker.widget().onChange = openStyle;
|
||||
stylePicker.onChange = openStyle;
|
||||
stylePicker.setEditorSession(editorSession);
|
||||
});
|
||||
a = new AlignmentPane(function (pane) {
|
||||
@ -300,6 +302,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
||||
stylePicker.setValue(currentStyle);
|
||||
}
|
||||
};
|
||||
|
||||
dialog.onHide = self.onToolDone;
|
||||
});
|
||||
|
||||
tabContainer.startup();
|
||||
@ -324,6 +328,8 @@ define("webodf/editor/widgets/paragraphStylesDialog", [], function () {
|
||||
}
|
||||
};
|
||||
|
||||
this.onToolDone = function () {};
|
||||
|
||||
// init
|
||||
makeWidget(function (dialog) {
|
||||
return callback(dialog);
|
||||
|
@ -43,8 +43,9 @@ define("webodf/editor/widgets/simpleStyles", [
|
||||
function (FontPicker, ToggleButton, NumberSpinner) {
|
||||
"use strict";
|
||||
|
||||
var SimpleStyles = function(onToolDone, callback) {
|
||||
var widget = {},
|
||||
var SimpleStyles = function(callback) {
|
||||
var self = this,
|
||||
widget = {},
|
||||
directTextStyler,
|
||||
boldButton,
|
||||
italicButton,
|
||||
@ -62,7 +63,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconBold",
|
||||
onChange: function (checked) {
|
||||
directTextStyler.setBold(checked);
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -74,7 +75,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconItalic",
|
||||
onChange: function (checked) {
|
||||
directTextStyler.setItalic(checked);
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -86,7 +87,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconUnderline",
|
||||
onChange: function (checked) {
|
||||
directTextStyler.setHasUnderline(checked);
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -98,7 +99,7 @@ define("webodf/editor/widgets/simpleStyles", [
|
||||
iconClass: "dijitEditorIcon dijitEditorIconStrikethrough",
|
||||
onChange: function (checked) {
|
||||
directTextStyler.setHasStrikethrough(checked);
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
}
|
||||
});
|
||||
|
||||
@ -110,8 +111,17 @@ define("webodf/editor/widgets/simpleStyles", [
|
||||
smallDelta: 1,
|
||||
constraints: {min:6, max:96},
|
||||
intermediateChanges: true,
|
||||
onChange: function(value) {
|
||||
onChange: function (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.onChange = function(value) {
|
||||
directTextStyler.setFontName(value);
|
||||
onToolDone();
|
||||
self.onToolDone();
|
||||
};
|
||||
|
||||
widget.children = [boldButton, italicButton, underlineButton, strikethroughButton, fontPickerWidget, fontSizeSpinner];
|
||||
@ -182,6 +192,8 @@ define("webodf/editor/widgets/simpleStyles", [
|
||||
});
|
||||
};
|
||||
|
||||
this.onToolDone = function () {};
|
||||
|
||||
callback(widget);
|
||||
};
|
||||
|
||||
|
@ -41,23 +41,24 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle",
|
||||
function (EditorSession) {
|
||||
"use strict";
|
||||
|
||||
return function CurrentStyle(onToolDone, callback) {
|
||||
var editorSession,
|
||||
return function CurrentStyle(callback) {
|
||||
var self = this,
|
||||
editorSession,
|
||||
paragraphStyles;
|
||||
|
||||
function selectParagraphStyle(info) {
|
||||
if (paragraphStyles) {
|
||||
if (info.type === 'style') {
|
||||
paragraphStyles.widget().set("value", info.styleName);
|
||||
paragraphStyles.setValue(info.styleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setParagraphStyle(value) {
|
||||
function setParagraphStyle() {
|
||||
if (editorSession) {
|
||||
editorSession.setCurrentParagraphStyle(value);
|
||||
onToolDone();
|
||||
editorSession.setCurrentParagraphStyle(paragraphStyles.value());
|
||||
}
|
||||
self.onToolDone();
|
||||
}
|
||||
|
||||
function makeWidget(callback) {
|
||||
@ -89,6 +90,8 @@ define("webodf/editor/widgets/toolbarWidgets/currentStyle",
|
||||
}
|
||||
};
|
||||
|
||||
this.onToolDone = function () {};
|
||||
|
||||
makeWidget(function (widget) {
|
||||
return callback(widget);
|
||||
});
|
||||
|
@ -39,7 +39,8 @@ define("webodf/editor/widgets/zoomSlider", [], function () {
|
||||
"use strict";
|
||||
|
||||
return function ZoomSlider(callback) {
|
||||
var editorSession,
|
||||
var self = this,
|
||||
editorSession,
|
||||
slider;
|
||||
|
||||
function makeWidget(callback) {
|
||||
@ -64,6 +65,7 @@ define("webodf/editor/widgets/zoomSlider", [], function () {
|
||||
if (editorSession) {
|
||||
editorSession.getOdfCanvas().setZoomLevel(value / 100.0);
|
||||
}
|
||||
self.onToolDone();
|
||||
};
|
||||
|
||||
return callback(slider);
|
||||
@ -75,6 +77,8 @@ define("webodf/editor/widgets/zoomSlider", [], function () {
|
||||
// if (slider) { slider.setValue(editorSession.getOdfCanvas().getZoomLevel() ); TODO!
|
||||
};
|
||||
|
||||
this.onToolDone = function () {};
|
||||
|
||||
// init
|
||||
makeWidget(function (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