yf_form2_ace_editor class

Fileplugins/form2/classes/form2/yf_form2_ace_editor.class.php
Use_class('form2_ace_editor', 'classes/form2/')

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 1

None without a leading underscore.

Methods starting with _ hooks and helpers; not routable as page actions

public function _ace_editor_html($extra = [], $replace = [], $form = null)
    public function _ace_editor_html($extra = [], $replace = [], $form = null)
    {
        $body = null;
        $extra['id'] = ($extra['id'] ?? null) ?: 'editor_html';
        asset('ace-editor');
        $opts = [
            'fontSize' => (($extra['ace_editor']['font-size'] ?? null) ?: '16px'),
//			'theme' => 'ace/theme/'.($extra['ace_editor']['theme'] ?: 'tomorrow_night'),
//			'mode' => 'ace/mode/'.($extra['ace_editor']['mode'] ?: 'html'),
        ];
        $jq = '
			try {
				var ace_editor = ace.edit("' . addslashes($extra['id']) . '");
				ace_editor.setTheme("ace/theme/' . (($extra['ace_editor']['theme'] ?? null) ?: 'tomorrow_night') . '");
				ace_editor.getSession().setMode("ace/mode/' . (($extra['ace_editor']['mode'] ?? null) ?: 'html') . '");
				ace_editor.setPrintMarginColumn(false);
				ace_editor.setOptions(' . str_replace('\/', '/', json_encode($opts)) . ');
				$("#' . addslashes($extra['id']) . '").data("ace_editor", ace_editor);
			} catch (e) {
				console.log(e)
			}
		';
        jquery($jq);
        return null;
    }