Commit Graph
105 Commits
Author SHA1 Message Date
Jos van den Oever f376bbfb78 Update EditorSession to the new document API. 2014-02-05 14:24:25 +01:00
Friedrich W. H. Kossebau d2671e2a00 @returns -> @return 2014-01-31 15:33:43 +01:00
Aditya Bhatt 6921bffe71 Rename TextManipulator to TextController 2014-01-15 13:37:47 +05:30
Aditya Bhatt 1c65c0eeec Rename ImageManager to ImageController 2014-01-15 13:37:47 +05:30
Philip Peitsch 3f2b2f0fb9 Support different selection view renderers
In certain cases it is useful to be able to swap out the technique used
to render cursor selections on the document. For example, SVG polygon
based rendering interacts badly with mouse events on the WebKit build
shipped on MacOS X 10.7.5.
2013-12-19 01:55:51 +11:00
lli 353b4b68f1 Added editor buttons for applying or deleting hyperlinks 2013-12-13 17:40:22 +11:00
Philip Peitsch ebb7462022 Extend step translation interface to allow custom rounding
Step translation from a DOM point to a step usually results in some
rounding. The existing interface provided a simple bool flag to control
this, but this does not provide help for a caller that doesn't know
ahead of time which step is "closer" to the desired node (e.g., asking
for steps at paragraph boundaries should round within the paragraph).

This extension now allows a custom delegate that will be called with the
prev and next position to choose between rounding options.
2013-11-28 00:35:36 +11:00
Aditya Bhatt f5883fe47e Apply paragraph style to all paragraphs in the cursor
selection.

* Modify OdtDocument.convertDomPointToCursorStep(),
which takes a node, an offset, and a boolean, and returns the steps to
that position from the root, rounded to the next allowed
position if the boolean is true, otherwise to the previous.

