Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist output names in cell attributes
This is needed to be able to allow for rendering cells without starting the engine.
- Loading branch information
Showing
3 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { prettyPrintXML } from 'substance' | ||
import { JATSExporter } from 'substance-texture' | ||
import persistCellStates from './persistCellStates' | ||
|
||
export default { | ||
export (session, { sessions }) { | ||
// FIXME: hard-coded, and thus bad | ||
// TODO: export only those resources which have been changed | ||
// Also we need to | ||
let jatsExporter = new JATSExporter() | ||
let pubMetaDb = sessions['pub-meta'].getDocument() | ||
let doc = session.getDocument() | ||
let dom = doc.toXML() | ||
|
||
let res = jatsExporter.export(dom, { pubMetaDb, doc }) | ||
persistCellStates(doc, res.dom) | ||
|
||
console.info('saving jats', res.dom.getNativeElement()) | ||
// TODO: bring back pretty printing (currently messes up CDATA content) | ||
let xmlStr = prettyPrintXML(res.dom) | ||
return xmlStr | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { forEach } from 'substance' | ||
|
||
export default function persistCellStates (doc, dom) { | ||
let cells = doc.getIndex('type').get('cell') | ||
forEach(cells, cell => { | ||
let el = dom.find(`#${cell.id}`) | ||
let state = cell.state | ||
// store the cell output | ||
if (state.output) { | ||
el.attr('output-name', state.output) | ||
} | ||
}) | ||
} |