Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular support for nimble-rich-text-editor #1450

Merged
merged 180 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 156 commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
ca4ccec
Initial pass for editor component. This is a intermediate commit and …
vivinkrishna-ni Jul 6, 2023
6e15794
Overrides semver version to be >=7.5.2
AagashRaaj Jul 7, 2023
a163b55
Removed the tiptap packages
vivinkrishna-ni Jul 11, 2023
6df5ef1
Reverted the package-lock.json to main branch changes
vivinkrishna-ni Jul 11, 2023
38be4dd
Added tiptap packages and necessary packages for tiptap
vivinkrishna-ni Jul 11, 2023
b159f86
Component and angular skeleton code bring up for rich-text-editor
vivinkrishna-ni Jul 11, 2023
37e1062
Merge branch 'users/vivin/initial-code-for-rich-text-editor' into use…
vivinkrishna-ni Jul 11, 2023
0d1de1a
Resolved linting errors
vivinkrishna-ni Jul 11, 2023
91362df
Merge branch 'users/vivin/initial-code-for-rich-text-editor' into use…
vivinkrishna-ni Jul 11, 2023
70a5c2d
Removed angular code from this branch and will be added as separate PR
vivinkrishna-ni Jul 11, 2023
0a68e83
Removed constant file file for rich-text-content
vivinkrishna-ni Jul 11, 2023
6bdd0d7
Change files
vivinkrishna-ni Jul 11, 2023
5851a8b
Merge branch 'users/vivin/initial-code-for-rich-text-editor' into use…
vivinkrishna-ni Jul 11, 2023
391ecbc
Updated the description for editor storybook
vivinkrishna-ni Jul 11, 2023
288aa3e
Merge branch 'users/vivin/initial-code-for-rich-text-editor' into use…
vivinkrishna-ni Jul 11, 2023
43330c2
Merge branch 'main' into users/vivin/initial-code-for-rich-text-editor
vivinkrishna-ni Jul 13, 2023
f21a11e
Merge branch 'users/vivin/initial-code-for-rich-text-editor' into use…
vivinkrishna-ni Jul 13, 2023
4c94bd4
Initial bring up of titptap editor with basic template enabled
vivinkrishna-ni Jul 14, 2023
6cc6209
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Jul 18, 2023
560ecd5
Intermediate commit to add functionalities to the buttons and modifie…
vivinkrishna-ni Jul 19, 2023
a32ade0
Added placeholder and link extensions
vivinkrishna-ni Jul 20, 2023
dc8152d
Added placeholder support rich-text-editor
vivinkrishna-ni Jul 20, 2023
00571c1
Updates on the link configurations
vivinkrishna-ni Jul 21, 2023
0468ba5
Intermediate changes for maxlength and disabled state
vivinkrishna-ni Jul 25, 2023
9ec89cf
Updated for footer hidden attribute
vivinkrishna-ni Jul 26, 2023
d56355b
Added some additional APIs to this branch, might be removed and split…
vivinkrishna-ni Jul 31, 2023
33cb3c7
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Jul 31, 2023
efe79e0
Update package lock json
vivinkrishna-ni Jul 31, 2023
ca2bf70
Changes with only basic editor and footer actions
vivinkrishna-ni Jul 31, 2023
1c39203
Updated few code changes to re-confirm pipeline passes
vivinkrishna-ni Aug 1, 2023
390df6a
Removed markdown-it from dev dependency
vivinkrishna-ni Aug 1, 2023
92ddd09
Updated test case, style and implementation to integrate tiptap edito…
vivinkrishna-ni Aug 2, 2023
e0e20eb
Update desc in change file and formatting in template
vivinkrishna-ni Aug 3, 2023
3df5015
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 3, 2023
fe4b926
resolve linting errors
vivinkrishna-ni Aug 3, 2023
bd29abb
Changed the name of the private function and minor style change
vivinkrishna-ni Aug 3, 2023
15b3fa4
Added model class for editor button events
vivinkrishna-ni Aug 3, 2023
9dc2e1a
returning void for base class methods
vivinkrishna-ni Aug 3, 2023
e67d478
resolve linting errors
vivinkrishna-ni Aug 3, 2023
40633b8
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 4, 2023
4d3e099
Resolved PR comments
vivinkrishna-ni Aug 7, 2023
ad024ef
Added internal comment for public variables
vivinkrishna-ni Aug 7, 2023
bbe0c26
Resolve PR comments
vivinkrishna-ni Aug 7, 2023
6dddc0a
Update minor function name change
vivinkrishna-ni Aug 7, 2023
94cafd0
resolve linting errors
vivinkrishna-ni Aug 7, 2023
c1a0ca8
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 8, 2023
0b16f24
Updated package-lock.json
vivinkrishna-ni Aug 9, 2023
9eb96e3
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 9, 2023
21abec6
Resolving PR comments
vivinkrishna-ni Aug 9, 2023
efa3f1e
Updated the name for button properties and resolve linting errors
vivinkrishna-ni Aug 9, 2023
101ebb5
Added test cases for aria attributes
vivinkrishna-ni Aug 9, 2023
2602635
Removed fdescribe
vivinkrishna-ni Aug 9, 2023
393f42b
Added comments to specify the return value for key handler
vivinkrishna-ni Aug 9, 2023
462d929
added readonly for base class properties
vivinkrishna-ni Aug 9, 2023
8e33326
Removed model classes and moved it to a template file
vivinkrishna-ni Aug 10, 2023
eeaec8e
Add setMarkdown and getmarkdown method in rich-text-editor
AagashRaaj Aug 10, 2023
2755e60
Added labels for each buttons
vivinkrishna-ni Aug 10, 2023
0a8955d
Update story book
AagashRaaj Aug 10, 2023
c4db560
Fix lint
AagashRaaj Aug 10, 2023
924fd8b
Minor fix
AagashRaaj Aug 10, 2023
bfb5c23
safari workaround
AagashRaaj Aug 10, 2023
d0bfce2
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 11, 2023
367491e
Resolving PR comments
vivinkrishna-ni Aug 11, 2023
2b01fff
Minor code changes
vivinkrishna-ni Aug 11, 2023
1ece855
Updated comment in the code
vivinkrishna-ni Aug 11, 2023
54cfba0
updated the comment in the styles
vivinkrishna-ni Aug 11, 2023
65bd029
resolve linting errors
vivinkrishna-ni Aug 11, 2023
ba0f36b
Address PR Comments
AagashRaaj Aug 11, 2023
04db1a8
Added test cases for the change event propagation and part for footer…
vivinkrishna-ni Aug 11, 2023
d8c239e
Minor correction in the comment added
vivinkrishna-ni Aug 11, 2023
2497365
Remove focus on setMarkdown()
AagashRaaj Aug 11, 2023
5dc0216
Merge branch 'users/vivin/integrate-tiptap-editor' of https://github.…
AagashRaaj Aug 11, 2023
9d21139
Added test cases for nested lists in editor and viewer
vivinkrishna-ni Aug 14, 2023
fc592a3
Removed skipping escape func while serializing
AagashRaaj Aug 14, 2023
7c5c95e
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 14, 2023
47e92d7
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 14, 2023
9f27b34
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 14, 2023
cd43757
Minor test case name update
vivinkrishna-ni Aug 15, 2023
1daf767
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 15, 2023
84e56dc
Address PR comments
AagashRaaj Aug 16, 2023
748c780
Remove types.ts file
AagashRaaj Aug 16, 2023
b845367
Fix linting
AagashRaaj Aug 16, 2023
aa4045c
Refactored page object and updated the test cases accordingly
vivinkrishna-ni Aug 16, 2023
567fd0c
Updated the nested list test cases in viewer component
vivinkrishna-ni Aug 16, 2023
ef70cda
Resolving PR comments
vivinkrishna-ni Aug 17, 2023
dfb9cd8
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 17, 2023
f211efc
Updated the default height of the container for sizing tests
vivinkrishna-ni Aug 17, 2023
afe3cdf
Merge branch 'users/vivin/integrate-tiptap-editor' of https://github.…
vivinkrishna-ni Aug 17, 2023
c49bcba
Address PR comments
AagashRaaj Aug 17, 2023
c3e7f8f
Minor fix
AagashRaaj Aug 17, 2023
f6188f2
Fix lint
AagashRaaj Aug 17, 2023
12dd3f0
Merge branch 'users/vivin/integrate-tiptap-editor' of https://github.…
AagashRaaj Aug 17, 2023
9f5b675
Updated the aria-multiline value by using setAttribute
vivinkrishna-ni Aug 18, 2023
43f52ac
Typo correction for aria-multiline attribute
vivinkrishna-ni Aug 18, 2023
31cac04
Added titles for buttons and moved enum to a type file
vivinkrishna-ni Aug 18, 2023
8db2b7f
Added spec file for types
vivinkrishna-ni Aug 18, 2023
0b58903
Merge branch 'main' into users/vivin/integrate-tiptap-editor
vivinkrishna-ni Aug 18, 2023
afe4eca
Merge branch 'users/vivin/integrate-tiptap-editor' into users/aagash/…
vivinkrishna-ni Aug 18, 2023
fe8de41
Merge branch 'users/aagash/markdown-parser-serializer-editor' of http…
vivinkrishna-ni Aug 18, 2023
da25204
Merge branch 'main' into users/aagash/markdown-parser-serializer-editor
vivinkrishna-ni Aug 18, 2023
9d32990
Removed change file
vivinkrishna-ni Aug 18, 2023
60ee9c7
Merge branch 'users/aagash/markdown-parser-serializer-editor' of http…
vivinkrishna-ni Aug 18, 2023
0823fe3
Fix linting
vivinkrishna-ni Aug 18, 2023
14bb516
Passed enum types to the methods in page objects instead of number type
vivinkrishna-ni Aug 18, 2023
d1b0955
Change files
jattasNI Aug 18, 2023
bfa0f2e
typo
jattasNI Aug 18, 2023
7252c97
Update Comments
AagashRaaj Aug 21, 2023
33611bd
Merge branch 'main' into users/aagash/markdown-parser-serializer-editor
vivinkrishna-ni Aug 21, 2023
e6f7e12
Additional APIs for rich text editor
vivinkrishna-ni Aug 21, 2023
8460c85
Add testcase for editor Before DOM Connection
AagashRaaj Aug 21, 2023
e9a4548
Minor renaming
AagashRaaj Aug 21, 2023
65a4b96
Check getMarkdown() before dom initialization
AagashRaaj Aug 21, 2023
1742dfb
Test case update due to the version update and placeholder code change
vivinkrishna-ni Aug 22, 2023
3efae7c
Merge branch 'users/aagash/markdown-parser-serializer-editor' into us…
vivinkrishna-ni Aug 22, 2023
61391b5
Removed waitForUpdatesAsync from the disabled API test cases
vivinkrishna-ni Aug 22, 2023
3544c6b
angular integration get and set markdown
AagashRaaj Aug 22, 2023
5fece27
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 22, 2023
0570cc4
Resolve commit for initial PR comments
vivinkrishna-ni Aug 22, 2023
9481f5d
Change files
vivinkrishna-ni Aug 22, 2023
82b4853
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 22, 2023
a6fd7f0
Removed aria-disabled for toggle buttons
vivinkrishna-ni Aug 22, 2023
5edc8bd
Merge branch 'users/vivin/editor-ui-api' of https://github.com/ni/nim…
vivinkrishna-ni Aug 22, 2023
b04b9ac
Resolving the comments
vivinkrishna-ni Aug 23, 2023
8008934
Minor changes in the code comments and in height
vivinkrishna-ni Aug 23, 2023
3fed861
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 23, 2023
0e9bd3b
Minor style changes related to footer-hidden attribute
vivinkrishna-ni Aug 23, 2023
031d672
Fixing the test case for footer hidden attribute
vivinkrishna-ni Aug 23, 2023
a87f199
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 23, 2023
33778eb
Typo correction in the empty property comment in the code
vivinkrishna-ni Aug 23, 2023
b058f59
Support for angular directive
vivinkrishna-ni Aug 23, 2023
6df4347
Updated placeholder test case
vivinkrishna-ni Aug 23, 2023
c1ee56b
Change files
vivinkrishna-ni Aug 23, 2023
86df7f0
Removed unused styles and rearranged directive methods
vivinkrishna-ni Aug 24, 2023
83ba6f8
Minor update in the spec
vivinkrishna-ni Aug 24, 2023
ab09e13
Removed setting visibility in footer section
vivinkrishna-ni Aug 24, 2023
491afbc
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 24, 2023
f048ad6
Resolving PR comments
vivinkrishna-ni Aug 24, 2023
8dea1af
Removed setting markdown in the client app
vivinkrishna-ni Aug 24, 2023
965a891
Removed unnecessary imports in the client component
vivinkrishna-ni Aug 24, 2023
d7cc526
Added slot button
vivinkrishna-ni Aug 24, 2023
781d97a
Removed slot button
vivinkrishna-ni Aug 24, 2023
7c7b622
Updated the example app by adding slot button and set markdown content
vivinkrishna-ni Aug 25, 2023
fa1c8ba
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 25, 2023
1d588a7
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 25, 2023
bf68596
Resolve merge conflicts
vivinkrishna-ni Aug 25, 2023
007365b
Resolve PR comments
vivinkrishna-ni Aug 26, 2023
b398040
Resolving PR comments for fit to content related changes
vivinkrishna-ni Aug 28, 2023
e1c1c53
Added test case to test input event is not firing when setting throug…
vivinkrishna-ni Aug 28, 2023
8919ed5
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 28, 2023
4b3ffc9
fix minor errors
vivinkrishna-ni Aug 28, 2023
78e578c
Merge branch 'users/vivin/editor-ui-api' of https://github.com/ni/nim…
vivinkrishna-ni Aug 28, 2023
56f6fbf
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 28, 2023
b3e5d6a
Resolve comments for aria-label
vivinkrishna-ni Aug 29, 2023
2c4fbae
Merge branch 'users/vivin/editor-ui-api' of https://github.com/ni/nim…
vivinkrishna-ni Aug 29, 2023
40ffe0a
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 29, 2023
3664aea
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 29, 2023
513be08
Merge branch 'users/vivin/editor-angular-integration' of https://gith…
vivinkrishna-ni Aug 29, 2023
8367ee2
Added entry points for page object files in editor and viewer
vivinkrishna-ni Aug 29, 2023
4132b06
resolving PR comments
vivinkrishna-ni Aug 29, 2023
3518bcf
Exports the toolbar button type for the editor page object
vivinkrishna-ni Aug 29, 2023
4884a84
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 29, 2023
9a12f91
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 29, 2023
4ebbdba
Resolving PR comments without the changes for fit to content
vivinkrishna-ni Aug 30, 2023
4d0e8a2
Merge branch 'users/vivin/editor-ui-api' of https://github.com/ni/nim…
vivinkrishna-ni Aug 30, 2023
255557d
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 30, 2023
48c0cfd
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 30, 2023
883efdc
Updated the placeholder to be string or undefined as it is updated in…
vivinkrishna-ni Aug 30, 2023
e754931
Removed all fit to content related changes and planning to move it to…
vivinkrishna-ni Aug 30, 2023
0c0094c
Updated the comment for the placeholder class.
vivinkrishna-ni Aug 30, 2023
235427b
Showing the error icon only after the width calculated.
vivinkrishna-ni Aug 30, 2023
e679b67
Fix lint errors
vivinkrishna-ni Aug 30, 2023
63b3f78
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 30, 2023
5200508
Removed fit-to-content attribute as it is removed from the component PR
vivinkrishna-ni Aug 30, 2023
5083656
Updated scrollbar-width-calculated to a class instead of attribute
vivinkrishna-ni Aug 31, 2023
487d95c
Updated scrollbar width calculation as a class and not an attribute
vivinkrishna-ni Aug 31, 2023
f1b8e07
Merge branch 'main' into users/vivin/editor-ui-api
vivinkrishna-ni Aug 31, 2023
6886863
Merge branch 'users/vivin/editor-ui-api' into users/vivin/editor-angu…
vivinkrishna-ni Aug 31, 2023
37a24ea
Merge branch 'users/vivin/editor-angular-integration' of https://gith…
vivinkrishna-ni Aug 31, 2023
84e8fa8
Merge branch 'main' into users/vivin/editor-angular-integration
vivinkrishna-ni Aug 31, 2023
4ca3caa
Merge branch 'main' into users/vivin/editor-angular-integration
vivinkrishna-ni Aug 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { NimbleTableColumnDateTextModule } from '@ni/nimble-angular/table-column
import { NimbleTableColumnEnumTextModule } from '@ni/nimble-angular/table-column/enum-text';
import { NimbleTableColumnIconModule } from '@ni/nimble-angular/table-column/icon';
import { NimbleRichTextViewerModule } from '@ni/nimble-angular/rich-text-viewer';
import { NimbleRichTextEditorModule } from '@ni/nimble-angular/rich-text-editor';
import { AppComponent } from './app.component';
import { CustomAppComponent } from './customapp/customapp.component';
import { HeaderComponent } from './header/header.component';
Expand Down Expand Up @@ -84,6 +85,7 @@ import { HeaderComponent } from './header/header.component';
NimbleMappingTextModule,
NimbleBannerModule,
NimbleRichTextViewerModule,
NimbleRichTextEditorModule,
NimbleTableColumnIconModule,
NimbleMappingIconModule,
NimbleMappingSpinnerModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,18 @@
<nimble-list-option *ngFor="let item of comboboxItems" [ngValue]="item">{{ item ? item.first : '' }}</nimble-list-option>
</nimble-combobox>
</div>
<div class="sub-container">
<div class="container-label">Rich Text Editor</div>
<div class="rich-text-editor-container">
<nimble-rich-text-editor placeholder="Rich text editor" #editor>
<nimble-button slot="footer-actions" (click)="loadRichTextEditorContent()">Load Content</nimble-button>
</nimble-rich-text-editor>
</div>
</div>
<div class="sub-container">
<div class="container-label">Rich Text Viewer</div>
<div class="rich-text-viewer-container">
<nimble-rich-text-viewer [markdown]="markdownString"></nimble-rich-text-viewer>
<nimble-rich-text-viewer [markdown]="viewerMarkdownString"></nimble-rich-text-viewer>
</div>
</div>
<div class="sub-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ nimble-table {
padding: $ni-nimble-small-padding;
width: 350px;
}

