Skip to content

Commit

Permalink
Updated urlTransformMap to handle nested objects (#1376)
Browse files Browse the repository at this point in the history
* Updated urlTransformMap to handle nested objects
  • Loading branch information
vershwal authored Sep 5, 2024
1 parent 21bf5f1 commit d8577b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion packages/kg-default-nodes/lib/generate-decorator-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ export function generateDecoratorNode({nodeType, properties = [], version = 1})

properties.forEach((prop) => {
if (prop.urlType) {
map[prop.name] = prop.urlType;
if (prop.urlPath) {
map[prop.urlPath] = prop.urlType;
} else {
map[prop.name] = prop.urlType;
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions packages/kg-default-nodes/lib/nodes/bookmark/BookmarkNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class BookmarkNode extends generateDecoratorNode({nodeType: 'bookmark',
{name: 'caption', default: '', wordCount: true},
{name: 'author', default: ''},
{name: 'publisher', default: ''},
{name: 'icon', default: '', urlType: 'url'},
{name: 'thumbnail', default: '', urlType: 'url'}
{name: 'icon', urlPath: 'metadata.icon', default: '', urlType: 'url'},
{name: 'thumbnail', urlPath: 'metadata.thumbnail', default: '', urlType: 'url'}
]}
) {
static importDOM() {
Expand Down
12 changes: 6 additions & 6 deletions packages/kg-default-nodes/test/nodes/bookmark.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ describe('BookmarkNode', function () {
describe('urlTransformMap', function () {
it('contains the expected URL mapping', editorTest(function () {
BookmarkNode.urlTransformMap.should.deepEqual({
url: 'url',
icon: 'url',
thumbnail: 'url'
'url': 'url',
'metadata.icon': 'url',
'metadata.thumbnail': 'url'
});
}));
});
Expand Down Expand Up @@ -277,9 +277,9 @@ describe('BookmarkNode', function () {

it('urlTransformMap', editorTest(function () {
BookmarkNode.urlTransformMap.should.deepEqual({
url: 'url',
icon: 'url',
thumbnail: 'url'
'url': 'url',
'metadata.icon': 'url',
'metadata.thumbnail': 'url'
});
}));
});
Expand Down

0 comments on commit d8577b0

Please sign in to comment.