diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a900a9d..682cf97 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - node-version: ["12.x"] + node-version: ["16.x"] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 42b53c5..413efe3 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ convert(delta, formats, { blockTag: 'FIGURE', inlineTag: 'INS' }); ## Changelog +- `6.1.0` Annotate autolink links with data attribute - `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 diff --git a/lib/formats/autolink.js b/lib/formats/autolink.js index 0c1d24a..3d8f546 100644 --- a/lib/formats/autolink.js +++ b/lib/formats/autolink.js @@ -4,6 +4,10 @@ module.exports = { add: function(node, value, dom) { if (!value.disabled) { node = addLink(node, value.href, dom); + + if (value.source) { + node.dataset.source = value.source; + } } return node; diff --git a/package.json b/package.json index 5a6203b..efd8c65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "convert-rich-text", - "version": "6.0.1", + "version": "6.1.0", "description": "Convert an insert-only rich-text delta into HTML", "main": "index.js", "browser": "browser.js", diff --git a/test/server/to_public_html.js b/test/server/to_public_html.js index c7b2263..32b40ee 100644 --- a/test/server/to_public_html.js +++ b/test/server/to_public_html.js @@ -96,11 +96,21 @@ describe('to_public_html', function() { { insert: 'Star Wars', attributes: { autolink: { id: 1, href: 'http://starwars.com/', disabled: false } } }, { insert: ' but ' }, { insert: 'Star Trek', attributes: { autolink: { id: 2, href: 'http://startrek.com/', disabled: true } } }, - { insert: ' is just okay!' } + { insert: ' is just ' }, + { insert: 'okay!', attributes: { autolink: { id: 3, href: 'http://okay.com/', disabled: true, source: 'name-of-backlinker' } } } ] }, html: '

I like Star Wars but Star Trek is just okay!

' }, + { + message: 'renders autolink source data attribute', + delta: { ops: [ + { insert: 'Vox Media', attributes: { autolink: { id: 1, href: 'http://product.voxmedia.com/', disabled: false, source: 'name-of-backlinker' } } }, + { insert: ' is a pretty great place.' } + ] }, + html: + '

Vox Media is a pretty great place.

' + }, { message: 'converts to
tags', delta: { ops: [