* Use this method in EditorSession.setCurrentParagraphStyle().
2013-11-26 14:02:36 +01:00
Aditya Bhatt e16cc38edb == Op-ify member data handling ==
* New operations: OpAddMember, OpRemoveMember,
OpUpdateMember.
* Member data is now handled in a memberDataManager
instance inside OdtDocument.
* Any operations must be executed only if a member
is present within this model.
* All polling code for member data has been removed;
colors, names, and images now instantly update
whenever a member data operation is executed.
* Added relevant entries to the OT Matrix.
2013-11-20 18:56:47 +01:00
Friedrich W. H. Kossebau db0ecac6ee Make directTextStyler no longer optional, now that it works also in collab mode 2013-11-15 15:30:32 +01:00
Aditya Bhatt 2dcd55205b Have dedicated Editor.closeDocument and Editor.closeSession
methods to correspond to openDocument and openSession.
Remove unused EditorSession.close method, not sure what it was
used for.
2013-11-14 21:47:26 +01:00
Friedrich W. H. Kossebau c2a795e668 Update link to repo: now https://github.com/kogmbh/WebODF/ 2013-10-23 18:20:30 +02:00
Friedrich W. H. Kossebau 508570dab8 Add copy of the AGPL3 to sources (+ add to created zip files) 2013-10-21 17:55:16 +02:00
Friedrich W. H. Kossebau f9249c08b8 Fix regression: fonts listed in resources/fonts/fonts.css became ignored
fixup for b426aab73f
2013-10-18 15:38:26 +02:00
Friedrich W. H. Kossebau 80e75c6b73 Separate annotation handling logic into a tool class AnnotationManager and UI into a editor/widgets/annotation.js
Also enable "Add annotation" button only if not inside annotations
2013-10-16 17:20:14 +02:00
Philip Peitsch 1ff4d6f9ec Upgrade from magical empty-string to const for shadow cursor memberId
In various parts of the code, the magical empty-string cursor id is used
to determine whether the object is a shadow cursor or not. Converting
this into a constant instead and removing the constructor arg prevents
some mistakes being made with this.
2013-10-16 21:43:00 +11:00
Aditya Bhatt aae55aca50 * Add a new ShadowCursor class. This class is meant, for now, to only
hold the 'selected range' fed to it, like with any other OdtCursor. It
provides a minimal OdtCursor-like interface, with only the methods
absolutely required to make it work. It does not modify the DOM in any
way.
* Make the shadowCursor object an instance of ShadowCursor, not
OdtCursor. This is ideal because ShadowCursor does not modify anything
in the DOM, and therefore is safer and faster to use for tracking
browser selections. This makes backwards-selections work finally,
because now there are no anchor nodes to interfere with the selection
whilst dragging.
* With the introduction of the ShadowCursor, we no longer have the
selection range's endpoints coinciding the with beginning and end of the
respective startContainer and endContainer. Therefore, modify
getExtremeRanges to reflect this. If an endpoint of the selection range
does not lie within a TextNode, we latch on to the nearest text node
within.
* In the SessionController, call maintainShadowSelection() if the
selection might leak outside the allowed local root, so that the
window selection object remains root-confined.
* Clone ranges if they may be later modified.
Properly detach ranges once they are used in SelectionView, less
memory leaks.
2013-10-15 11:44:24 +02:00
Aditya Bhatt b426aab73f Add a SelectionView class that can be initialized with a cursor, a
SelectionViewManager that maintains SelectionView instances, and a
shadow cursor object that is an invisible caret-less cursor, fed to both
SessionController and SessionView, which follows the selection as it
changes.
Selections by each cursor are colored according to their memberid
2013-10-15 11:44:23 +02:00
Friedrich W. H. Kossebau 55e6322bf7 Little fixes in editor code that closure compiler did not like 2013-10-07 10:45:41 +02:00
Friedrich W. H. Kossebau f46bb9e502 Change ops.OperationRouter.push to take a sequence of ops
Taking a sequence of ops also enables to give the guarantee that all
contained operations will be executed directly after each other,
in the given order. So creator of the ops can calculate the spec of each op
by relying on the known effect of the other ops.
2013-10-02 19:29:52 +02:00
Philip Peitsch 3f6790ef5f Add insert image button to the editor 2013-10-02 16:37:49 +10:00
Friedrich W. H. Kossebau 297562afb3 Consistency: "named" style -> "common" style 2013-09-20 18:50:29 +02:00
Lu Li bbb5ecef8a Refactoring: changed Op(Add|Remove)ParagraphStyle to Op(Add|Remove)Style, so they can handle all style families NOT just paragraph 2013-09-20 17:36:41 +02:00
Aditya Bhatt 57c8e6c462 Handle default styles properly in the editor.
* EditorSession gets a bit of abstraction which allows smoothly
using the same functions to handle paragraph styles, where an empty
styleName means the default style.
* The paragraphStyles widget now names the default style as ":default"
internally, because dojo could not handle "" properly as an entry value.
* OpUpdateParagraphStyle now knows to treat "" as default style.
* Translations for defaultStyle
2013-09-17 16:27:29 +02:00
Friedrich W. H. Kossebau de1103fcfe Add gui.DirectParagraphStyler, a UI-less tool specialized on direct styling of paragraphs 2013-09-10 15:52:39 +02:00
Friedrich W. H. Kossebau eb57ef2def Add gui.DirectTextStyler, a UI-less tool specialized on direct styling of text 2013-09-10 13:02:28 +02:00
Philip Peitsch 15f4bba862 Clarified document signals (common style created/deleted)
Creating an automatic style was firing signalStyleCreated/Deleted events
unexpectedly. Renamed these to signalCommonParagraphStyle* instead to
clarify that this signal only fires when "common" styles are created.

Terminology was taken from ODF specs:
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415058_253892949
2013-09-09 19:58:44 +10:00
Philip Peitsch d1cdcfb2cb Add direct font family and size styling support to Editor
* tweak fontPicker wrapper to be a little easier to use within other
  widgets
