mirror of
https://github.com/codex-team/editor.js
synced 2024-06-10 18:03:25 +02:00
* Add tunes improvements * Allow to show Inline Toolbar at Block Tune Wrapper element * Add fake cursor on block selection * Fix lint * Update types * Fix bugs with selection * Remove selection observer * Update due to comments * Fix tests * Update docs/block-tunes.md Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * Move fake cursor to selection utils * Fix missing range for Safari * Fix data attribute value * Add comment * Update z-index for inline-toolbar * Add changelog * Remove fake cursor visibility for the core Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
37 lines
780 B
TypeScript
37 lines
780 B
TypeScript
import { ReadOnly } from '../../../../types/api';
|
|
import Module from '../../__module';
|
|
|
|
/**
|
|
* @class ReadOnlyAPI
|
|
* @classdesc ReadOnly API
|
|
*/
|
|
export default class ReadOnlyAPI extends Module {
|
|
/**
|
|
* Available methods
|
|
*/
|
|
public get methods(): ReadOnly {
|
|
return {
|
|
toggle: (state): Promise<boolean> => this.toggle(state),
|
|
isEnabled: this.isEnabled,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Set or toggle read-only state
|
|
*
|
|
* @param {boolean|undefined} state - set or toggle state
|
|
*
|
|
* @returns {boolean} current value
|
|
*/
|
|
public toggle(state?: boolean): Promise<boolean> {
|
|
return this.Editor.ReadOnly.toggle(state);
|
|
}
|
|
|
|
/**
|
|
* Returns current read-only state
|
|
*/
|
|
public get isEnabled(): boolean {
|
|
return this.Editor.ReadOnly.isEnabled;
|
|
}
|
|
}
|