Automatically hyperlink links in WYSIWYG editors

This commit is contained in:
Garrett Mills 2020-11-09 12:03:53 -06:00
parent a9dd16cc64
commit 042494128a
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
2 changed files with 5 additions and 1 deletions

View File

@ -78,6 +78,6 @@
<div
class="editable-base"
*ngIf="!isFocused"
[innerHTML]="initialValue"
[innerHTML]="displayContents"
></div>
</div>

View File

@ -19,6 +19,10 @@ export class NormComponent extends EditorNodeContract implements OnInit {
private dirtyOverride = false;
protected hadOneFocusOut = false;
public get displayContents() {
return this.contents.replace(/</g, '\n<').replace(/(https?:\/\/[^\s]+)/g, (val) => `<a href="${val}" target="_blank">${val}</a>`);
}
constructor(
public editorService: EditorService,
) {