Skip to content

Commit

Permalink
Merge pull request #51 from voxmedia/ls-autolink-data-attr
Browse files Browse the repository at this point in the history
Add data attribute for autolink source
  • Loading branch information
lsirivong authored May 1, 2023
2 parents b1f1c22 + 15a66c9 commit 7ac96c2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: ["12.x"]
node-version: ["16.x"]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/formats/autolink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 11 additions & 1 deletion test/server/to_public_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
'<p>I like <a href="http://starwars.com/">Star Wars</a> but Star Trek is just okay!</p>'
},
{
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:
'<p><a href="http://product.voxmedia.com/" data-source="name-of-backlinker">Vox Media</a> is a pretty great place.</p>'
},
{
message: 'converts to <br> tags',
delta: { ops: [
Expand Down

0 comments on commit 7ac96c2

Please sign in to comment.