Skip to content

Commit

Permalink
Merge pull request #3 from dimitrov-adrian/patch-1
Browse files Browse the repository at this point in the history
Add read-only mode support
  • Loading branch information
vishaltelangre authored Dec 9, 2020
2 parents 55e44af + 1f774e7 commit 22d3bec
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ export default class Alert {
* @param {AlertData} data — previously saved data
* @param {AlertConfig} config — user config for Tool
* @param {Object} api - Editor.js API
* @param {boolean} readOnly - read only mode flag
*/
constructor({ data, config, api }) {
constructor({ data, config, api, readOnly }) {
this.api = api;

this.defaultType = config.defaultType || Alert.DEFAULT_TYPE;
Expand All @@ -130,6 +131,17 @@ export default class Alert {
};

this.container = undefined;

this.readOnly = readOnly;
}

/**
* Returns true to notify the core that read-only mode is supported
*
* @return {boolean}
*/
static get isReadOnlySupported() {
return true;
}

/**
Expand All @@ -146,7 +158,7 @@ export default class Alert {
this.container = this._make('div', containerClasses);

const messageEl = this._make('div', [this.CSS.message], {
contentEditable: true,
contentEditable: !this.readOnly,
innerHTML: this.data.message,
});

Expand Down

0 comments on commit 22d3bec

Please sign in to comment.