X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ec3713bc743d56d2aeea5fe6890f8843dce63127..refs/heads/development:/resources/js/markdown/settings.js diff --git a/resources/js/markdown/settings.js b/resources/js/markdown/settings.js deleted file mode 100644 index 6dd142210..000000000 --- a/resources/js/markdown/settings.js +++ /dev/null @@ -1,40 +0,0 @@ -import {kebabToCamel} from "../services/text"; - - -export class Settings { - - constructor(initialSettings) { - this.settingMap = {}; - this.changeListeners = {}; - this.merge(initialSettings); - } - - set(key, value) { - key = this.normaliseKey(key); - this.settingMap[key] = value; - for (const listener of (this.changeListeners[key] || [])) { - listener(value); - } - } - - get(key) { - return this.settingMap[this.normaliseKey(key)] || null; - } - - merge(settings) { - for (const [key, value] of Object.entries(settings)) { - this.set(key, value); - } - } - - onChange(key, callback) { - key = this.normaliseKey(key); - const listeners = this.changeListeners[this.normaliseKey(key)] || []; - listeners.push(callback); - this.changeListeners[this.normaliseKey(key)] = listeners; - } - - normaliseKey(key) { - return kebabToCamel(key.replace('md-', '')); - } -} \ No newline at end of file