From abebba2d95b590b142830a8d49e8ca3ebc2efa84 Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Mon, 14 Sep 2020 16:14:59 -0400 Subject: [PATCH 1/8] remove all private exports, update exports.public to module.exports --- .gitignore | 1 + lib/formats/actionbox.js | 4 +- lib/formats/ad_placement.js | 7 +-- lib/formats/autolink.js | 36 +----------- lib/formats/blockquote.js | 5 +- lib/formats/bold.js | 5 +- lib/formats/br.js | 21 +------ lib/formats/bullet.js | 5 +- lib/formats/credits.js | 4 +- lib/formats/del.js | 4 +- lib/formats/doc.js | 4 +- lib/formats/dropcap.js | 21 +------ lib/formats/endmark.js | 21 +------ lib/formats/fifthheader.js | 5 +- lib/formats/firstheader.js | 5 +- lib/formats/fourthheader.js | 5 +- lib/formats/grouping.js | 7 +-- lib/formats/hr.js | 4 +- lib/formats/html.js | 4 +- lib/formats/id.js | 7 +-- lib/formats/image.js | 4 +- lib/formats/index.js | 90 +++++++++++++++--------------- lib/formats/ins.js | 4 +- lib/formats/italic.js | 5 +- lib/formats/leadgraf.js | 21 +------ lib/formats/link.js | 17 +----- lib/formats/list.js | 5 +- lib/formats/mark.js | 4 +- lib/formats/newsletter.js | 4 +- lib/formats/oembed.js | 4 +- lib/formats/position.js | 7 +-- lib/formats/pullquote.js | 4 +- lib/formats/pym.js | 4 +- lib/formats/ratingcard.js | 4 +- lib/formats/readmore.js | 4 +- lib/formats/secondheader.js | 5 +- lib/formats/small.js | 5 +- lib/formats/strike.js | 2 +- lib/formats/subscript.js | 2 +- lib/formats/superscript.js | 2 +- lib/formats/thirdheader.js | 5 +- lib/formats/toh_project_details.js | 4 +- lib/formats/toh_tools.js | 4 +- lib/formats/video.js | 4 +- 44 files changed, 88 insertions(+), 301 deletions(-) diff --git a/.gitignore b/.gitignore index 5417130..d3e2be3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .grunt +.vscode build lib-cov coverage diff --git a/lib/formats/actionbox.js b/lib/formats/actionbox.js index d270df0..c16fb72 100644 --- a/lib/formats/actionbox.js +++ b/lib/formats/actionbox.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); @@ -17,5 +17,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('actionbox'); diff --git a/lib/formats/ad_placement.js b/lib/formats/ad_placement.js index 6f9a4f3..4ed9c05 100644 --- a/lib/formats/ad_placement.js +++ b/lib/formats/ad_placement.js @@ -1,9 +1,4 @@ -exports.private = { - type: 'line', - attribute: 'data-ad-placement-anchor' -}; - -exports.public = { +module.exports = { type: 'line', add: function(node, value) { // add the attribute to the top-most wrapper div diff --git a/lib/formats/autolink.js b/lib/formats/autolink.js index ff7ef33..8fe1a21 100644 --- a/lib/formats/autolink.js +++ b/lib/formats/autolink.js @@ -1,40 +1,6 @@ var addLink = require('./link').public.add; -exports.private = { - add: function(node, value, dom) { - if (node.nodeType !== Node.ELEMENT_NODE) { - var span = node.ownerDocument.createElement('span'); - dom(node).wrap(span); - node = span; - } - node.setAttribute('data-autolink-id', value.id); - node.setAttribute('data-autolink-href', value.href); - if (value.disabled) { - node.setAttribute('data-autolink-disabled', ''); - } else { - node.removeAttribute('data-autolink-disabled'); - } - return node; - }, - remove: function(node) { - node.removeAttribute('data-autolink-id'); - node.removeAttribute('data-autolink-href'); - node.removeAttribute('data-autolink-disabled'); - return node; - }, - value: function(node) { - return { - id: node.getAttribute('data-autolink-id'), - href: node.getAttribute('data-autolink-href'), - disabled: node.hasAttribute('data-autolink-disabled') - }; - }, - match: function(node) { - return node.hasAttribute('data-autolink-id'); - } -}; - -exports.public = { +module.exports = { add: function(node, value, dom) { if (!value.disabled) { node = addLink(node, value.href, dom); diff --git a/lib/formats/blockquote.js b/lib/formats/blockquote.js index bb04602..43dbb51 100644 --- a/lib/formats/blockquote.js +++ b/lib/formats/blockquote.js @@ -1,4 +1 @@ -var blockquote = { type: 'line', parentTag: 'BLOCKQUOTE' }; - -exports.public = blockquote; -exports.private = Object.assign({}, blockquote, { exclusive: true, inherit: true }); +module.exports = { type: 'line', parentTag: 'BLOCKQUOTE' }; diff --git a/lib/formats/bold.js b/lib/formats/bold.js index 36b9294..cfd56ef 100644 --- a/lib/formats/bold.js +++ b/lib/formats/bold.js @@ -1,4 +1 @@ -var bold = { tag: 'STRONG' }; - -exports.public = bold; -exports.private = Object.assign({}, bold, { prepare: 'bold' }); +module.exports = { tag: 'STRONG' }; diff --git a/lib/formats/br.js b/lib/formats/br.js index e61831b..ae89005 100644 --- a/lib/formats/br.js +++ b/lib/formats/br.js @@ -1,27 +1,8 @@ -exports.private = { - type: 'line', - reverseMerge: true, - add: function(node) { - node.classList.add('soft-break'); - return node; - }, - remove: function(node) { - node.classList.remove('soft-break'); - return node; - }, - value: function(node) { - return node.classList.contains('soft-break'); - }, - match: function(node) { - return node.classList.contains('soft-break'); - } -}; - // All lines that end with a line-break will end with a
tag. `to_unison_html` // post-processing will strip out extra

tags b/t lines after the fact. // // Ex.

Hello

world!

=>

Hello
world!

-exports.public = { +module.exports = { type: 'line', add: function(node) { var br = node.ownerDocument.createElement('br'); diff --git a/lib/formats/bullet.js b/lib/formats/bullet.js index f8a9f92..3d764e6 100644 --- a/lib/formats/bullet.js +++ b/lib/formats/bullet.js @@ -1,4 +1 @@ -var bullet = { type: 'line', parentTag: 'UL', tag: 'LI' }; - -exports.public = bullet; -exports.private = Object.assign({}, bullet, { exclusive: true, inherit: true }); +exports.public = { type: 'line', parentTag: 'UL', tag: 'LI' }; diff --git a/lib/formats/credits.js b/lib/formats/credits.js index 82e4a00..3363f2d 100644 --- a/lib/formats/credits.js +++ b/lib/formats/credits.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); var div = node.ownerDocument.createElement('div'); @@ -9,5 +9,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('credits'); diff --git a/lib/formats/del.js b/lib/formats/del.js index b15b4c3..62d85b4 100644 --- a/lib/formats/del.js +++ b/lib/formats/del.js @@ -1,3 +1 @@ -exports.private = exports.public = { - tag: 'DEL' -}; +module.exports = { tag: 'DEL' }; diff --git a/lib/formats/doc.js b/lib/formats/doc.js index e615202..0fce4f9 100644 --- a/lib/formats/doc.js +++ b/lib/formats/doc.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('div'); @@ -15,5 +15,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('doc'); \ No newline at end of file diff --git a/lib/formats/dropcap.js b/lib/formats/dropcap.js index 20d750f..4cf8d7e 100644 --- a/lib/formats/dropcap.js +++ b/lib/formats/dropcap.js @@ -1,23 +1,4 @@ -exports.private = { - type: 'line', - splitAffinity: 'left', - add: function(node, value) { - node.setAttribute('data-dropcap', value.toString()); - return node; - }, - remove: function(node) { - node.removeAttribute('data-dropcap'); - return node; - }, - value: function(node) { - return node.dataset.dropcap === 'true'; - }, - match: function(node) { - return node.tagName === 'P' && node.hasAttribute('data-dropcap'); - } -}; - -exports.public = { +module.exports = { type: 'line', add: function(node, value) { if (value) { diff --git a/lib/formats/endmark.js b/lib/formats/endmark.js index ca3cad7..990fe8a 100644 --- a/lib/formats/endmark.js +++ b/lib/formats/endmark.js @@ -1,23 +1,4 @@ -exports.private = { - type: 'line', - splitAffinity: 'right', - add: function(node, value) { - node.setAttribute('data-endmark', value.toString()); - return node; - }, - remove: function(node) { - node.removeAttribute('data-endmark'); - return node; - }, - value: function(node) { - return node.dataset.endmark === 'true'; - }, - match: function(node) { - return node.tagName === 'P' && node.hasAttribute('data-endmark'); - } -}; - -exports.public = { +module.exports = { type: 'line', add: function(node, value) { if (value) { diff --git a/lib/formats/fifthheader.js b/lib/formats/fifthheader.js index 42583d6..baef2fa 100644 --- a/lib/formats/fifthheader.js +++ b/lib/formats/fifthheader.js @@ -1,4 +1 @@ -var fifthheader = { type: 'line', tag: 'H5' }; - -exports.public = fifthheader; -exports.private = Object.assign({}, fifthheader, { exclusive: true }); +module.exports = { type: 'line', tag: 'H5' }; diff --git a/lib/formats/firstheader.js b/lib/formats/firstheader.js index 65d7c58..ec34982 100644 --- a/lib/formats/firstheader.js +++ b/lib/formats/firstheader.js @@ -1,4 +1 @@ -var firstheader = { type: 'line', tag: 'H1' }; - -exports.public = firstheader; -exports.private = Object.assign({}, firstheader, { exclusive: true }); +module.exports = { type: 'line', tag: 'H1' }; diff --git a/lib/formats/fourthheader.js b/lib/formats/fourthheader.js index b5bcc60..b1ac7f8 100644 --- a/lib/formats/fourthheader.js +++ b/lib/formats/fourthheader.js @@ -1,4 +1 @@ -var fourthheader = { type: 'line', tag: 'H4' }; - -exports.public = fourthheader; -exports.private = Object.assign({}, fourthheader, { exclusive: true }); +module.exports = { type: 'line', tag: 'H4' }; diff --git a/lib/formats/grouping.js b/lib/formats/grouping.js index 369300c..3536a95 100644 --- a/lib/formats/grouping.js +++ b/lib/formats/grouping.js @@ -1,9 +1,4 @@ -exports.private = { - type: 'line', - attribute: 'data-grouping' -}; - -exports.public = { +module.exports = { type: 'line', add: function(node, value, dom) { // Create the image grid container with appropriate classes diff --git a/lib/formats/hr.js b/lib/formats/hr.js index f2ce0de..5929978 100644 --- a/lib/formats/hr.js +++ b/lib/formats/hr.js @@ -1,9 +1,7 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { var hr = dom(node.parentNode).switchTag('hr').get(); hr.classList.add('p-entry-hr'); return hr; } }; - -exports.private = require('./object')('hr'); diff --git a/lib/formats/html.js b/lib/formats/html.js index cead1d7..403ab62 100644 --- a/lib/formats/html.js +++ b/lib/formats/html.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { var temp = node.ownerDocument.createElement('div'); temp.innerHTML = value.value; @@ -19,5 +19,3 @@ exports.public = { return frag; } }; - -exports.private = require('./object')('html'); diff --git a/lib/formats/id.js b/lib/formats/id.js index 874f81c..572eb7f 100644 --- a/lib/formats/id.js +++ b/lib/formats/id.js @@ -1,9 +1,4 @@ -exports.private = { - type: 'line', - attribute: 'id' -}; - -exports.public = { +module.exports = { type: 'line', add: function(node, value) { if (!node.id) { diff --git a/lib/formats/image.js b/lib/formats/image.js index 7be41e0..ec54a4a 100644 --- a/lib/formats/image.js +++ b/lib/formats/image.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { var doc = node.ownerDocument; dom(node.parentNode).switchTag('figure'); @@ -29,5 +29,3 @@ exports.public = { return frag; } }; - -exports.private = require('./object')('image'); diff --git a/lib/formats/index.js b/lib/formats/index.js index 3dc0881..d5fb293 100644 --- a/lib/formats/index.js +++ b/lib/formats/index.js @@ -1,52 +1,52 @@ -function makeFormats(type) { +function makeFormats() { return { - bold: require('./bold')[type], - italic: require('./italic')[type], - mark: require('./mark')[type], - strike: require('./strike')[type], - superscript: require('./superscript')[type], - subscript: require('./subscript')[type], - firstheader: require('./firstheader')[type], - secondheader: require('./secondheader')[type], - thirdheader: require('./thirdheader')[type], - fourthheader: require('./fourthheader')[type], - fifthheader: require('./fifthheader')[type], - bullet: require('./bullet')[type], - list: require('./list')[type], - blockquote: require('./blockquote')[type], - link: require('./link')[type], - ins: require('./ins')[type], - del: require('./del')[type], - br: require('./br')[type], - autolink: require('./autolink')[type], - id: require('./id')[type], - position: require('./position')[type], - grouping: require('./grouping')[type], - dropcap: require('./dropcap')[type], - leadgraf: require('./leadgraf')[type], - endmark: require('./endmark')[type], - ad_placement: require('./ad_placement')[type], - image: require('./image')[type], - pullquote: require('./pullquote')[type], - oembed: require('./oembed')[type], - video: require('./video')[type], - hr: require('./hr')[type], - html: require('./html')[type], - doc: require('./doc')[type], - small: require('./small')[type], - actionbox: require('./actionbox')[type], - readmore: require('./readmore')[type], - ratingcard: require('./ratingcard')[type], - newsletter: require('./newsletter')[type], - credits: require('./credits')[type], - toh_project_details: require('./toh_project_details')[type], - toh_tools: require('./toh_tools')[type], - pym: require('./pym')[type] + bold: require('./bold'), + italic: require('./italic'), + mark: require('./mark'), + strike: require('./strike'), + superscript: require('./superscript'), + subscript: require('./subscript'), + firstheader: require('./firstheader'), + secondheader: require('./secondheader'), + thirdheader: require('./thirdheader'), + fourthheader: require('./fourthheader'), + fifthheader: require('./fifthheader'), + bullet: require('./bullet'), + list: require('./list'), + blockquote: require('./blockquote'), + link: require('./link'), + ins: require('./ins'), + del: require('./del'), + br: require('./br'), + autolink: require('./autolink'), + id: require('./id'), + position: require('./position'), + grouping: require('./grouping'), + dropcap: require('./dropcap'), + leadgraf: require('./leadgraf'), + endmark: require('./endmark'), + ad_placement: require('./ad_placement'), + image: require('./image'), + pullquote: require('./pullquote'), + oembed: require('./oembed'), + video: require('./video'), + hr: require('./hr'), + html: require('./html'), + doc: require('./doc'), + small: require('./small'), + actionbox: require('./actionbox'), + readmore: require('./readmore'), + ratingcard: require('./ratingcard'), + newsletter: require('./newsletter'), + credits: require('./credits'), + toh_project_details: require('./toh_project_details'), + toh_tools: require('./toh_tools'), + pym: require('./pym') }; } -exports.public = makeFormats('public'); -exports.internal = makeFormats('private'); +module.exports = makeFormats(); + exports.options = { blockTag: 'P', formatOrder: [ diff --git a/lib/formats/ins.js b/lib/formats/ins.js index 19f4533..1c2a954 100644 --- a/lib/formats/ins.js +++ b/lib/formats/ins.js @@ -1,3 +1 @@ -exports.private = exports.public = { - tag: 'INS' -}; +module.exports = { tag: 'INS' }; diff --git a/lib/formats/italic.js b/lib/formats/italic.js index 219f14f..95901a4 100644 --- a/lib/formats/italic.js +++ b/lib/formats/italic.js @@ -1,4 +1 @@ -var italic = { tag: 'EM' }; - -exports.public = italic; -exports.private = Object.assign({}, italic, { prepare: 'italic' }); +module.exports = { tag: 'EM' }; diff --git a/lib/formats/leadgraf.js b/lib/formats/leadgraf.js index 2e92e25..1b17254 100644 --- a/lib/formats/leadgraf.js +++ b/lib/formats/leadgraf.js @@ -1,23 +1,4 @@ -exports.private = { - type: 'line', - splitAffinity: 'left', - add: function(node, value) { - node.setAttribute('data-leadgraf', value.toString()); - return node; - }, - remove: function(node) { - node.removeAttribute('data-leadgraf'); - return node; - }, - value: function(node) { - return node.dataset.leadgraf === 'true'; - }, - match: function(node) { - return node.tagName === 'P' && node.hasAttribute('data-leadgraf'); - } -}; - -exports.public = { +module.exports = { type: 'line', add: function(node, value) { if (value) { diff --git a/lib/formats/link.js b/lib/formats/link.js index ad3f565..79c8ccb 100644 --- a/lib/formats/link.js +++ b/lib/formats/link.js @@ -1,19 +1,4 @@ -exports.private = { - tag: 'A', - add: function(node, value) { - node.setAttribute('href', value); - return node; - }, - remove: function(node) { - node.removeAttribute('href'); - return node; - }, - value: function(node) { - return node.getAttribute('href'); - } -}; - -exports.public = { +module.exports = { add: function(node, value, dom) { var link = node.ownerDocument.createElement('a'); dom(node).wrap(link); diff --git a/lib/formats/list.js b/lib/formats/list.js index 14910cf..d0cd08a 100644 --- a/lib/formats/list.js +++ b/lib/formats/list.js @@ -1,4 +1 @@ -var list = { type: 'line', parentTag: 'OL', tag: 'LI' }; - -exports.public = list; -exports.private = Object.assign({}, list, { exclusive: true, inherit: true }); +module.exports = { type: 'line', parentTag: 'OL', tag: 'LI' }; diff --git a/lib/formats/mark.js b/lib/formats/mark.js index 2e03c7c..9120222 100644 --- a/lib/formats/mark.js +++ b/lib/formats/mark.js @@ -1,9 +1,7 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { var blank = node.ownerDocument.createTextNode(''); dom(node).replace(blank); return blank; } }; - -exports.private = { tag: 'MARK' }; diff --git a/lib/formats/newsletter.js b/lib/formats/newsletter.js index c715849..6311fe3 100644 --- a/lib/formats/newsletter.js +++ b/lib/formats/newsletter.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); @@ -14,5 +14,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('newsletter'); diff --git a/lib/formats/oembed.js b/lib/formats/oembed.js index 9954b0d..e417bde 100644 --- a/lib/formats/oembed.js +++ b/lib/formats/oembed.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { var doc = node.ownerDocument; dom(node.parentNode).switchTag('div'); @@ -24,5 +24,3 @@ exports.public = { } } }; - -exports.private = require('./object')('oembed'); diff --git a/lib/formats/position.js b/lib/formats/position.js index 8389947..176bfc2 100644 --- a/lib/formats/position.js +++ b/lib/formats/position.js @@ -1,9 +1,4 @@ -exports.private = { - type: 'line', - attribute: 'data-position' -}; - -exports.public = { +module.exports = { type: 'line', add: function(node, value, dom) { var container = node.ownerDocument.createElement('div'); diff --git a/lib/formats/pullquote.js b/lib/formats/pullquote.js index c2b321e..ff5a018 100644 --- a/lib/formats/pullquote.js +++ b/lib/formats/pullquote.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, data, dom) { var formatNode = node.ownerDocument.createElement('q'); if (node.parentNode) { @@ -11,5 +11,3 @@ exports.public = { return node; } }; - -exports.private = require('./object')('pullquote'); diff --git a/lib/formats/pym.js b/lib/formats/pym.js index 650e59c..b5c4725 100644 --- a/lib/formats/pym.js +++ b/lib/formats/pym.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); @@ -14,5 +14,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('pym'); diff --git a/lib/formats/ratingcard.js b/lib/formats/ratingcard.js index 0311f07..e0df0a9 100644 --- a/lib/formats/ratingcard.js +++ b/lib/formats/ratingcard.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); @@ -15,5 +15,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('ratingcard'); diff --git a/lib/formats/readmore.js b/lib/formats/readmore.js index 73521b1..7be6465 100644 --- a/lib/formats/readmore.js +++ b/lib/formats/readmore.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); @@ -19,5 +19,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('readmore'); diff --git a/lib/formats/secondheader.js b/lib/formats/secondheader.js index 30aca1c..84abd7f 100644 --- a/lib/formats/secondheader.js +++ b/lib/formats/secondheader.js @@ -1,4 +1 @@ -var secondheader = { type: 'line', tag: 'H2' }; - -exports.public = secondheader; -exports.private = Object.assign({}, secondheader, { exclusive: true }); +module.exports = { type: 'line', tag: 'H2' }; diff --git a/lib/formats/small.js b/lib/formats/small.js index 8844be3..684849c 100644 --- a/lib/formats/small.js +++ b/lib/formats/small.js @@ -1,4 +1 @@ -var small = { tag: 'SMALL' }; - -exports.public = small; -exports.private = small; +module.exports = { tag: 'SMALL' }; diff --git a/lib/formats/strike.js b/lib/formats/strike.js index 8ead633..9b97fe0 100644 --- a/lib/formats/strike.js +++ b/lib/formats/strike.js @@ -1 +1 @@ -exports.public = exports.private = { tag: 'S' }; +module.exports = { tag: 'S' }; diff --git a/lib/formats/subscript.js b/lib/formats/subscript.js index 46f942f..1bc2ace 100644 --- a/lib/formats/subscript.js +++ b/lib/formats/subscript.js @@ -1 +1 @@ -exports.public = exports.private = { tag: 'SUB' }; +module.exports = { tag: 'SUB' }; diff --git a/lib/formats/superscript.js b/lib/formats/superscript.js index 0604803..48c2059 100644 --- a/lib/formats/superscript.js +++ b/lib/formats/superscript.js @@ -1 +1 @@ -exports.public = exports.private = { tag: 'SUP' }; +module.exports = { tag: 'SUP' }; diff --git a/lib/formats/thirdheader.js b/lib/formats/thirdheader.js index 89990db..dfe81ba 100644 --- a/lib/formats/thirdheader.js +++ b/lib/formats/thirdheader.js @@ -1,4 +1 @@ -var thirdheader = { type: 'line', tag: 'H3' }; - -exports.public = thirdheader; -exports.private = Object.assign({}, thirdheader, { exclusive: true }); +module.exports = { type: 'line', tag: 'H3' }; diff --git a/lib/formats/toh_project_details.js b/lib/formats/toh_project_details.js index 3c4cdd0..7323286 100644 --- a/lib/formats/toh_project_details.js +++ b/lib/formats/toh_project_details.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); @@ -17,5 +17,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('toh_project_details'); diff --git a/lib/formats/toh_tools.js b/lib/formats/toh_tools.js index 15f3b77..732bdf0 100644 --- a/lib/formats/toh_tools.js +++ b/lib/formats/toh_tools.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { dom(node.parentNode).switchTag('ASIDE'); @@ -20,5 +20,3 @@ exports.public = { return div; } }; - -exports.private = require('./object')('toh_tools'); diff --git a/lib/formats/video.js b/lib/formats/video.js index c7d5c0e..5a1eb51 100644 --- a/lib/formats/video.js +++ b/lib/formats/video.js @@ -1,4 +1,4 @@ -exports.public = { +module.exports = { add: function(node, value, dom) { var doc = node.ownerDocument; dom(node.parentNode).switchTag('div'); @@ -41,5 +41,3 @@ exports.public = { return frag; } }; - -exports.private = require('./object')('video'); From 625698a583dee6617a8c6cce3e64f7c8ab0f5bc6 Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Mon, 14 Sep 2020 16:54:20 -0400 Subject: [PATCH 2/8] delete all toInternalHtml methods --- browser.js | 5 ----- index.js | 5 ----- lib/export/to_internal_html.js | 9 --------- 3 files changed, 19 deletions(-) delete mode 100644 lib/export/to_internal_html.js diff --git a/browser.js b/browser.js index bd6b201..9f6f79c 100644 --- a/browser.js +++ b/browser.js @@ -1,6 +1,5 @@ var toHtml = require('./lib/export/to_html'); var toInlineHtml = require('./lib/export/to_inline_html'); -var toInternalHtml = require('./lib/export/to_internal_html'); var toPublicHtml = require('./lib/export/to_public_html'); var toPlaintext = require('./lib/export/to_plaintext'); @@ -13,10 +12,6 @@ module.exports = { options = Object.assign({}, options, { document: document }); return toInlineHtml(delta, formats, options); }, - toInternalHtml: function(delta, formats, options) { - options = Object.assign({}, options, { document: document }); - return toInternalHtml(delta, formats, options); - }, toPublicHtml: function(delta, formats, options) { options = Object.assign({}, options, { document: document }); return toPublicHtml(delta, formats, options); diff --git a/index.js b/index.js index b5759c9..4aedff5 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ var JSDOM = require('jsdom').JSDOM; var toHtml = require('./lib/export/to_html'); var toInlineHtml = require('./lib/export/to_inline_html'); -var toInternalHtml = require('./lib/export/to_internal_html'); var toPublicHtml = require('./lib/export/to_public_html'); var toPlaintext = require('./lib/export/to_plaintext'); @@ -14,10 +13,6 @@ module.exports = { options = Object.assign({}, options, { document: new JSDOM().window.document }); return toInlineHtml(delta, formats, options); }, - toInternalHtml: function(delta, formats, options) { - options = Object.assign({}, options, { document: new JSDOM().window.document }); - return toInternalHtml(delta, formats, options); - }, toPublicHtml: function(delta, formats, options) { options = Object.assign({}, options, { document: new JSDOM().window.document }); return toPublicHtml(delta, formats, options); diff --git a/lib/export/to_internal_html.js b/lib/export/to_internal_html.js deleted file mode 100644 index e60a4a5..0000000 --- a/lib/export/to_internal_html.js +++ /dev/null @@ -1,9 +0,0 @@ -var pick = require('lodash').pick; -var toHtml = require('./to_html'); -var internalFormats = require('../formats').internal; -var formatOptions = require('../formats').options; - -module.exports = function toInternalHtml(delta, formats, options) { - formats = formats ? pick(internalFormats, formats) : internalFormats; - return toHtml(delta, formats, Object.assign({}, formatOptions, options)); -}; From ba76b04d867161ae4c7254eca7ea6c6d49936138 Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Mon, 14 Sep 2020 17:03:53 -0400 Subject: [PATCH 3/8] a few public properties I missed --- lib/export/to_public_html.js | 2 +- lib/formats/autolink.js | 2 +- lib/formats/bullet.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/export/to_public_html.js b/lib/export/to_public_html.js index ad40e64..379a5f7 100644 --- a/lib/export/to_public_html.js +++ b/lib/export/to_public_html.js @@ -1,6 +1,6 @@ var pick = require('lodash').pick; var toHtml = require('./to_html'); -var publicFormats = require('../formats').public; +var publicFormats = require('../formats'); var formatOptions = require('../formats').options; module.exports = function toPublicHtml(delta, formats, options) { diff --git a/lib/formats/autolink.js b/lib/formats/autolink.js index 8fe1a21..0c1d24a 100644 --- a/lib/formats/autolink.js +++ b/lib/formats/autolink.js @@ -1,4 +1,4 @@ -var addLink = require('./link').public.add; +var addLink = require('./link').add; module.exports = { add: function(node, value, dom) { diff --git a/lib/formats/bullet.js b/lib/formats/bullet.js index 3d764e6..556ee4b 100644 --- a/lib/formats/bullet.js +++ b/lib/formats/bullet.js @@ -1 +1 @@ -exports.public = { type: 'line', parentTag: 'UL', tag: 'LI' }; +module.exports = { type: 'line', parentTag: 'UL', tag: 'LI' }; From ff5d274e47d1ebf828f59f9637d9790d9058d119 Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Tue, 15 Sep 2020 11:54:35 -0400 Subject: [PATCH 4/8] nix makeFormats funtion since we no longer need to filter for private or public formatting --- lib/formats/index.js | 92 +++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/lib/formats/index.js b/lib/formats/index.js index d5fb293..9b0283a 100644 --- a/lib/formats/index.js +++ b/lib/formats/index.js @@ -1,51 +1,47 @@ -function makeFormats() { - return { - bold: require('./bold'), - italic: require('./italic'), - mark: require('./mark'), - strike: require('./strike'), - superscript: require('./superscript'), - subscript: require('./subscript'), - firstheader: require('./firstheader'), - secondheader: require('./secondheader'), - thirdheader: require('./thirdheader'), - fourthheader: require('./fourthheader'), - fifthheader: require('./fifthheader'), - bullet: require('./bullet'), - list: require('./list'), - blockquote: require('./blockquote'), - link: require('./link'), - ins: require('./ins'), - del: require('./del'), - br: require('./br'), - autolink: require('./autolink'), - id: require('./id'), - position: require('./position'), - grouping: require('./grouping'), - dropcap: require('./dropcap'), - leadgraf: require('./leadgraf'), - endmark: require('./endmark'), - ad_placement: require('./ad_placement'), - image: require('./image'), - pullquote: require('./pullquote'), - oembed: require('./oembed'), - video: require('./video'), - hr: require('./hr'), - html: require('./html'), - doc: require('./doc'), - small: require('./small'), - actionbox: require('./actionbox'), - readmore: require('./readmore'), - ratingcard: require('./ratingcard'), - newsletter: require('./newsletter'), - credits: require('./credits'), - toh_project_details: require('./toh_project_details'), - toh_tools: require('./toh_tools'), - pym: require('./pym') - }; -} - -module.exports = makeFormats(); +module.exports = { + bold: require('./bold'), + italic: require('./italic'), + mark: require('./mark'), + strike: require('./strike'), + superscript: require('./superscript'), + subscript: require('./subscript'), + firstheader: require('./firstheader'), + secondheader: require('./secondheader'), + thirdheader: require('./thirdheader'), + fourthheader: require('./fourthheader'), + fifthheader: require('./fifthheader'), + bullet: require('./bullet'), + list: require('./list'), + blockquote: require('./blockquote'), + link: require('./link'), + ins: require('./ins'), + del: require('./del'), + br: require('./br'), + autolink: require('./autolink'), + id: require('./id'), + position: require('./position'), + grouping: require('./grouping'), + dropcap: require('./dropcap'), + leadgraf: require('./leadgraf'), + endmark: require('./endmark'), + ad_placement: require('./ad_placement'), + image: require('./image'), + pullquote: require('./pullquote'), + oembed: require('./oembed'), + video: require('./video'), + hr: require('./hr'), + html: require('./html'), + doc: require('./doc'), + small: require('./small'), + actionbox: require('./actionbox'), + readmore: require('./readmore'), + ratingcard: require('./ratingcard'), + newsletter: require('./newsletter'), + credits: require('./credits'), + toh_project_details: require('./toh_project_details'), + toh_tools: require('./toh_tools'), + pym: require('./pym') +}; exports.options = { blockTag: 'P', From e012e9117692f9299c3477360de0c0b25dce4d4d Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Tue, 15 Sep 2020 13:09:03 -0400 Subject: [PATCH 5/8] move formatOptions to its own separate file --- lib/export/to_public_html.js | 2 +- lib/formats/formatOptions.js | 56 +++++++++++++++++++++++++++++++++++ lib/formats/index.js | 57 ------------------------------------ 3 files changed, 57 insertions(+), 58 deletions(-) create mode 100644 lib/formats/formatOptions.js diff --git a/lib/export/to_public_html.js b/lib/export/to_public_html.js index 379a5f7..8d18bf5 100644 --- a/lib/export/to_public_html.js +++ b/lib/export/to_public_html.js @@ -1,7 +1,7 @@ var pick = require('lodash').pick; var toHtml = require('./to_html'); var publicFormats = require('../formats'); -var formatOptions = require('../formats').options; +var formatOptions = require('../formats/formatOptions'); module.exports = function toPublicHtml(delta, formats, options) { formats = formats ? pick(publicFormats, formats) : publicFormats; diff --git a/lib/formats/formatOptions.js b/lib/formats/formatOptions.js new file mode 100644 index 0000000..d0b9609 --- /dev/null +++ b/lib/formats/formatOptions.js @@ -0,0 +1,56 @@ +module.exports = { + blockTag: 'P', + formatOrder: [ + // inline: wrapper tag + 'bold', + 'italic', + 'mark', + 'small', + 'strike', + 'superscript', + 'subscript', + 'autolink', + 'link', // links come last so that they can merge sibling nodes + + // objects + 'actionbox', + 'credits', + 'doc', + 'hr', + 'html', + 'image', + 'oembed', + 'pullquote', + 'ratingcard', + 'newsletter', + 'readmore', + 'video', + 'toh_project_details', + 'toh_tools', + 'pym', + + // line: wrapper tag + 'position', + 'grouping', + 'blockquote', + + // line: wrapper tag + switch tag + 'bullet', + 'list', + + // line: switch tag + 'firstheader', + 'secondheader', + 'thirdheader', + 'fourthheader', + 'fifthheader', + + // line: add classes / attributes + 'dropcap', + 'leadgraf', + 'endmark', + 'ad_placement', + 'br', + 'id' + ] + }; diff --git a/lib/formats/index.js b/lib/formats/index.js index 9b0283a..2b3a87d 100644 --- a/lib/formats/index.js +++ b/lib/formats/index.js @@ -42,60 +42,3 @@ module.exports = { toh_tools: require('./toh_tools'), pym: require('./pym') }; - -exports.options = { - blockTag: 'P', - formatOrder: [ - // inline: wrapper tag - 'bold', - 'italic', - 'mark', - 'small', - 'strike', - 'superscript', - 'subscript', - 'autolink', - 'link', // links come last so that they can merge sibling nodes - - // objects - 'actionbox', - 'credits', - 'doc', - 'hr', - 'html', - 'image', - 'oembed', - 'pullquote', - 'ratingcard', - 'newsletter', - 'readmore', - 'video', - 'toh_project_details', - 'toh_tools', - 'pym', - - // line: wrapper tag - 'position', - 'grouping', - 'blockquote', - - // line: wrapper tag + switch tag - 'bullet', - 'list', - - // line: switch tag - 'firstheader', - 'secondheader', - 'thirdheader', - 'fourthheader', - 'fifthheader', - - // line: add classes / attributes - 'dropcap', - 'leadgraf', - 'endmark', - 'ad_placement', - 'br', - 'id' - ] -}; From 977559c711e0a287e18cb2c2eb86d9d2b5b0bb80 Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Tue, 15 Sep 2020 15:17:39 -0400 Subject: [PATCH 6/8] update package version and changelog --- README.md | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b1d7454..58c26d9 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ convert(delta, formats, { blockTag: 'FIGURE', inlineTag: 'INS' }); ## Changelog +- `6.0.0` Remove private formats and internal-specific outputs - `5.5.0` Add support for data params in doc component - `5.4.1` Update dev dependencies to address security vulnerabilities - `5.4.0` Update jsdom and lodash dependencies diff --git a/package.json b/package.json index c001f36..9804040 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "convert-rich-text", - "version": "5.5.0", + "version": "6.0.0", "description": "Convert an insert-only rich-text delta into HTML", "main": "index.js", "browser": "browser.js", From fb8a7a2da171415fec51ec60fd280e012acbf472 Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Tue, 22 Sep 2020 17:49:55 -0400 Subject: [PATCH 7/8] update changelog to be more concise, change filename to snake case format --- README.md | 2 +- lib/formats/formatOptions.js | 56 ----------------------------------- lib/formats/format_options.js | 56 +++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 57 deletions(-) delete mode 100644 lib/formats/formatOptions.js create mode 100644 lib/formats/format_options.js diff --git a/README.md b/README.md index 58c26d9..42b53c5 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ convert(delta, formats, { blockTag: 'FIGURE', inlineTag: 'INS' }); ## Changelog -- `6.0.0` Remove private formats and internal-specific outputs +- `6.0.0` Remove the `toInternalHtml` method. Also remove the private formats and internal-specific outputs that used to support `toInternalHtml`. - `5.5.0` Add support for data params in doc component - `5.4.1` Update dev dependencies to address security vulnerabilities - `5.4.0` Update jsdom and lodash dependencies diff --git a/lib/formats/formatOptions.js b/lib/formats/formatOptions.js deleted file mode 100644 index d0b9609..0000000 --- a/lib/formats/formatOptions.js +++ /dev/null @@ -1,56 +0,0 @@ -module.exports = { - blockTag: 'P', - formatOrder: [ - // inline: wrapper tag - 'bold', - 'italic', - 'mark', - 'small', - 'strike', - 'superscript', - 'subscript', - 'autolink', - 'link', // links come last so that they can merge sibling nodes - - // objects - 'actionbox', - 'credits', - 'doc', - 'hr', - 'html', - 'image', - 'oembed', - 'pullquote', - 'ratingcard', - 'newsletter', - 'readmore', - 'video', - 'toh_project_details', - 'toh_tools', - 'pym', - - // line: wrapper tag - 'position', - 'grouping', - 'blockquote', - - // line: wrapper tag + switch tag - 'bullet', - 'list', - - // line: switch tag - 'firstheader', - 'secondheader', - 'thirdheader', - 'fourthheader', - 'fifthheader', - - // line: add classes / attributes - 'dropcap', - 'leadgraf', - 'endmark', - 'ad_placement', - 'br', - 'id' - ] - }; diff --git a/lib/formats/format_options.js b/lib/formats/format_options.js new file mode 100644 index 0000000..9feeec8 --- /dev/null +++ b/lib/formats/format_options.js @@ -0,0 +1,56 @@ +module.exports = { + blockTag: 'P', + formatOrder: [ + // inline: wrapper tag + 'bold', + 'italic', + 'mark', + 'small', + 'strike', + 'superscript', + 'subscript', + 'autolink', + 'link', // links come last so that they can merge sibling nodes + + // objects + 'actionbox', + 'credits', + 'doc', + 'hr', + 'html', + 'image', + 'oembed', + 'pullquote', + 'ratingcard', + 'newsletter', + 'readmore', + 'video', + 'toh_project_details', + 'toh_tools', + 'pym', + + // line: wrapper tag + 'position', + 'grouping', + 'blockquote', + + // line: wrapper tag + switch tag + 'bullet', + 'list', + + // line: switch tag + 'firstheader', + 'secondheader', + 'thirdheader', + 'fourthheader', + 'fifthheader', + + // line: add classes / attributes + 'dropcap', + 'leadgraf', + 'endmark', + 'ad_placement', + 'br', + 'id' + ] +}; From 81b97b13d27a59cde8518a0b8393606e6391a0bd Mon Sep 17 00:00:00 2001 From: Michele Cynowicz Date: Tue, 22 Sep 2020 17:56:15 -0400 Subject: [PATCH 8/8] one import reference I forogt to update --- lib/export/to_public_html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/export/to_public_html.js b/lib/export/to_public_html.js index 8d18bf5..6ba39cf 100644 --- a/lib/export/to_public_html.js +++ b/lib/export/to_public_html.js @@ -1,7 +1,7 @@ var pick = require('lodash').pick; var toHtml = require('./to_html'); var publicFormats = require('../formats'); -var formatOptions = require('../formats/formatOptions'); +var formatOptions = require('../formats/format_options'); module.exports = function toPublicHtml(delta, formats, options) { formats = formats ? pick(publicFormats, formats) : publicFormats;