Add Spell Checker Option to SimpleMDE Plugin

Default is off.
This commit is contained in:
anaggh 2016-11-19 14:00:53 +05:30
parent dbaf520653
commit 26c03bc9d7
2 changed files with 14 additions and 3 deletions

View File

@ -6,5 +6,6 @@
}, },
"toolbar": "Toolbar", "toolbar": "Toolbar",
"tab-size": "Tab size", "tab-size": "Tab size",
"autosave": "Autosave" "autosave": "Autosave",
"spell-checker": "Spell Checker"
} }

View File

@ -14,7 +14,8 @@ class pluginsimpleMDE extends Plugin {
$this->dbFields = array( $this->dbFields = array(
'tabSize'=>'2', 'tabSize'=>'2',
'toolbar'=>'"bold", "italic", "heading", "|", "quote", "unordered-list", "|", "link", "image", "code", "horizontal-rule", "|", "preview", "side-by-side", "fullscreen", "guide"', 'toolbar'=>'"bold", "italic", "heading", "|", "quote", "unordered-list", "|", "link", "image", "code", "horizontal-rule", "|", "preview", "side-by-side", "fullscreen", "guide"',
'autosave'=>0 'autosave'=>0,
'spellChecker'=>0
); );
} }
@ -37,6 +38,12 @@ class pluginsimpleMDE extends Plugin {
$html .= '<input name="autosave" id="jsautosave" type="checkbox" value="1" '.($this->getDbField('autosave')?'checked':'').'>'; $html .= '<input name="autosave" id="jsautosave" type="checkbox" value="1" '.($this->getDbField('autosave')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsautosave">'.$Language->get('Autosave').'</label>'; $html .= '<label class="forCheckbox" for="jsautosave">'.$Language->get('Autosave').'</label>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="spellChecker" value="0">';
$html .= '<input name="spellChecker" id="jsspellChecker" type="checkbox" value="1" '.($this->getDbField('spellChecker')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsspellChecker">'.$Language->get('spell-checker').'</label>';
$html .= '</div>';
return $html; return $html;
} }
@ -96,6 +103,9 @@ class pluginsimpleMDE extends Plugin {
$autosaveID = $_Post->key(); $autosaveID = $_Post->key();
} }
// Spell Checker
$spellCheckerEnable = $this->getDbField('spellChecker')?'true':'false';
$pluginPath = $this->htmlPath(); $pluginPath = $this->htmlPath();
$html = '<script>'.PHP_EOL; $html = '<script>'.PHP_EOL;
@ -123,7 +133,7 @@ class pluginsimpleMDE extends Plugin {
autoDownloadFontAwesome: false, autoDownloadFontAwesome: false,
indentWithTabs: true, indentWithTabs: true,
tabSize: '.$this->getDbField('tabSize').', tabSize: '.$this->getDbField('tabSize').',
spellChecker: false, spellChecker: '.$spellCheckerEnable.',
autosave: { autosave: {
enabled: '.$autosaveEnable.', enabled: '.$autosaveEnable.',
uniqueId: "'.$autosaveID.'", uniqueId: "'.$autosaveID.'",