Skip to content

Commit

Permalink
feat: add new options (#1390)
Browse files Browse the repository at this point in the history
* feat: add new options

* chore: apply changes after linting [bot]

---------

Co-authored-by: taiga-family-bot <taiga-family-bot@users.noreply.github.com>
  • Loading branch information
splincode and taiga-family-bot authored Sep 16, 2024
1 parent f0c86b8 commit 6deb3a7
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 3 additions & 6 deletions projects/editor/src/components/editor/editor.component.ts
Original file line number Diff line number Diff line change
@@ -32,15 +32,13 @@ import {
import {delay, fromEvent, throttleTime} from 'rxjs';

import type {AbstractTuiEditor} from '../../abstract/editor-adapter.abstract';
import {TUI_EDITOR_DEFAULT_TOOLS} from '../../constants/default-editor-tools';
import {TUI_EDITOR_RESIZE_EVENT} from '../../constants/default-events';
import {TuiTiptapEditor} from '../../directives/tiptap-editor/tiptap-editor.directive';
import {TuiTiptapEditorService} from '../../directives/tiptap-editor/tiptap-editor.service';
import type {TuiEditorAttachedFile} from '../../interfaces/attached';
import {TUI_EDITOR_OPTIONS} from '../../tokens/editor-options';
import {TUI_EDITOR_VALUE_TRANSFORMER} from '../../tokens/editor-value-transformer';
import {TIPTAP_EDITOR} from '../../tokens/tiptap-editor';
import type {TuiEditorToolType} from '../../types/editor-tool';
import type {TuiSelectionState} from '../../utils/get-selection-state';
import {tuiGetSelectionState} from '../../utils/get-selection-state';
import {tuiIsSafeLinkRange} from '../../utils/safe-link-range';
@@ -131,14 +129,13 @@ export class TuiEditor extends TuiControl<string> implements OnDestroy {
protected firstInitialValue = '';

@Input()
public exampleText = '';
public exampleText = this.options.exampleText;

@Input()
public floatingToolbar = false;
public floatingToolbar = this.options.floatingToolbar;

@Input()
public tools: Set<TuiEditorToolType> | readonly TuiEditorToolType[] =
TUI_EDITOR_DEFAULT_TOOLS;
public tools = this.options.tools;

@Output()
public readonly fileAttached = new EventEmitter<Array<TuiEditorAttachedFile<any>>>();
8 changes: 8 additions & 0 deletions projects/editor/src/tokens/editor-options.ts
Original file line number Diff line number Diff line change
@@ -5,9 +5,11 @@ import {
EDITOR_BLANK_COLOR,
TUI_EDITOR_DEFAULT_EDITOR_COLORS,
} from '../constants/default-editor-colors';
import {TUI_EDITOR_DEFAULT_TOOLS} from '../constants/default-editor-tools';
import {tuiDefaultFontOptionsHandler} from '../constants/default-font-options-handler';
import type {TuiEditorLinkOptions} from '../constants/default-link-options-handler';
import {TUI_DEFAULT_LINK_OPTIONS} from '../constants/default-link-options-handler';
import type {TuiEditorToolType} from '../types/editor-tool';

export interface TuiEditorOptions {
readonly blankColor: string;
@@ -75,16 +77,22 @@ export interface TuiEditorOptions {
readonly spellcheck: boolean;
readonly enableDefaultStyles: boolean;
readonly translate: 'no' | 'yes';
readonly tools: Set<TuiEditorToolType> | readonly TuiEditorToolType[];
readonly floatingToolbar: boolean;
readonly exampleText: string;
}

export const TUI_EDITOR_DEFAULT_OPTIONS: TuiEditorOptions = {
translate: 'no',
spellcheck: false,
exampleText: '',
enableDefaultStyles: true,
tools: TUI_EDITOR_DEFAULT_TOOLS,
colors: TUI_EDITOR_DEFAULT_EDITOR_COLORS,
blankColor: EDITOR_BLANK_COLOR,
linkOptions: TUI_DEFAULT_LINK_OPTIONS,
fontOptions: tuiDefaultFontOptionsHandler,
floatingToolbar: false,
icons: {
undo: '@tui.undo',
redo: '@tui.redo',

0 comments on commit 6deb3a7

Please sign in to comment.