<commit_before>import {defaultSchema} from "../model"
import {AssertionError} from "../util/error"
import {ParamPrompt} from "../ui/prompt"

import {CommandSet, updateCommands} from "./command"

class Option {
  constructor(defaultValue, update, updateOnInit) {
    this.defaultValue = defaultValue
    this.update = update
    this.updateOnInit = updateOnInit !== false
  }
}

const options = Object.create(null)

// :: (string, any, (pm: ProseMirror, newValue: any, oldValue: any, init: bool), bool)
// Define a new option. The `update` handler will be called with the
// option's old and new value every time the option is
// [changed](#ProseMirror.setOption). When `updateOnInit` is false, it
// will not be called on editor init, otherwise it is called with null as the old value,
// and a fourth argument of true.
export function defineOption(name, defaultValue, update, updateOnInit) {
  options[name] = new Option(defaultValue, update, updateOnInit)
}<commit_msg>Add option docs<commit_after>import {defaultSchema} from "../model"
import {AssertionError} from "../util/error"
import {ParamPrompt} from "../ui/prompt"

import {CommandSet, updateCommands} from "./command"

// An option encapsulates functionality for an editor instance,
// e.g. the amount of history events that the editor should hold
// onto or the document's schema.
class Option {
  constructor(defaultValue, update, updateOnInit) {
    this.defaultValue = defaultValue
    // A function that will be invoked with the option's old and new
    // value every time the option is [set](#ProseMirror.setOption).
    // This function should bootstrap option functionality.
    this.update = update
    this.updateOnInit = updateOnInit !== false
  }
}

const options = Object.create(null)

// :: (string, any, (pm: ProseMirror, newValue: any, oldValue: any, init: bool), bool)
// Define a new option. The `update` handler will be called with the
// option's old and new value every time the option is
// [changed](#ProseMirror.setOption). When `updateOnInit` is false, it
// will not be called on editor init, otherwise it is called with null as the old value,
// and a fourth argument of true.
export function defineOption(name, defaultValue, update, updateOnInit) {
  options[name] = new Option(defaultValue, update, updateOnInit)
}
{'fraction_non_alphanumeric': 0.10932754880694143, 'fraction_numerical': 0.0, 'mean_word_length': 4.193693693693693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2839184', 'n_tokens_mistral': 650, 'n_tokens_neox': 633, 'n_words': 261}