cirsfid-unibo / lime

LIME (Language Independent Markup Editor)
http://lime.cirsfid.unibo.it/
29 stars 14 forks source link

Document Template ? #42

Closed kohsah closed 8 years ago

kohsah commented 8 years ago

When I create a new document , I want a standard template for it that places some default content.

I saw buildEmptyDocumentTemplate() in LanguagesPlugin ... couldnt i just override that and inject my custom html ?

obujor commented 8 years ago

The buildEmptyDocumentTemplate uses the json configuration of a new document template defined the "newDocumentTemplate" property of "markupMenu_rules.json" file, you can see an example of that in this file.

You can override that and inject custom html, by you have to inject the html accepted by LIME with id and classes used by the editor. To avoid this we created the "newDocumentTemplate" which can be changed depending of the type of document or/and locale, and it is designed to be easier to write than html.

There is another method to avoid creating the html it can be a default documents in the database in AkomaNtoso and load the default document of the selected type, in this case there is some code to write in order to achieve this.

kohsah commented 8 years ago

Thanks @obujor ...

There is another method to avoid creating the html it can be a default documents in the database in AkomaNtoso and load the default document of the selected type, in this case there is some code to write in order to achieve this.

Can you provide some more details on this method, seems to be the one i would like to use.

obujor commented 8 years ago

Yes, as I said it has to be implemented, but is not hard. You need to upload in the database (for each user or in a shared folder) one or more documents you want to use as new document, let's say:

When users create a new document, you need to call the function from Storage controller: storage.openDocument(pathOfNewDocumentBasedOnDocTypeOrLocale); And this should open the new document in the editor, but if the user saves it the document will be overwritten, so this needs some modifications in order to open the "pathOfNewDocumentBasedOnDocTypeOrLocale" path but treat it as '.untitled.xml' document which is the default new document path, you can get its path by calling this "User.getDefaultFilePath".

kohsah commented 8 years ago

Cool @obujor will try this method