2018-02-13 17:19:32 +00:00
|
|
|
/**
|
2018-02-27 20:31:30 +00:00
|
|
|
* This module implements `<ref>` and `<references>` extension tag handling
|
2016-01-13 23:34:40 +00:00
|
|
|
* natively in Parsoid.
|
2018-02-13 17:19:32 +00:00
|
|
|
* @module ext/Cite
|
|
|
|
*/
|
2017-04-27 17:45:54 +00:00
|
|
|
|
2016-01-13 23:34:40 +00:00
|
|
|
'use strict';
|
|
|
|
|
2019-04-02 22:06:21 +00:00
|
|
|
const Ref = require('./Ref.js');
|
|
|
|
const References = require('./References.js');
|
2019-04-03 17:16:56 +00:00
|
|
|
const RefProcessor = require('./RefProcessor.js');
|
2016-01-13 23:34:40 +00:00
|
|
|
|
|
|
|
/**
|
2019-04-02 22:06:21 +00:00
|
|
|
* Native Parsoid implementation of the Cite extension
|
|
|
|
* that ties together `<ref>` and `<references>`.
|
2018-02-13 17:19:32 +00:00
|
|
|
*/
|
2019-04-02 22:06:21 +00:00
|
|
|
class Cite {
|
|
|
|
constructor() {
|
|
|
|
this.config = {
|
|
|
|
name: 'cite',
|
|
|
|
domProcessors: {
|
2019-04-03 17:16:56 +00:00
|
|
|
wt2htmlPostProcessor: RefProcessor,
|
2019-04-02 22:06:21 +00:00
|
|
|
html2wtPreProcessor: (...args) => this._html2wtPreProcessor(...args),
|
|
|
|
},
|
|
|
|
tags: [
|
|
|
|
{
|
|
|
|
name: 'ref',
|
|
|
|
toDOM: Ref.toDOM,
|
|
|
|
fragmentOptions: {
|
2019-06-13 17:53:22 +00:00
|
|
|
sealFragment: true,
|
2019-04-02 22:06:21 +00:00
|
|
|
},
|
|
|
|
serialHandler: Ref.serialHandler, // FIXME: Rename to toWikitext
|
|
|
|
lintHandler: Ref.lintHandler,
|
|
|
|
// FIXME: Do we need (a) domDiffHandler (b) ... others ...
|
|
|
|
}, {
|
|
|
|
name: 'references',
|
|
|
|
toDOM: References.toDOM,
|
|
|
|
serialHandler: References.serialHandler,
|
|
|
|
lintHandler: References.lintHandler,
|
2018-06-09 04:37:17 +00:00
|
|
|
},
|
2019-04-02 22:06:21 +00:00
|
|
|
],
|
|
|
|
styles: [
|
|
|
|
'ext.cite.style',
|
|
|
|
'ext.cite.styles',
|
|
|
|
],
|
|
|
|
};
|
2016-01-13 23:34:40 +00:00
|
|
|
}
|
|
|
|
|
2019-04-02 22:06:21 +00:00
|
|
|
/**
|
|
|
|
* html -> wt DOM PreProcessor
|
|
|
|
*
|
|
|
|
* This is to reconstitute page-level information from local annotations
|
|
|
|
* left behind by editing clients.
|
|
|
|
*
|
|
|
|
* Editing clients add inserted: true or deleted: true properties to a <ref>'s
|
|
|
|
* data-mw object. These are no-ops for non-named <ref>s. For named <ref>s,
|
|
|
|
* - for inserted refs, we might want to de-duplicate refs.
|
|
|
|
* - for deleted refs, if the primary ref was deleted, we have to transfer
|
|
|
|
* the primary ref designation to another instance of the named ref.
|
|
|
|
*/
|
|
|
|
_html2wtPreProcessor(env, body) {
|
|
|
|
// TODO
|
2016-01-13 23:34:40 +00:00
|
|
|
}
|
2019-04-02 22:06:21 +00:00
|
|
|
}
|
2016-01-13 23:34:40 +00:00
|
|
|
|
|
|
|
if (typeof module === "object") {
|
2016-04-21 18:52:34 +00:00
|
|
|
module.exports = Cite;
|
2016-01-13 23:34:40 +00:00
|
|
|
}
|