-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo): add example for filled groups
- Loading branch information
Showing
8 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ects/demo/src/modules/components/editor/filled-groups/editor-filled-groups.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<tui-doc-page | ||
header="Editor" | ||
package="ADDON-EDITOR" | ||
type="components" | ||
> | ||
<ng-template pageTab> | ||
<p i18n> | ||
Rich Text Editor based on | ||
<a | ||
tuiLink | ||
href="https://www.tiptap.dev/" | ||
> | ||
TipTap Editor | ||
</a> | ||
for using with Angular forms. For safety reasons use a | ||
<a | ||
tuiLink | ||
routerLink="/icon-set" | ||
fragment="sanitizer" | ||
> | ||
sanitizer | ||
</a> | ||
with this component. | ||
</p> | ||
|
||
<tui-doc-example | ||
id="filled-groups" | ||
i18n-heading | ||
heading="Filled groups" | ||
[content]="example1" | ||
> | ||
<tui-editor-filled-group-example-1></tui-editor-filled-group-example-1> | ||
</tui-doc-example> | ||
</ng-template> | ||
</tui-doc-page> |
24 changes: 24 additions & 0 deletions
24
projects/demo/src/modules/components/editor/filled-groups/editor-filled-groups.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiDocExample} from '@taiga-ui/addon-doc'; | ||
import {defaultEditorExtensions, TUI_EDITOR_EXTENSIONS} from '@taiga-ui/addon-editor'; | ||
|
||
@Component({ | ||
selector: `editor-draggable-groups`, | ||
templateUrl: `./editor-filled-groups.component.html`, | ||
encapsulation, | ||
changeDetection, | ||
providers: [ | ||
{ | ||
provide: TUI_EDITOR_EXTENSIONS, | ||
useValue: defaultEditorExtensions, | ||
}, | ||
], | ||
}) | ||
export class ExampleTuiEditorFilledGroupsComponent { | ||
readonly example1: TuiDocExample = { | ||
TypeScript: import(`./examples/1/index.ts?raw`), | ||
HTML: import(`./examples/1/index.html?raw`), | ||
}; | ||
} |
40 changes: 40 additions & 0 deletions
40
projects/demo/src/modules/components/editor/filled-groups/editor-filled-groups.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; | ||
import {RouterModule} from '@angular/router'; | ||
import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc'; | ||
import {TuiEditorModule, TuiEditorSocketModule} from '@taiga-ui/addon-editor'; | ||
import {TuiActiveZoneModule} from '@taiga-ui/cdk'; | ||
import { | ||
TuiButtonModule, | ||
TuiHostedDropdownModule, | ||
TuiLinkModule, | ||
TuiSvgModule, | ||
} from '@taiga-ui/core'; | ||
|
||
import {ExampleTuiEditorFilledGroupsComponent} from './editor-filled-groups.component'; | ||
import {TuiEditorFilledGroupExample1} from './examples/1'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
TuiActiveZoneModule, | ||
TuiSvgModule, | ||
TuiLinkModule, | ||
TuiHostedDropdownModule, | ||
TuiButtonModule, | ||
TuiAddonDocModule, | ||
FormsModule, | ||
ReactiveFormsModule, | ||
TuiEditorModule, | ||
TuiEditorSocketModule, | ||
RouterModule.forChild( | ||
tuiGenerateRoutes(ExampleTuiEditorFilledGroupsComponent), | ||
), | ||
], | ||
declarations: [ | ||
TuiEditorFilledGroupExample1, | ||
ExampleTuiEditorFilledGroupsComponent, | ||
], | ||
}) | ||
export class ExampleTuiEditorFilledGroupsModule {} |
11 changes: 11 additions & 0 deletions
11
projects/demo/src/modules/components/editor/filled-groups/examples/1/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<tui-editor | ||
class="my-editor" | ||
[formControl]="control" | ||
[tools]="builtInTools" | ||
></tui-editor> | ||
|
||
<h4>HTML:</h4> | ||
<tui-editor-socket [content]="control.value || ''"></tui-editor-socket> | ||
|
||
<h4>Text:</h4> | ||
<p>{{ control.value }}</p> |
10 changes: 10 additions & 0 deletions
10
projects/demo/src/modules/components/editor/filled-groups/examples/1/index.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.my-editor { | ||
min-height: 30rem; | ||
} | ||
|
||
tui-editor-socket [data-type='group'] { | ||
flex-direction: column; | ||
padding: 0.5rem; | ||
margin: 0.5rem 0; | ||
border: 2px dotted var(--tui-link); | ||
} |
46 changes: 46 additions & 0 deletions
46
projects/demo/src/modules/components/editor/filled-groups/examples/1/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {Component, ViewEncapsulation} from '@angular/core'; | ||
import {FormControl} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {TUI_EDITOR_EXTENSIONS, TuiEditorTool} from '@taiga-ui/addon-editor'; | ||
import {TuiDestroyService} from '@taiga-ui/cdk'; | ||
|
||
@Component({ | ||
selector: `tui-editor-filled-group-example-1`, | ||
templateUrl: `./index.html`, | ||
styleUrls: [`./index.less`], | ||
providers: [ | ||
TuiDestroyService, | ||
{ | ||
provide: TUI_EDITOR_EXTENSIONS, | ||
useValue: [ | ||
import(`@taiga-ui/addon-editor/extensions/starter-kit`).then( | ||
({StarterKit}) => StarterKit, | ||
), | ||
import(`@taiga-ui/addon-editor/extensions/group`).then( | ||
({createGroupExtension}) => | ||
createGroupExtension({ | ||
nested: false, | ||
draggable: false, | ||
createOnEnter: true, | ||
// @note: you can override css styles with your own classes | ||
groupNodeClass: `filled-group`, | ||
groupPointerNodeClass: ``, // anyway element doesn't exists if `draggable` is false | ||
}), | ||
), | ||
], | ||
}, | ||
], | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection, | ||
}) | ||
export class TuiEditorFilledGroupExample1 { | ||
readonly builtInTools = [TuiEditorTool.Undo, TuiEditorTool.Group]; | ||
|
||
control = new FormControl(``); | ||
|
||
constructor() { | ||
this.control.patchValue( | ||
`<div data-type="group"><p>This is a boring paragraph.</p></div><div data-type="group"><p>And another draggable paragraph.</p></div><div data-type="group"><p>Let’s finish with a boring paragraph.</p></div>`, | ||
); | ||
} | ||
} |