epitelete
v0.2.20
Published
PERF Middleware for Editors in the Proskomma Ecosystem
Downloads
251
Readme
Epitelete
Installation
Epitelete is available as an npm package.
npm install epitelete
Usage
Proskomma mode
Uses a proskomma instance to handle PERF documents.
Example
import Epitelete from "epitelete"
import Proskomma from "proskomma";
const proskomma = new Proskomma();
proskomma.loadSuccinctDocSet(succintJson);
const docSetId = "doc_set_id";
const epitelete = new Epitelete({ proskomma, docSetId });
const bookCode = "GEN";
let docPerf = epitelete.readPerf(bookCode);
const sequenceId = docPerf.mainSequence;
const sequence = docPerf.sequences[sequenceId];
//...make changes in sequence
docPerf = epitelete.writePerf(bookCode,sequenceId,sequence);
docPerf = epitelete.undoPerf(bookCode);
docPerf = epitelete.redoPerf(bookCode);
How to
1. Install proskomma:
npm install proskomma
2. Instantiate and set Proskomma:
import Proskomma from "proskomma";
const proskomma = new Proskomma();
proskomma.loadSuccinctDocSet(succintJson);
...
succintJson
: ...
3. Instantiate Epitelete:
import Epitelete from "epitelete"
...
const docSetId = "doc_set_id";
const epitelete = new Epitelete({ proskomma, docSetId });
...
4. Get a document:
...
const bookCode = "GEN";
let docPerf = epitelete.readPerf(bookCode);
...
.readPerf()
: gets a document from cache or by fetching from the proskomma instance.
docPerf
: copy of the document that has been saved in cache. example docPerf content
5. Make changes to some docPerf
sequence:
...
const sequenceId = docPerf.mainSequence;
const sequence = docPerf.sequences[sequenceId];
//...make changes in sequence
...
6. Persist changes to epitelete s history:
...
docPerf = epitelete.writePerf(bookCode,sequenceId,sequence);
...
.writePerf()
: creates a copy of last saved document, updates it with the changed sequence and saves it in memory.
7. Undo/Redo your changes to docPerf:
...
docPerf = epitelete.undoPerf(bookCode);
docPerf = epitelete.redoPerf(bookCode);
...
.undoPerf()
: retrieves the previous changed document from history.
.redoPerf()
: retrieves the next changed document from history.
History size can be set at instantiation with the options
argument:
const options = { historySize: 5 }
const epitelete = new Epitelete({ proskomma, docSetId, options });
Standalone mode
Uses only given PERF documents.
Example
import Epitelete from "epitelete"
const docSetId = "doc_set_id";
const options = { historySize: 5 };
const epitelete = new Epitelete({ docSetId, options });
const bookCode = "GEN";
const perfJSON = {...}
let docPerf = await epitelete.sideloadPerf(bookCode,perfJSON);
const sequenceId = docPerf.mainSequence;
const sequence = docPerf.sequences[sequenceId];
//...make changes in sequence
docPerf = epitelete.writePerf(bookCode,sequenceId,sequence);
docPerf = epitelete.undoPerf(bookCode);
docPerf = epitelete.redoPerf(bookCode);
How to
1. Instatiate Epilete:
import Epitelete from "epitelete"
...
const docSetId = "doc_set_id";
const epitelete = new Epitelete({ docSetId [,options] });
...
Optionally could set historySize
in the options
arg.
2. Load a document into memory:
...
docPerf = await epitelete.sideloadPerf(bookCode, perfJSON);
...
perfJSON
: externally loaded and parsed documentPerf.
3. Use writePerf
,readPerf
,undoPerf
,redoPerf
as shown before.
API
License
This project is licensed under the MIT.