From 400c63638c81c8f95acc83c167a166e4878f70ec Mon Sep 17 00:00:00 2001 From: sibiraj-s Date: Thu, 10 Dec 2020 11:07:31 +0530 Subject: [PATCH] fix: set target _blank for links --- README.md | 2 +- demo/src/app/doc.ts | 6 +++--- src/lib/components/bubble/bubble.component.html | 2 +- src/lib/modules/menu/link/link.component.ts | 2 +- src/lib/schema/marks.ts | 9 +++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f01d5626..716aff15 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/demo/src/app/doc.ts b/demo/src/app/doc.ts index 054bce32..6d9be841 100644 --- a/demo/src/app/doc.ts +++ b/demo/src/app/doc.ts @@ -112,8 +112,8 @@ export default { type: 'link', attrs: { href: 'https://codemirror.net', - title: 'CodeMirror', - default: '_blank' + title: 'https://codemirror.net', + target: '_blank' } } ], @@ -131,7 +131,7 @@ export default { attrs: { href: 'https://en.wikipedia.org', title: '', - default: '_blank' + target: '_blank' } } ], diff --git a/src/lib/components/bubble/bubble.component.html b/src/lib/components/bubble/bubble.component.html index 6fcf8ccf..72586a9a 100644 --- a/src/lib/components/bubble/bubble.component.html +++ b/src/lib/components/bubble/bubble.component.html @@ -1,5 +1,5 @@ - + {{activeLinkItem.attrs.href}}
diff --git a/src/lib/modules/menu/link/link.component.ts b/src/lib/modules/menu/link/link.component.ts index 17dfd0dd..59807adc 100644 --- a/src/lib/modules/menu/link/link.component.ts +++ b/src/lib/modules/menu/link/link.component.ts @@ -126,7 +126,7 @@ export class LinkComponent implements OnDestroy { const { selection } = state; const attrs = { - title: text, + title: href, href, target: openInNewTab ? '_blank' : '_self' }; diff --git a/src/lib/schema/marks.ts b/src/lib/schema/marks.ts index c920bf33..1219aba7 100644 --- a/src/lib/schema/marks.ts +++ b/src/lib/schema/marks.ts @@ -9,7 +9,7 @@ const link: MarkSpec = { attrs: { href: {}, title: { default: null }, - default: { default: '_blank' } + target: { default: '_blank' } }, inclusive: false, parseDOM: [ @@ -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]; } };