<?php

namespace App\Admin\Extensions\Form;

use Encore\Admin\Form\Field;

class AddSpecification extends Field
{
    protected $view = 'admin.add-specification';

    protected static $css = [
        '/vendor/wangEditor-3.1.1/release/wangEditor.css',
    ];

    protected static $js = [
        '/vendor/wangEditor-3.1.1/release/wangEditor.js',
    ];

    public function render()
    {
        $name = $this->formatName($this->column);

        $this->script = <<<EOT

var E = window.wangEditor
var editor = new E('#{$this->id}');
editor.customConfig.zIndex = 0
editor.customConfig.uploadImgShowBase64 = true
editor.customConfig.onchange = function (html) {
    $('input[name=$name]').val(html);
}
editor.create()

EOT;
        return parent::render();
    }
}