.rich-text-editor-container {
padding: $ni-nimble-small-padding;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Component, Inject, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { DrawerLocation, MenuItem, NimbleDialogDirective, NimbleDrawerDirective, OptionNotFound, OPTION_NOT_FOUND, UserDismissed } from '@ni/nimble-angular';
import type { TableRecord } from '@ni/nimble-angular/table';
import { NimbleRichTextEditorDirective } from '@ni/nimble-angular/rich-text-editor';
import { BehaviorSubject, Observable } from 'rxjs';

interface ComboboxItem {
Expand Down Expand Up @@ -44,7 +45,7 @@ export class CustomAppComponent {
public selectedRadio = 'mango';
public activeTabId = 'tab-1';
public activeAnchorTabId = 'a-tab-2';
public markdownString = `Supported rich text formatting options:
public viewerMarkdownString = `Supported rich text formatting options:
1. **Bold**
2. *Italics*
3. Numbered lists
Expand All @@ -56,11 +57,23 @@ export class CustomAppComponent {
5. Absolute link: <https://nimble.ni.dev/>
`;

public editorMarkdownString = `Supported rich text formatting options:
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
1. **Bold**
2. *Italics*
3. Numbered lists
1. Option 1
2. Option 2
4. Bulleted lists
* Option 1
* Option 2
`;

public readonly tableData$: Observable<SimpleTableRecord[]>;
private readonly tableDataSubject = new BehaviorSubject<SimpleTableRecord[]>([]);

@ViewChild('dialog', { read: NimbleDialogDirective }) private readonly dialog: NimbleDialogDirective<string>;
@ViewChild('drawer', { read: NimbleDrawerDirective }) private readonly drawer: NimbleDrawerDirective<string>;
@ViewChild('editor', { read: NimbleRichTextEditorDirective }) private readonly editor: NimbleRichTextEditorDirective;

public constructor(@Inject(ActivatedRoute) public readonly route: ActivatedRoute) {
this.tableData$ = this.tableDataSubject.asObservable();
Expand Down Expand Up @@ -115,4 +128,8 @@ export class CustomAppComponent {
});
this.tableDataSubject.next(tableData);
}

public loadRichTextEditorContent(): void {
this.editor.setMarkdown(this.editorMarkdownString);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "../../../../../node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "public-api.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Directive, ElementRef, EventEmitter, HostListener, Input, Output, Renderer2 } from '@angular/core';
import type { RichTextEditor } from '@ni/nimble-components/dist/esm/rich-text-editor';
import { BooleanValueOrAttribute, toBooleanProperty } from '@ni/nimble-angular/internal-utilities';

export type { RichTextEditor };

/**
* Directive to provide Angular integration for the rich text editor element.
*/
@Directive({
selector: 'nimble-rich-text-editor'
})

export class NimbleRichTextEditorDirective {
@Output() public inputEvent = new EventEmitter<boolean>();

public get disabled(): boolean {
return this.elementRef.nativeElement.disabled;
}

@Input() public set disabled(value: BooleanValueOrAttribute) {
this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', toBooleanProperty(value));
}

public get footerHidden(): boolean {
return this.elementRef.nativeElement.footerHidden;
}

// Renaming because property should have camel casing, but attribute should not
// eslint-disable-next-line @angular-eslint/no-input-rename
@Input('footer-hidden') public set footerHidden(value: BooleanValueOrAttribute) {
this.renderer.setProperty(this.elementRef.nativeElement, 'footerHidden', toBooleanProperty(value));
}

public get fitToContent(): boolean {
return this.elementRef.nativeElement.fitToContent;
}

// Renaming because property should have camel casing, but attribute should not
// eslint-disable-next-line @angular-eslint/no-input-rename
@Input('fit-to-content') public set fitToContent(value: BooleanValueOrAttribute) {
this.renderer.setProperty(this.elementRef.nativeElement, 'fitToContent', toBooleanProperty(value));
}

public get errorVisible(): boolean {
return this.elementRef.nativeElement.errorVisible;
}

// Renaming because property should have camel casing, but attribute should not
// eslint-disable-next-line @angular-eslint/no-input-rename
@Input('error-visible') public set errorVisible(value: BooleanValueOrAttribute) {
this.renderer.setProperty(this.elementRef.nativeElement, 'errorVisible', toBooleanProperty(value));
}

public get errorText(): string | undefined {
return this.elementRef.nativeElement.errorText;
}

// Renaming because property should have camel casing, but attribute should not
// eslint-disable-next-line @angular-eslint/no-input-rename
@Input('error-text') public set errorText(value: string | undefined) {
this.renderer.setProperty(this.elementRef.nativeElement, 'errorText', value);
}

public get placeholder(): string {
return this.elementRef.nativeElement.placeholder;
}

@Input() public set placeholder(value: string) {
this.renderer.setProperty(this.elementRef.nativeElement, 'placeholder', value);
}

public constructor(private readonly renderer: Renderer2, private readonly elementRef: ElementRef<RichTextEditor>) { }

public getMarkdown(): string {
return this.elementRef.nativeElement.getMarkdown();
}

public setMarkdown(value: string): void {
this.elementRef.nativeElement.setMarkdown(value);
}

public get empty(): boolean {
return this.elementRef.nativeElement.empty;
}

@HostListener('input', ['$event'])
public onInput($event: Event): void {
if ($event.target === this.elementRef.nativeElement) {
this.inputEvent.emit();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NimbleRichTextEditorDirective } from './nimble-rich-text-editor.directive';

import '@ni/nimble-components/dist/esm/rich-text-editor';

@NgModule({
declarations: [NimbleRichTextEditorDirective],
imports: [CommonModule],
exports: [NimbleRichTextEditorDirective]
})
export class NimbleRichTextEditorModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './nimble-rich-text-editor.directive';
vivinkrishna-ni marked this conversation as resolved.
Show resolved Hide resolved
export * from './nimble-rich-text-editor.module';
Loading