### Hierarchy

- WriteAwayCore

## Index

### Constructors

- constructor

### Accessors

- api
- config
- piecesConfig
- state

### Methods

- addPiece
- applyEditor
- destroy
- destroyAllPieces
- destroyPiece
- getPieceList
- isEditorActive
- isExpertMode
- isNavBarCollapsed
- setData
- setEditorActive
- setExpertMode
- setNavBarCollapsed

## Constructors

### constructor

- new WriteAwayCore(options?: Partial<IOptions>): WriteAwayCore

- #### Parameters

  - ##### Default value options: Partial<IOptions> = {}

  #### Returns WriteAwayCore

## Accessors

### api

- get api(): IPiecesAPI

- #### Returns IPiecesAPI

### config

- get config(): IOptions

- #### Returns IOptions

### piecesConfig

- get piecesConfig(): IPiecesOptions

- #### Returns IPiecesOptions

### state

- get state(): IWriteAwayState

- #### Returns IWriteAwayState

## Methods

### addPiece

- addPiece<Data>(node: HTMLElement, options?: { data?: Data; dataset?: undefined | {}; id?: undefined | string; name?: undefined | string; type?: undefined | string }): void

- Add a piece from specific node

  #### Type parameters

  - #### Data = any

  #### Parameters

  - ##### node: HTMLElement

    HTMLElement

  - ##### Default value options: { data?: Data; dataset?: undefined | {}; id?: undefined | string; name?: undefined | string; type?: undefined | string } = {}

    - ##### Optional data?: Data

      Optional. Set of data associated with piece in format of piece component. If not specified will be fetched.

    - ##### Optional dataset?: undefined | {}

      Optional. Set of random data attributes associated with node that will be passed to save and get API calls. If not specified will be read directly from node dataset.

    - ##### Optional id?: undefined | string

      Mandatory unique identification id of piece. Should present in options OR in `this.options.pieces.attributeId` attribute of node, i.e. `data-id`

    - ##### Optional name?: undefined | string

      Optional. Human readable name for list in editor. If not specified will be tried to be read from `this.options.pieces.attributeName` attribute of node

    - ##### Optional type?: undefined | string

      Mandatory type of piece. Should present in options OR in `this.options.pieces.attribute` attribute of node, i.e. `data-piece`

  #### Returns void

### applyEditor

- applyEditor(node: HTMLElement, editorType: PieceType, data: any): void

- #### Parameters

  - ##### node: HTMLElement

  - ##### editorType: PieceType

  - ##### data: any

  #### Returns void

### destroy

- destroy(): void

- #### Returns void

### destroyAllPieces

- destroyAllPieces(): void

- Destroy all existing pieces

  #### Returns void

### destroyPiece

- destroyPiece(id: string): void

- Prepares node for removal from DOM. Dirty destroys editor. Removes listeners, cleans up memory, but does not restore node fully.

  #### Parameters

  - ##### id: string

    of element to destroy

  #### Returns void

### getPieceList

- getPieceList(): {}

- Get a list of all active pieces information

  #### Returns {}

  - ##### [pieceId: string]: IPieceItem

### isEditorActive

- isEditorActive(editorType?: PieceType): boolean

- Checks if editor toggle is active

  #### Parameters

  - ##### Optional editorType: PieceType

    editor type. Optional. If not specified, returns state of "all" toggle

  #### Returns boolean

### isExpertMode

- isExpertMode(): boolean

- Check if expert mode

  #### Returns boolean

### isNavBarCollapsed

- isNavBarCollapsed(): boolean

- Check if navbar is collapsed

  #### Returns boolean

### setData

- setData<Data>(pieceId: string, data: Data): void

- Set new data to a piece by piece id

  #### Type parameters

  - #### Data

  #### Parameters

  - ##### pieceId: string

    id of piece

  - ##### data: Data

    `data` of the pieces

  #### Returns void

### setEditorActive

- setEditorActive(editorActive: boolean, editorType?: PieceType): void

- Set the active state for editors

  #### Parameters

  - ##### editorActive: boolean

    new state

  - ##### Optional editorType: PieceType

    type of editor, optional. By default applies to "all" toggle.

  #### Returns void

### setExpertMode

- setExpertMode(expert: boolean): void

- Visualize expert features

  #### Parameters

  - ##### expert: boolean

    new state

  #### Returns void

### setNavBarCollapsed

- setNavBarCollapsed(navBarActive: boolean): void

- Set the collapsed state for navbar

  #### Parameters

  - ##### navBarActive: boolean

    new state

  #### Returns void

Generated using TypeDoc