2015-04-21 09:03:17 -05:00
|
|
|
Leaflet platform for LibreOffice On-Line
|
|
|
|
========================================
|
2015-03-09 08:58:37 -05:00
|
|
|
|
2015-04-21 09:03:17 -05:00
|
|
|
This is the client part of LibreOffice On-Line. For the server part, see the
|
|
|
|
../loolwsd/README, and install it first.
|
|
|
|
|
|
|
|
Build dependencies
|
|
|
|
------------------
|
|
|
|
|
|
|
|
First you need to install 'jake'. As root, do:
|
2015-03-09 08:58:37 -05:00
|
|
|
|
|
|
|
npm install -g jake
|
|
|
|
npm install
|
2015-04-21 09:03:17 -05:00
|
|
|
|
|
|
|
Alternatively, you can use the provided zip (as a normal user):
|
|
|
|
|
|
|
|
unzip node_modules/modules.zip -d node_modules
|
|
|
|
|
2015-05-27 09:08:58 -05:00
|
|
|
A third way is to use npm as a user, but set its prefix to a directory where
|
|
|
|
you have write access. If you want that, you need to have an ~/.npmrc with the
|
|
|
|
line e.g.
|
|
|
|
|
|
|
|
prefix=/opt/npm
|
|
|
|
|
2015-04-21 09:03:17 -05:00
|
|
|
Building
|
|
|
|
--------
|
|
|
|
|
|
|
|
As a normal user:
|
|
|
|
|
2015-03-09 08:58:37 -05:00
|
|
|
jake build
|
2015-04-06 09:14:21 -05:00
|
|
|
cd plugins/draw-0.2.4
|
|
|
|
jake build
|
2015-03-23 12:24:39 -05:00
|
|
|
|
2015-04-21 09:03:17 -05:00
|
|
|
Running
|
|
|
|
-------
|
|
|
|
|
|
|
|
To see an example:
|
|
|
|
|
|
|
|
* run loolwsd, like:
|
|
|
|
|
2015-05-06 02:08:56 -05:00
|
|
|
./loolwsd --systemplate=${SYSTEMPLATE} --lotemplate=${MASTER}/instdir --childroot=${ROOTFORJAILS}
|
2015-04-21 09:03:17 -05:00
|
|
|
|
|
|
|
* open debug/document/document_simple_example.html in the browser, like:
|
|
|
|
|
|
|
|
firefox debug/document/document_simple_example.html
|
|
|
|
|
2015-05-06 02:08:56 -05:00
|
|
|
* modify the URL to allow loleaflet to connect to a server and open a document
|
|
|
|
|
2015-07-15 11:25:34 -05:00
|
|
|
http://web-page/document_simple_example.html?file_path=file:///PATH/TO/DOC&host=ws://localhost:9980
|
2015-05-06 02:08:56 -05:00
|
|
|
|
2015-04-21 09:03:17 -05:00
|
|
|
and you should see the document in the browser. In case anything goes wrong,
|
|
|
|
check the loolwsd console for the debugging output.
|
|
|
|
|
2015-07-15 11:25:34 -05:00
|
|
|
API & events
|
|
|
|
------------
|
|
|
|
|
|
|
|
Search:
|
|
|
|
- API:
|
|
|
|
map.search(text, [backward])
|
|
|
|
- events:
|
|
|
|
map.on('searchnotfound', function)
|
|
|
|
|
|
|
|
Zoom:
|
|
|
|
- API:
|
|
|
|
map.zoomIn(amount)
|
|
|
|
map.zoomOut(amout)
|
|
|
|
map.getMinZoom()
|
|
|
|
map.getMaxZoom()
|
|
|
|
- events:
|
|
|
|
map.on('zoomend zoomlevelschange', function)
|
|
|
|
|
|
|
|
Edit, view, readOnly:
|
|
|
|
- API:
|
|
|
|
map.setPermission('edit' | 'view' | 'readonly')
|
|
|
|
- events:
|
|
|
|
map.on('updatepermission', function (e) {}) where:
|
|
|
|
+ e.perm == 'edit' | 'view' | 'readonly'
|
|
|
|
|
|
|
|
Buttons like Bold, Italic, Strike through etc.
|
|
|
|
- API:
|
|
|
|
map.toggleCommandState('Bold' | 'Italic' | 'Underline' | 'Strikeout' | 'AlighLeft', etc)
|
|
|
|
- events:
|
|
|
|
map.on('commandstatechanged', function (e) {}) where:
|
|
|
|
+ e.unoCmd == 'Bold' | 'Italic' etc.
|
|
|
|
+ e.state = 'true' | 'false'
|
|
|
|
|
|
|
|
Parts (like slides in presentation, or sheets in spreadsheets):
|
|
|
|
- API:
|
|
|
|
map.setPart('next' | 'prev' | partNumber)
|
|
|
|
map.getPartPreview(id, part, maxWidth, maxHeight) where:
|
|
|
|
+ id = the ID of the request so that the response can be identified
|
|
|
|
+ maxWidth / maxHeight are the desired dimensions of the preview, a smaller
|
|
|
|
image might be returned in order to keep the original ratio of the document
|
|
|
|
- events:
|
|
|
|
map.on('updateparts', function (e) {}) where:
|
|
|
|
+ e.currentPart is the current part
|
|
|
|
+ e.parts == the number of parts that the document has
|
|
|
|
+ e.docType == 'text' | 'spreadsheet' | 'presentation' | 'drawing' | 'other'
|
|
|
|
+ [e.partNames] if present, part names (e.g. sheet names)
|
|
|
|
|
|
|
|
Statusindicator (when the document is loading):
|
|
|
|
- events
|
|
|
|
map.on('statusindicator', function (e) {}) where:
|
|
|
|
+ e.statusType = 'start' | 'setvalue' | 'finish'
|
|
|
|
+ e.value == a value from 0 to 100 indicating the status
|
|
|
|
if the statusType is 'setvalue
|
|
|
|
|
2015-04-21 09:03:17 -05:00
|
|
|
Contributing
|
|
|
|
------------
|
|
|
|
|
|
|
|
Code conventions:
|
|
|
|
|
|
|
|
* 'jake lint' should be run before commiting
|
|
|
|
* files should have unix line terminators (LF)
|
|
|
|
* tools to convert files: dos2unix or fromdos
|
|
|
|
|
|
|
|
Implementation details
|
|
|
|
----------------------
|
2015-03-24 06:15:43 -05:00
|
|
|
|
2015-03-23 12:24:39 -05:00
|
|
|
Loading a document:
|
|
|
|
The map should have the following options:
|
|
|
|
- center at [0, 0] this will try to place the [0, 0] point in the middle of the
|
|
|
|
map, but it will be moved in the top left corner when the maxBounds are set
|
|
|
|
- zoom = defautl zoom value, zooming in and out will refer to this value
|
|
|
|
- server address
|
|
|
|
|
|
|
|
The layer (actual document) should have the following options:
|
|
|
|
- doc = path to the document that will be loaded
|
|
|
|
- useSocket = tells the map the tiles will be received from a websocket
|
|
|
|
connection. If this parameter is false, an image will be loaded in each tile
|
|
|
|
|
2015-04-10 08:29:01 -05:00
|
|
|
How zooming works:
|
2015-05-01 11:18:03 -05:00
|
|
|
The zoom level goes from 1 to 20 (those limits can be changed) and the initial
|
|
|
|
level is 10, which represents the 100% zoom level. The zoom factor is 1.2
|
2015-04-10 08:29:01 -05:00
|
|
|
|
2015-04-06 09:14:21 -05:00
|
|
|
Controls are added above the map in a div called "controls" is intended to be used as a toolbar.
|
2015-05-01 11:18:03 -05:00
|
|
|
There is no leaflet method of adding them in a separate div, so for now this is done in the html
|
2015-04-06 09:14:21 -05:00
|
|
|
document after the map initialization.
|
2015-05-01 11:18:03 -05:00
|
|
|
|
2015-05-06 02:08:56 -05:00
|
|
|
To enable scrollbars the map is placed above a div that contains a bigger div of
|
|
|
|
the document's size (a mock document). So the div under the map gets scrollbars which
|
2015-05-01 11:18:03 -05:00
|
|
|
are independent of the map's div, thus enabling us to link them to the map as needed.
|
|
|
|
When the user scrolls, the map is panned by the same amount as it would've been scrolled.
|
2015-05-06 02:08:56 -05:00
|
|
|
Also, some custom jquery scrollbars are used, to trigger the same scroll events across
|
2015-05-01 11:18:03 -05:00
|
|
|
browsers.
|