-
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.
feat!: delete
tui-palette.less
(data-tui-background
and `data-tui…
…-color` states) (#2473)
- Loading branch information
1 parent
059d7af
commit 09067a2
Showing
20 changed files
with
747 additions
and
829 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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
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
16 changes: 16 additions & 0 deletions
16
projects/demo/src/modules/components/editor/examples/7/image-loader.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,16 @@ | ||
import {fromEvent, Observable} from 'rxjs'; | ||
import {map, switchMap} from 'rxjs/operators'; | ||
|
||
import {ImgbbService} from './imgbb.service'; | ||
|
||
export function imageLoader(service: ImgbbService): (file: File) => Observable<string> { | ||
return (file: File) => { | ||
const fileReader = new FileReader(); | ||
|
||
fileReader.readAsDataURL(file); | ||
|
||
return fromEvent(fileReader, `load`) | ||
.pipe(map(() => String(fileReader.result))) | ||
.pipe(switchMap(base64 => service.save(base64))); | ||
}; | ||
} |
45 changes: 45 additions & 0 deletions
45
projects/demo/src/modules/components/editor/examples/7/imgbb.service.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,45 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {from, Observable} from 'rxjs'; | ||
import {map} from 'rxjs/operators'; | ||
|
||
import {environment} from '../../../../../environments/environment'; | ||
|
||
interface ImgbbResponse { | ||
data: { | ||
id: string; | ||
title: string; | ||
url: string; | ||
width: string; | ||
height: string; | ||
size: number; | ||
time: string; | ||
expiration: string; | ||
}; | ||
success: boolean; | ||
status: number; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: `root`, | ||
}) | ||
export class ImgbbService { | ||
private static createBody(base64: string): URLSearchParams { | ||
const formData = new FormData(); | ||
|
||
formData.append(`image`, base64.split(`,`).pop() || ``); | ||
|
||
return new URLSearchParams(formData as any); | ||
} | ||
|
||
save(base64: string): Observable<string> { | ||
const {host, apiKey, expiration} = environment.imgbb; | ||
|
||
return from( | ||
fetch(`${host}/1/upload?key=${apiKey}&expiration=${expiration}`, { | ||
method: `POST`, | ||
body: ImgbbService.createBody(base64), | ||
headers: {'Content-Type': `application/x-www-form-urlencoded`}, | ||
}).then(async (response: Response) => response.json()), | ||
).pipe(map((response: ImgbbResponse) => response.data.url)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
projects/demo/src/modules/components/editor/examples/7/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="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> |
3 changes: 3 additions & 0 deletions
3
projects/demo/src/modules/components/editor/examples/7/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,3 @@ | ||
.editor { | ||
min-height: 30rem; | ||
} |
63 changes: 63 additions & 0 deletions
63
projects/demo/src/modules/components/editor/examples/7/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,63 @@ | ||
import {Component, Injector} from '@angular/core'; | ||
import {FormControl} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import { | ||
TUI_EDITOR_EXTENSIONS, | ||
TUI_EDITOR_MAX_IMAGE_WIDTH, | ||
TUI_EDITOR_MIN_IMAGE_WIDTH, | ||
TUI_IMAGE_LOADER, | ||
TuiEditorTool, | ||
} from '@taiga-ui/addon-editor'; | ||
import {TuiDestroyService} from '@taiga-ui/cdk'; | ||
|
||
import {imageLoader} from './image-loader'; | ||
import {ImgbbService} from './imgbb.service'; | ||
|
||
@Component({ | ||
selector: `tui-editor-example-7`, | ||
templateUrl: `./index.html`, | ||
styleUrls: [`./index.less`], | ||
providers: [ | ||
TuiDestroyService, | ||
{ | ||
provide: TUI_EDITOR_EXTENSIONS, | ||
deps: [Injector], | ||
useFactory: (injector: Injector) => [ | ||
import(`@taiga-ui/addon-editor/extensions/starter-kit`).then( | ||
({StarterKit}) => StarterKit, | ||
), | ||
import(`@taiga-ui/addon-editor/extensions/image-editor`).then( | ||
({createImageEditorExtension}) => | ||
createImageEditorExtension(injector), | ||
), | ||
], | ||
}, | ||
{ | ||
provide: TUI_EDITOR_MIN_IMAGE_WIDTH, | ||
useValue: 150, | ||
}, | ||
{ | ||
provide: TUI_EDITOR_MAX_IMAGE_WIDTH, | ||
useValue: 400, | ||
}, | ||
{ | ||
provide: TUI_IMAGE_LOADER, | ||
useFactory: imageLoader, | ||
deps: [ImgbbService], | ||
}, | ||
], | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiEditorExample7 { | ||
readonly builtInTools = [TuiEditorTool.Undo, TuiEditorTool.Img]; | ||
|
||
control = new FormControl(``); | ||
|
||
constructor() { | ||
this.control.patchValue( | ||
`<img data-type="image-editor" src="/assets/images/lumberjack.png" width="300"><p>Try to drag right border of image!</p><p>To change min size of image use token <code>TUI_EDITOR_MIN_IMAGE_WIDTH</code>.</p><p>To change max size of image use token <code>TUI_EDITOR_MAX_IMAGE_WIDTH</code>.</p>`, | ||
); | ||
} | ||
} |
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
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
Oops, something went wrong.