Skip to content

Commit

Permalink
fix: set target _blank for links
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Dec 10, 2020
1 parent e9d6909 commit 400c636
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ See [CONTRIBUTING.md](./.github/CONTRIBUTING.md) to get started.
[npm]: https://www.npmjs.com/
[yarn]: https://yarnpkg.com/lang/en/
[github]: https://sibiraj-s.github.io/
[documentation]: https://sibiraj.dev/ngx-editor/
[documentation]: https://sibiraj.dev/ngx-editor/
[wiki]: https://github.com/sibiraj-s/ngx-editor/wiki/ngxEditor
6 changes: 3 additions & 3 deletions demo/src/app/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export default {
type: 'link',
attrs: {
href: 'https://codemirror.net',
title: 'CodeMirror',
default: '_blank'
title: 'https://codemirror.net',
target: '_blank'
}
}
],
Expand All @@ -131,7 +131,7 @@ export default {
attrs: {
href: 'https://en.wikipedia.org',
title: '',
default: '_blank'
target: '_blank'
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/bubble/bubble.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ng-container *ngIf="activeLinkItem">
<a [href]="activeLinkItem.attrs.href" [target]="(activeLinkItem.attrs.target)" [title]="activeLinkItem.attrs.href">
<a [href]="activeLinkItem.attrs.href" target="_blank" [title]="activeLinkItem.attrs.href">
{{activeLinkItem.attrs.href}}
</a>
<div class="commands">
Expand Down
2 changes: 1 addition & 1 deletion src/lib/modules/menu/link/link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class LinkComponent implements OnDestroy {
const { selection } = state;

const attrs = {
title: text,
title: href,
href,
target: openInNewTab ? '_blank' : '_self'
};
Expand Down
9 changes: 5 additions & 4 deletions src/lib/schema/marks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const link: MarkSpec = {
attrs: {
href: {},
title: { default: null },
default: { default: '_blank' }
target: { default: '_blank' }
},
inclusive: false,
parseDOM: [
Expand All @@ -18,13 +18,14 @@ const link: MarkSpec = {
getAttrs(dom: HTMLElement): GetAttrsSpec {
return {
href: dom.getAttribute('href'),
title: dom.getAttribute('title')
title: dom.getAttribute('title'),
target: dom.getAttribute('target'),
};
}
}],
toDOM(node): DOMOutputSpec {
const { href, title } = node.attrs;
return ['a', { href, title }, 0];
const { href, title, target } = node.attrs;
return ['a', { href, title, target }, 0];
}
};

Expand Down

0 comments on commit 400c636

Please sign in to comment.