mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 01:30:32 +00:00
30aaf6574c
* unwrapFragment had a somewhat unusual behavior which could be a source of bugs while reasoning with it. If undefined, it's default value is true which is contrary to how we think of undefined. * Flipping the polarity of the flag to sealFragment makes the semantics easier to reason with and where !empty(..) applies more naturally to it. Change-Id: Ia50cba345f37e815e5f5f95abb452c8eefcf9011
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
/**
|
|
* This module implements `<ref>` and `<references>` extension tag handling
|
|
* natively in Parsoid.
|
|
* @module ext/Cite
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const Ref = require('./Ref.js');
|
|
const References = require('./References.js');
|
|
const RefProcessor = require('./RefProcessor.js');
|
|
|
|
/**
|
|
* Native Parsoid implementation of the Cite extension
|
|
* that ties together `<ref>` and `<references>`.
|
|
*/
|
|
class Cite {
|
|
constructor() {
|
|
this.config = {
|
|
name: 'cite',
|
|
domProcessors: {
|
|
wt2htmlPostProcessor: RefProcessor,
|
|
html2wtPreProcessor: (...args) => this._html2wtPreProcessor(...args),
|
|
},
|
|
tags: [
|
|
{
|
|
name: 'ref',
|
|
toDOM: Ref.toDOM,
|
|
fragmentOptions: {
|
|
sealFragment: true,
|
|
},
|
|
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,
|
|
},
|
|
],
|
|
styles: [
|
|
'ext.cite.style',
|
|
'ext.cite.styles',
|
|
],
|
|
};
|
|
}
|
|
|
|
/**
|
|
* 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
|
|
}
|
|
}
|
|
|
|
if (typeof module === "object") {
|
|
module.exports = Cite;
|
|
}
|