From 0d9dee533eba4e233404a6ff5dd09fddc1633e10 Mon Sep 17 00:00:00 2001 From: sunhao Date: Tue, 11 Nov 2025 08:51:18 +0800 Subject: [PATCH] * [misc] support for setting initial content to zen-editor by attribute. --- lib/zin/wg/editor/v1.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/zin/wg/editor/v1.php b/lib/zin/wg/editor/v1.php index 4ea3c18d44..2c0df9d3f9 100644 --- a/lib/zin/wg/editor/v1.php +++ b/lib/zin/wg/editor/v1.php @@ -114,10 +114,15 @@ class editor extends wg $customProps = $this->getRestProps(); if(!isset($customProps['class'])) $customProps['class'] = 'w-full'; - $editor->add(set($customProps)); - $editor->add(set('css', self::$css)); // Inject CSS into editor. - $editor->add(set('css-src', $app->getWebRoot() . 'js/zui3/zen-editor/zui-inject-style.css')); // Inject CSS on page, for tippy menus. - $editor->add(h('article', set('slot', 'content'), html($this->prop('value')), $this->children())); // Set initial content. + $editor->setProp($customProps); + $editor->setProp('css', self::$css); // Inject CSS into editor. + $editor->setProp('css-src', $app->getWebRoot() . 'js/zui3/zen-editor/zui-inject-style.css'); // Inject CSS on page, for tippy menus. + + /* Set initial content. */ + $initialContent = $this->prop('value'); + $children = $this->children(); + if(empty($children)) $editor->setProp('initial-content', $initialContent); + else $editor->add(h('article', set('slot', 'content'), $initialContent? html($initialContent) : null, $children)); $templateType = $this->prop('templateType');