* keep annotation button stays in same position
2013-09-09 09:16:04 +02:00
Philip Peitsch 0d7aa91424 Forward on paragraph change events for all paragraphs within the user's selection 2013-09-06 18:30:53 +02:00
Philip Peitsch c7eac5bd5e Added buttons to editor for modifying paragraph alignment and indentation 2013-09-06 18:30:53 +02:00
Friedrich W. H. Kossebau 679eccd2f9 fix wrong memberId -> memberid in opspecs created in EditorSession (too aggressive CamelCasing...) 2013-09-03 13:40:21 +02:00
Friedrich W. H. Kossebau 1f7469884f redo class Editor (for proper re-usage and also destruction)
* Editor can have three states: without a document/session, with a document/session, destroyed
* Editor is created without any document/session initially
* document/session has to be closed before loading another one
* EditorSession/Session are bound to a document/session, recreated for another one
* all other objects are reused with another document/session
* destroy() cleans up the Editor from the webpage it is embedded (at least good enough for now)
* startEditing/endEditing have to be done by the user of Editor
2013-09-03 01:02:48 +02:00
Friedrich W. H. Kossebau f2b56083e6 add a ops.Server interface + a ServerFactory interface, move Nowjs-based server stuff into programs/editor/server/nowjs
MemberModel, SessionList, and OperationRouter are proxy classes which use
the server object to communicate with the server, while the server does
not always need to know about them
e.g. some server could not provide a SessionList, while another could have
that and more, while sharing the same basic server protocol.
Thus the serverfactory instance is separated from the server instance.
2013-08-28 16:33:49 +02:00
Friedrich W. H. Kossebau f4d293645d Rename OpDeleteParagraphStyle to OpRemoveParagraphStyle 2013-08-08 16:26:03 +02:00
Friedrich W. H. Kossebau 4322b22858 Rename everything with "[Uu]ser|[Ppeople]" to "[Mm]ember"
consolidates the terms used a little
2013-08-07 18:03:19 +02:00
Aditya Bhatt 825a44affc * OpAddAnnotation that lets you create annotations. This only creates an
annotation-end node if the length of the selection > 0.
* Adds a button to the editor to add an annotation at the given cursor position
or selection
* A bad hack in AnnotationViewManager: The dc:creator of
a created annotation is initially empty because the operation has no
way to access the user model even if it knows the memberid. The
SessionView has a new rule for editinfo:memberid attributes that sets
the CSS content: attribute to the user name. AnnotationViewManager,
for now, will read this CSS property and set the text of dc:creator to
that; at least till we have a better way to access the usermodel in
the future
* Rerenders annotations when an annotation is added for tracking (like upon creation)
* SessionView gets a way to concretely specify the CSS pseudo-class for a rule (:before, :after, etc)
* enableAnnotations only allows handles annotations if the allow value
changes
* Add translation strings for annotate
2013-08-05 19:16:32 +02:00
Friedrich W. H. Kossebau cce094b2c1 turn OpCloneParagraphStyle into OpAddParagraphStyle
having all the data in the spec not only helps/enables OT, but also
makes it possible to create styles in documents without any prior existing
2013-08-01 20:00:44 +02:00
Friedrich W. H. Kossebau b10f41de7b Rename "OpApplyStyle" to "OpApplyDirectStyling" and its spec elemnt "info" to "setProperties" 2013-07-30 12:05:09 +02:00
Philip Peitsch f25d936355 Removing a cursor will now cause the associated caret to be removed
Removing the local cursor (e.g., calling SessionController.endEditing)
previously left behind an orphaned caret that would continue to receive
focus/blur commands and attempt to remain visible. This would cause an
error to be thrown after most operations.

This change turns CaretFactory into a manager that is responsible for
proper disposal of carets unpon the corresponding cursor's removal from
the document.
2013-07-26 22:26:11 +10:00
Lu Li c75f303cfb handle shortcuts for applying bold, italic & underline 2013-07-24 09:58:17 +02:00
Lu Li 0eff2c6a0a Refactor odf.Formatting class
* move getTextNode from OdfUtils to StyleHelper
* move some of the unit tests under FormattingTests to StyleHelperTests
2013-07-22 16:47:42 +02:00
Jos van den Oever 8e633684bc JSLint fixes. 2013-07-10 15:51:03 +02:00
Philip Peitsch a3dd2374dd SessionController now better hides absence of an undo manager
Consumers of the SessionController would all need to check if and how
undo was supported. As a result, it makes more sense to simply expose
the necessary signals for UI purposes, and encapsulate how the signals
are bound inside SessionController
2013-07-09 02:18:34 +10:00
Philip Peitsch e2b477968f Implemented trivial singler-user only undo manager
This manager supplies really simple undo and redo behaviour. Undo is
achieved by resetting the document back to the initial state, and
replaying all operations on top of it.

This undo mechanism is not suitable for a networked operation sessions
as there is no attempt to communicate the resetting of the document
state.

Initial undo state for a document is set when startEditing is called on
a session. This state is effectively a clean document with the local
cursor added to it.

* Added undo/redo buttons to the editor
2013-07-09 01:48:24 +10:00
Friedrich W. H. Kossebau a9e386a7a0 Fixup API dox of EditorSession.updateParagraphStyle() 2013-07-05 12:44:02 +02:00
Friedrich W. H. Kossebau f558e33231 During initial ops replay there is no own cursor yet added, so either test for the cursor or do not do cursor-using things 2013-07-03 14:57:28 +02:00
Friedrich W. H. Kossebau f6c017a7f3 in ops.OpUpdateParagraphStyle split info into setProperties & removedProperties
using value "null" for "remove" and "undefined" for "skip" is hard/impossible to map to other languages
2013-07-02 22:58:43 +02:00
Friedrich W. H. Kossebau c71bdb30bf Remove unused property "styleNameBefore" from spec of ops.OpSetParagraphStyle 2013-07-02 22:35:49 +02:00
Philip Peitsch ec2e72a58b Editor uses direct formatting for applying font style changes 2013-07-02 21:19:36 +02:00
Jos van den Oever eecfa4d201 Remove trailing spaces and tabs. 2013-06-19 16:47:52 +02:00