fvn-ui 0.1.0-alpha.39 → 0.1.0-alpha.40
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.
- package/package.json +1 -1
- package/src/fvn-ui/LLM.md +3 -5
- package/src/fvn-ui/components/editable.js +11 -11
package/package.json
CHANGED
package/src/fvn-ui/LLM.md
CHANGED
|
@@ -17,17 +17,15 @@ selectComponent({ onChange: (value, item, event) => console.log(value, item) })
|
|
|
17
17
|
tabs({ onChange: (value, item, event) => console.log(value, item) })
|
|
18
18
|
collapsible({ onChange: (isOpen, event) => console.log(isOpen) })
|
|
19
19
|
toggle({ onChange: (checked, event) => console.log(checked) })
|
|
20
|
+
editable({ onInput: (html, event) => console.log(html, event.target.textContent) })
|
|
20
21
|
|
|
21
22
|
// `this` is bound to the element
|
|
22
23
|
input({ onInput(value) { console.log(this.id, value) } })
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
**Special
|
|
26
|
+
**Special case - draggable uses object payload:**
|
|
26
27
|
```js
|
|
27
|
-
//
|
|
28
|
-
editable({ onChange: ({ value, html, element, event }) => ... })
|
|
29
|
-
|
|
30
|
-
// draggable - passes reorder info
|
|
28
|
+
// draggable - passes reorder info (no event)
|
|
31
29
|
draggable({ onChange: ({ items, from, to }) => ... })
|
|
32
30
|
```
|
|
33
31
|
|
|
@@ -14,12 +14,12 @@ const bem = bemFactory('editable');
|
|
|
14
14
|
* @param {number} [config.rows] - 1 = single line, > 1 = multiline (sets min-height)
|
|
15
15
|
* @param {boolean} [config.multiline=true] - Allow multiple lines (false = single line)
|
|
16
16
|
* @param {boolean} [config.plainText=false] - Strip formatting on paste
|
|
17
|
-
* @param {Function} [config.onChange] - Called on input with
|
|
18
|
-
* @param {Function} [config.onInput] - Called on every input event
|
|
19
|
-
* @param {Function} [config.onFocus] - Called on focus
|
|
20
|
-
* @param {Function} [config.onBlur] - Called on blur
|
|
21
|
-
* @param {Function} [config.onKeydown] - Called on keydown
|
|
22
|
-
* @param {Function} [config.onSubmit] - Called on Enter key (single line mode
|
|
17
|
+
* @param {Function} [config.onChange] - Called on input with (html, event) - use e.target.textContent for text
|
|
18
|
+
* @param {Function} [config.onInput] - Called on every input with (html, event)
|
|
19
|
+
* @param {Function} [config.onFocus] - Called on focus with (event)
|
|
20
|
+
* @param {Function} [config.onBlur] - Called on blur with (html, event)
|
|
21
|
+
* @param {Function} [config.onKeydown] - Called on keydown with (event)
|
|
22
|
+
* @param {Function} [config.onSubmit] - Called on Enter key with (html, event) - single line mode only
|
|
23
23
|
* @param {string} [config.id] - Registers to dom.editable[id] and dom[id]
|
|
24
24
|
* @returns {HTMLDivElement} Wrapper with .value getter/setter for text content
|
|
25
25
|
* @example
|
|
@@ -73,9 +73,9 @@ export function editable(...args) {
|
|
|
73
73
|
|
|
74
74
|
const handleInput = (e) => {
|
|
75
75
|
normalizeContent();
|
|
76
|
-
const
|
|
77
|
-
onInput?.call(editableEl,
|
|
78
|
-
onChange?.call(editableEl,
|
|
76
|
+
const html = getHtml();
|
|
77
|
+
onInput?.call(editableEl, html, e);
|
|
78
|
+
onChange?.call(editableEl, html, e);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const handleKeydown = (e) => {
|
|
@@ -84,7 +84,7 @@ export function editable(...args) {
|
|
|
84
84
|
// Single line: prevent Enter from creating new lines
|
|
85
85
|
if (isSingleLine && e.key === 'Enter') {
|
|
86
86
|
e.preventDefault();
|
|
87
|
-
onSubmit?.call(editableEl,
|
|
87
|
+
onSubmit?.call(editableEl, getHtml(), e);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
|
|
@@ -117,7 +117,7 @@ export function editable(...args) {
|
|
|
117
117
|
|
|
118
118
|
const handleBlur = (e) => {
|
|
119
119
|
normalizeContent();
|
|
120
|
-
onBlur?.call(editableEl,
|
|
120
|
+
onBlur?.call(editableEl, getHtml(), e);
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
const editableDiv = el('div', {
|