Skip to content

Commit c5f3d56

Browse files
committed
update
1 parent 16d7a1e commit c5f3d56

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/Editor.php

+18-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Editor extends Field
1818

1919
public function render()
2020
{
21-
$name = $this->formatName($this->column);
2221
$id = $this->formatName($this->id);
2322

2423
$config = (array) WangEditor::config('config');
@@ -31,19 +30,26 @@ public function render()
3130
$token = csrf_token();
3231

3332
$this->script = <<<EOT
33+
(function ($) {
3434
35-
var E = window.wangEditor
36-
var editor = new E('#{$this->id}');
37-
38-
editor.customConfig.uploadImgParams = {_token: '$token'}
39-
40-
Object.assign(editor.customConfig, {$config})
41-
42-
editor.customConfig.onchange = function (html) {
43-
$('#input-$id').val(html);
44-
}
45-
editor.create()
35+
if ($('#{$this->id}').attr('initialized')) {
36+
return;
37+
}
4638
39+
var E = window.wangEditor
40+
var editor = new E('#{$this->id}');
41+
42+
editor.customConfig.uploadImgParams = {_token: '$token'}
43+
44+
Object.assign(editor.customConfig, {$config})
45+
46+
editor.customConfig.onchange = function (html) {
47+
$('#input-$id').val(html);
48+
}
49+
editor.create();
50+
51+
$('#{$this->id}').attr('initialized', 1);
52+
})(jQuery);
4753
EOT;
4854
return parent::render();
4955
}

0 commit comments

Comments
 (0)