webspresso 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,8 @@ module.exports = {
28
28
  function initEditor(vnode) {
29
29
  const editorId = 'quill-editor-' + name;
30
30
  const editorEl = document.getElementById(editorId);
31
+ const hiddenInput = document.getElementById(name + '-value');
32
+
31
33
  if (editorEl && !editorEl._quill) {
32
34
  const quill = new window.Quill(editorEl, {
33
35
  theme: 'snow',
@@ -45,28 +47,56 @@ module.exports = {
45
47
  // Set initial content
46
48
  if (value) {
47
49
  quill.root.innerHTML = value;
50
+ if (hiddenInput) {
51
+ hiddenInput.value = value;
52
+ }
48
53
  }
49
54
 
50
55
  // Handle content changes
51
56
  quill.on('text-change', () => {
52
57
  const content = quill.root.innerHTML;
58
+ if (hiddenInput) {
59
+ hiddenInput.value = content;
60
+ }
53
61
  if (onchange) {
54
62
  onchange(content);
55
63
  }
56
64
  });
57
65
 
58
66
  editorEl._quill = quill;
67
+ vnode.state.quill = quill;
68
+ }
69
+ }
70
+ },
71
+
72
+ onupdate: (vnode) => {
73
+ // Update editor content if value changed externally
74
+ const { name, value = '' } = vnode.attrs;
75
+ const editorId = 'quill-editor-' + name;
76
+ const editorEl = document.getElementById(editorId);
77
+ const hiddenInput = document.getElementById(name + '-value');
78
+
79
+ if (editorEl && editorEl._quill && vnode.state.quill) {
80
+ const currentContent = editorEl._quill.root.innerHTML;
81
+ if (currentContent !== value) {
82
+ editorEl._quill.root.innerHTML = value || '';
83
+ if (hiddenInput) {
84
+ hiddenInput.value = value || '';
85
+ }
59
86
  }
60
87
  }
61
88
  },
62
89
 
63
90
  view: (vnode) => {
64
- const { name, meta = {}, required = false } = vnode.attrs;
91
+ const { name, meta = {}, required = false, value = '' } = vnode.attrs;
92
+ const ui = meta.ui || {};
93
+ const label = ui.label || meta.label || name;
94
+ const hint = ui.hint || '';
65
95
  const editorId = 'quill-editor-' + name;
66
96
 
67
97
  return m('.mb-4', [
68
- m('label.block.text-sm.font-medium.mb-2',
69
- meta.label || name,
98
+ m('label.block.text-sm.font-medium.text-gray-700.mb-1', { for: name },
99
+ label,
70
100
  required ? m('span.text-red-500', ' *') : null
71
101
  ),
72
102
  m('div.border.border-gray-300.rounded', {
@@ -76,7 +106,9 @@ module.exports = {
76
106
  m('input[type=hidden]', {
77
107
  name,
78
108
  id: name + '-value',
109
+ value: value || '',
79
110
  }),
111
+ hint ? m('p.text-xs.text-gray-500.mt-1', hint) : null,
80
112
  ]);
81
113
  }
82
114
  },