@componyx/ui 0.0.0-stage → 1.0.4
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/AppSkin/AppSkin.css +1268 -0
- package/AppSkin/AppSkin.js +2748 -0
- package/AppSkin/Themes/Default.css +241 -0
- package/Base/Base.js +3407 -0
- package/Base/ComponentIcons.css +66 -0
- package/Base/Font/ComponentIcons.woff +0 -0
- package/Base/Font/UI.woff +0 -0
- package/Base/Library.js +8432 -0
- package/Base/NavigationManager.js +462 -0
- package/Base/ResponsiveTemplates.js +371 -0
- package/Base/Sanitizer.js +288 -0
- package/Base/Themes/Default.css +255 -0
- package/Base/UI.css +618 -0
- package/Base/UIResourcePath.js +6 -0
- package/Bindary/Bindary.js +2011 -0
- package/Bindary/Modules/Connection.js +216 -0
- package/Bindary/Modules/Core.js +854 -0
- package/Bindary/Modules/DataUpdater.js +351 -0
- package/Bindary/Modules/ExpressionEngine.js +347 -0
- package/Bindary/Modules/ProxyManager.js +482 -0
- package/Bindary/Modules/Renderer.js +605 -0
- package/Bindary/Modules/Router.js +291 -0
- package/Bindary/Modules/Scroller.js +89 -0
- package/Bindary/Modules/Template.js +1273 -0
- package/BookmarkSpy/BookmarkSpy.js +430 -0
- package/Box/Box.css +36 -0
- package/Box/Box.js +1685 -0
- package/Button/Button.css +470 -0
- package/Button/Button.js +1398 -0
- package/Button/Themes/Default.css +200 -0
- package/Carousel/Carousel.css +273 -0
- package/Carousel/Carousel.js +607 -0
- package/ColorButton/ColorButton.css +39 -0
- package/ColorButton/ColorButton.js +336 -0
- package/ColorPicker/ColorPicker.css +359 -0
- package/ColorPicker/ColorPicker.js +972 -0
- package/ComboBox/ComboBox.css +357 -0
- package/ComboBox/ComboBox.js +2342 -0
- package/ComboBox/Themes/Default.css +23 -0
- package/DataPager/DataPager.css +72 -0
- package/DataPager/DataPager.js +674 -0
- package/DatePicker/DatePicker.css +227 -0
- package/DatePicker/DatePicker.js +1531 -0
- package/DatePicker/Themes/Default.css +26 -0
- package/Dialog/Dialog.css +106 -0
- package/Dialog/Dialog.js +572 -0
- package/Dialog/Themes/Default.css +10 -0
- package/Editor/Data/Emoji.json +8285 -0
- package/Editor/Data/Special.json +1042 -0
- package/Editor/Editor.css +1562 -0
- package/Editor/Editor.js +4058 -0
- package/Editor/Font/Editor.woff +0 -0
- package/Editor/Modules/ComponentFactory.js +565 -0
- package/Editor/Modules/ContentManager.js +748 -0
- package/Editor/Modules/DialogManager.js +1234 -0
- package/Editor/Modules/EventManager.js +458 -0
- package/Editor/Modules/Format.js +950 -0
- package/Editor/Modules/History.js +191 -0
- package/Editor/Modules/LayoutState.js +379 -0
- package/Editor/Modules/ListManager.js +296 -0
- package/Editor/Modules/MenuManager.js +388 -0
- package/Editor/Modules/NodeManager.js +681 -0
- package/Editor/Modules/ParagraphButtons.js +122 -0
- package/Editor/Modules/Resizer.js +176 -0
- package/Editor/Modules/SelectionRange.js +564 -0
- package/Editor/Modules/SourceViewBuilder.js +212 -0
- package/Editor/Modules/SymbolPicker.js +208 -0
- package/Editor/Modules/Table.js +2327 -0
- package/Editor/Modules/TableDialog.js +757 -0
- package/Editor/Modules/Toolbar.js +375 -0
- package/Editor/Modules/TooltipMenu.js +125 -0
- package/Editor/Modules/Utility.js +131 -0
- package/Editor/Themes/Default.css +204 -0
- package/FileUpload/FileUpload.css +156 -0
- package/FileUpload/FileUpload.js +898 -0
- package/FileUpload/Themes/Default.css +17 -0
- package/Form/Form.css +1934 -0
- package/Form/Form.js +4943 -0
- package/Form/Modules/ActionManager.js +368 -0
- package/Form/Modules/BuildPanelManager.js +319 -0
- package/Form/Modules/ComponentFactory.js +468 -0
- package/Form/Modules/ComponentPanel.js +265 -0
- package/Form/Modules/ConfigPanelManager.js +685 -0
- package/Form/Modules/DataBinder.js +602 -0
- package/Form/Modules/DataObserver.js +717 -0
- package/Form/Modules/Draggable.js +756 -0
- package/Form/Modules/OptionsPanel.js +342 -0
- package/Form/Modules/Renderer.js +1889 -0
- package/Form/Modules/RuleEngine.js +585 -0
- package/Form/Modules/RulesPanel.js +1158 -0
- package/Form/Modules/Types.js +1709 -0
- package/Form/Modules/ValidationManager.js +194 -0
- package/Form/Themes/Default.css +216 -0
- package/FormField/FormField.css +468 -0
- package/FormField/FormField.js +576 -0
- package/FormField/Themes/Default.css +99 -0
- package/Grid/Grid.css +544 -0
- package/Grid/Grid.js +3761 -0
- package/Grid/Themes/Default.css +43 -0
- package/LICENSE +126 -0
- package/MaskedTextBox/MaskedTextBox.css +28 -0
- package/MaskedTextBox/MaskedTextBox.js +642 -0
- package/MaskedTextBox/Themes/Default.css +6 -0
- package/Menu/Menu.css +328 -0
- package/Menu/Menu.js +2386 -0
- package/Menu/Themes/Default.css +24 -0
- package/NumericBox/NumericBox.css +120 -0
- package/NumericBox/NumericBox.js +984 -0
- package/PanelBar/PanelBar.css +123 -0
- package/PanelBar/PanelBar.js +505 -0
- package/PanelBar/Themes/Default.css +51 -0
- package/PieChart/PieChart.css +95 -0
- package/PieChart/PieChart.js +820 -0
- package/PieChart/Themes/Default.css +9 -0
- package/README.md +178 -3
- package/Slider/Slider.css +348 -0
- package/Slider/Slider.js +1306 -0
- package/Slider/Themes/Default.css +44 -0
- package/TabStrip/TabStrip.css +52 -0
- package/TabStrip/TabStrip.js +362 -0
- package/TabStrip/Themes/Default.css +35 -0
- package/TimePicker/Themes/Default.css +30 -0
- package/TimePicker/TimePicker.css +253 -0
- package/TimePicker/TimePicker.js +1485 -0
- package/TooltipManager/Themes/Default.css +21 -0
- package/TooltipManager/TooltipManager.css +227 -0
- package/TooltipManager/TooltipManager.js +791 -0
- package/Validator/Validator.css +54 -0
- package/Validator/Validator.js +2508 -0
- package/componyx.html-data.json +619 -0
- package/index.js +27 -0
- package/package.json +43 -4
- package/types/AppSkin.d.ts +842 -0
- package/types/Base.d.ts +1034 -0
- package/types/Bindary.d.ts +1196 -0
- package/types/BookmarkSpy.d.ts +112 -0
- package/types/Box.d.ts +374 -0
- package/types/Button.d.ts +455 -0
- package/types/Carousel.d.ts +136 -0
- package/types/ColorButton.d.ts +120 -0
- package/types/ColorPicker.d.ts +225 -0
- package/types/ComboBox.d.ts +507 -0
- package/types/DataPager.d.ts +152 -0
- package/types/DatePicker.d.ts +354 -0
- package/types/Dialog.d.ts +160 -0
- package/types/Editor.d.ts +1289 -0
- package/types/FileUpload.d.ts +206 -0
- package/types/Form.d.ts +3078 -0
- package/types/FormField.d.ts +204 -0
- package/types/Grid.d.ts +911 -0
- package/types/Library.d.ts +1899 -0
- package/types/MaskedTextBox.d.ts +91 -0
- package/types/Menu.d.ts +577 -0
- package/types/NumericBox.d.ts +310 -0
- package/types/PanelBar.d.ts +223 -0
- package/types/PieChart.d.ts +224 -0
- package/types/ResponsiveTemplates.d.ts +108 -0
- package/types/Slider.d.ts +227 -0
- package/types/TabStrip.d.ts +185 -0
- package/types/TimePicker.d.ts +265 -0
- package/types/TooltipManager.d.ts +178 -0
- package/types/UI.d.ts +29 -0
- package/types/Validator.d.ts +653 -0
- package/types/index.d.ts +59 -0
- package/ui.css +11783 -0
- package/ui.js +79477 -0
- package/ui.min.css +138 -0
- package/ui.min.js +264 -0
- package/ui.min.js.map +1 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
componyx.UI.editor_modules = componyx.UI.editor_modules || {};
|
|
3
|
+
/**
|
|
4
|
+
* SourceViewBuilder module — The source viewer.
|
|
5
|
+
*
|
|
6
|
+
* @class SourceViewBuilder
|
|
7
|
+
* @memberof componyx.UI.editor_modules
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
componyx.UI.editor_modules.SourceViewBuilder = class SourceViewBuilder
|
|
11
|
+
{
|
|
12
|
+
constructor(targetNode, buttonCssClass = '', defTagName = 'span', rootItemText = 'root-item', voidNodeRegEx = null)
|
|
13
|
+
{
|
|
14
|
+
this.targetNode = targetNode;
|
|
15
|
+
this.buttonCssClass = buttonCssClass;
|
|
16
|
+
this.defTagName = defTagName;
|
|
17
|
+
this.rootItemText = rootItemText;
|
|
18
|
+
this.voidNodeRegEx = voidNodeRegEx;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
outerHTML()
|
|
22
|
+
{
|
|
23
|
+
let rootItem = this.targetNode.querySelector('.item.root'),
|
|
24
|
+
tag = $lib.remove(rootItem.querySelector('.tag')),
|
|
25
|
+
content = this.targetNode.textContent;
|
|
26
|
+
|
|
27
|
+
rootItem.insertBefore(tag, rootItem.querySelector('.item')); // restore tag
|
|
28
|
+
return content;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
build(sourceNode)
|
|
32
|
+
{
|
|
33
|
+
this.targetNode.innerHTML = '';
|
|
34
|
+
|
|
35
|
+
let me = this,
|
|
36
|
+
rootItem = $lib.element(this.targetNode, '', '', '', '', { className: 'item root' });
|
|
37
|
+
|
|
38
|
+
rootItem.onclick = me.select.bind(me, rootItem);
|
|
39
|
+
me.createButton(rootItem, { className: this.buttonCssClass, onclick: me.edit.bind(me, rootItem, true) });
|
|
40
|
+
$lib.element(rootItem, '', 'span', this.rootItemText, '', { className: 'tag' });
|
|
41
|
+
me.createEditBox(rootItem, true);
|
|
42
|
+
me.buildSection(sourceNode, rootItem);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
buildSection(sourceNode, targetNode, beforeNode)
|
|
46
|
+
{
|
|
47
|
+
let me = this,
|
|
48
|
+
node = sourceNode.firstChild, nodeType, hasChildElements,
|
|
49
|
+
item, nodeName, tag;
|
|
50
|
+
|
|
51
|
+
while (node)
|
|
52
|
+
{
|
|
53
|
+
nodeType = node.nodeType;
|
|
54
|
+
nodeName = node.nodeName.toLowerCase();
|
|
55
|
+
hasChildElements = node.firstElementChild != null;
|
|
56
|
+
|
|
57
|
+
if (nodeType == 1)
|
|
58
|
+
{
|
|
59
|
+
item = $lib.element(targetNode, beforeNode, '', '', '', { className: 'item' });
|
|
60
|
+
item.onclick = me.select.bind(me, item);
|
|
61
|
+
me.createButton(item, { className: this.buttonCssClass, onclick: me.edit.bind(me, item, false) });
|
|
62
|
+
|
|
63
|
+
if (hasChildElements)
|
|
64
|
+
$lib.element(item, '', this.defTagName, '', '', { className: 'expand', onclick: me.toggleExpand.bind(me, item) });
|
|
65
|
+
else
|
|
66
|
+
item.className += ' childless';
|
|
67
|
+
|
|
68
|
+
me.createEditBox(item, false);
|
|
69
|
+
|
|
70
|
+
tag = $lib.element(item, '', this.defTagName, `<${nodeName}`, '', { className: 'tag' });
|
|
71
|
+
|
|
72
|
+
if (node.hasAttributes())
|
|
73
|
+
me.buildAttributes(node, tag);
|
|
74
|
+
|
|
75
|
+
tag.appendChild(document.createTextNode('>'));
|
|
76
|
+
|
|
77
|
+
if (hasChildElements)
|
|
78
|
+
me.buildSection(node, item);
|
|
79
|
+
else
|
|
80
|
+
this.writeData(node, item);
|
|
81
|
+
|
|
82
|
+
if (node.hasChildNodes() || (!this.voidNodeRegEx || !nodeName.match(this.voidNodeRegEx)))
|
|
83
|
+
tag = $lib.element(item, '', this.defTagName, `</${nodeName}>`, '', { className: 'end-tag' });
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
this.writeData(node, targetNode);
|
|
87
|
+
|
|
88
|
+
node = node.nextSibling;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
createEditBox(item, isRoot)
|
|
93
|
+
{
|
|
94
|
+
$lib.element(item, '', 'span', '', '', {
|
|
95
|
+
className: 'edit-box',
|
|
96
|
+
contentEditable: true,
|
|
97
|
+
spellcheck: false,
|
|
98
|
+
onblur: this.edit.bind(this, item, isRoot)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
writeData(node, targetNode)
|
|
103
|
+
{
|
|
104
|
+
let data = $lib.element(targetNode, '', this.defTagName),
|
|
105
|
+
nodeType = node.nodeType;
|
|
106
|
+
|
|
107
|
+
data.className = (nodeType == 8) ? 'data comment' : 'data';
|
|
108
|
+
data.textContent = (nodeType == 8) ? ` <!-- ${node.textContent} -->` : node.textContent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
buildAttributes(sourceNode, targetNode)
|
|
112
|
+
{
|
|
113
|
+
$lib.each(sourceNode.attributes, (attr) =>
|
|
114
|
+
{
|
|
115
|
+
targetNode.appendChild(document.createTextNode(' '));
|
|
116
|
+
$lib.element(targetNode, '', this.defTagName, attr.name, { class: 'attr-name' });
|
|
117
|
+
targetNode.appendChild(document.createTextNode('="'));
|
|
118
|
+
$lib.element(targetNode, '', this.defTagName, attr.value, { class: 'attr-value' });
|
|
119
|
+
targetNode.appendChild(document.createTextNode('"'));
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
createButton(item, props)
|
|
124
|
+
{
|
|
125
|
+
$lib.element(item, '', 'a', '', '', props);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
toggleExpand(item, e)
|
|
129
|
+
{
|
|
130
|
+
item.classList.toggle('collapsed');
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
select(item, e)
|
|
135
|
+
{
|
|
136
|
+
if (!item)
|
|
137
|
+
return;
|
|
138
|
+
|
|
139
|
+
if (e)
|
|
140
|
+
e.stopPropagation();
|
|
141
|
+
|
|
142
|
+
if (item.classList.contains('edit-mode'))
|
|
143
|
+
return;
|
|
144
|
+
|
|
145
|
+
let selected = this.targetNode.querySelector('.selected');
|
|
146
|
+
|
|
147
|
+
if (selected == item)
|
|
148
|
+
return;
|
|
149
|
+
|
|
150
|
+
if (selected)
|
|
151
|
+
selected.classList.remove('selected', 'edit-mode');
|
|
152
|
+
|
|
153
|
+
item.classList.toggle('selected'); // shows edit button
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
edit(item, isRoot, e)
|
|
157
|
+
{
|
|
158
|
+
let edit = item.querySelector('.edit-box');
|
|
159
|
+
|
|
160
|
+
if (isRoot && this.saved)
|
|
161
|
+
return;
|
|
162
|
+
|
|
163
|
+
e.stopPropagation();
|
|
164
|
+
|
|
165
|
+
if (!item.classList.contains('edit-mode'))
|
|
166
|
+
{
|
|
167
|
+
item.classList.add('edit-mode'); // shows save icon
|
|
168
|
+
|
|
169
|
+
if (isRoot)
|
|
170
|
+
edit.textContent = this.outerHTML();
|
|
171
|
+
else
|
|
172
|
+
edit.textContent = item.textContent;
|
|
173
|
+
|
|
174
|
+
edit.focus();
|
|
175
|
+
}
|
|
176
|
+
else
|
|
177
|
+
{
|
|
178
|
+
item.classList.remove('edit-mode');
|
|
179
|
+
this.save(item, isRoot);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
save(item, isRoot)
|
|
184
|
+
{
|
|
185
|
+
let edit = item.querySelector('.edit-box'),
|
|
186
|
+
parentNode = item.parentNode,
|
|
187
|
+
changedSource = $lib.element({ tag: 'template' });
|
|
188
|
+
|
|
189
|
+
if (isRoot)
|
|
190
|
+
{
|
|
191
|
+
parentNode = item;
|
|
192
|
+
item.querySelectorAll('.item').forEach(e => e.remove());
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
changedSource.innerHTML = edit.textContent;
|
|
196
|
+
edit.textContent = '';
|
|
197
|
+
this.buildSection(changedSource.content, parentNode, (isRoot) ? null : item); // rebuild, use original item as beforeElement
|
|
198
|
+
|
|
199
|
+
if (!isRoot)
|
|
200
|
+
item.remove(); // remove original item
|
|
201
|
+
else
|
|
202
|
+
{ // avoid fireing edit event after save action
|
|
203
|
+
item.firstElementChild.outerHTML = item.firstElementChild.outerHTML;
|
|
204
|
+
item.firstElementChild.onclick = this.edit.bind(this, item, true);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
this.select(isRoot ? item : parentNode.querySelector('.item'));
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
var SourceViewBuilder = componyx.UI.editor_modules.SourceViewBuilder;
|
|
211
|
+
|
|
212
|
+
export { SourceViewBuilder as default };
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
componyx.UI.editor_modules = componyx.UI.editor_modules || {};
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SymbolPicker module — builds and manages a categorised symbol/emoji picker box.
|
|
6
|
+
* One instance is created for emoji symbols and one for special characters.
|
|
7
|
+
*
|
|
8
|
+
* @class SymbolPicker
|
|
9
|
+
* @memberof componyx.UI.editor_modules
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
componyx.UI.editor_modules.SymbolPicker = class SymbolPicker
|
|
13
|
+
{
|
|
14
|
+
/**
|
|
15
|
+
* @param {componyx.UI.Editor} editor The editor instance.
|
|
16
|
+
* @param {string} cloneId Id of the base Box component to clone from.
|
|
17
|
+
* @param {string} id Id that will be given to the new Box.
|
|
18
|
+
* @param {string} pickerCssClass Extra CSS class for the picker box.
|
|
19
|
+
* @param {string[]} catLabels Display labels for every category (index 0 = "All").
|
|
20
|
+
* @param {Array} symbols Category data: [{name, values:[{value, name}]}].
|
|
21
|
+
*/
|
|
22
|
+
constructor(editor, cloneId, id, pickerCssClass, catLabels, symbols)
|
|
23
|
+
{
|
|
24
|
+
this.editor = editor;
|
|
25
|
+
this.cf = editor.componentFactory;
|
|
26
|
+
this.symbols = symbols;
|
|
27
|
+
this.selectedCategory = undefined;
|
|
28
|
+
this.searchFilter = '';
|
|
29
|
+
|
|
30
|
+
this.categoriesEl = null;
|
|
31
|
+
this.symbolViewEl = null;
|
|
32
|
+
this.headerEl = null;
|
|
33
|
+
this.searchEl = null;
|
|
34
|
+
this.symbolsEl = null;
|
|
35
|
+
this.footerEl = null;
|
|
36
|
+
this.nameEl = null;
|
|
37
|
+
|
|
38
|
+
this.box = this.#createBox(id, cloneId, pickerCssClass, catLabels, symbols);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Shows the picker box anchored to the toolbar button for the given command.
|
|
43
|
+
* @param {Object} cmd The command settings object (must have an `id` property).
|
|
44
|
+
*/
|
|
45
|
+
show(cmd)
|
|
46
|
+
{
|
|
47
|
+
const button = $UI.store[this.editor.utility.getId(cmd.id)];
|
|
48
|
+
this.box.expander = button.element;
|
|
49
|
+
this.box.show();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Builds the DOM and Box component.
|
|
54
|
+
*/
|
|
55
|
+
#createBox(id, cloneId, pickerCssClass, catLabels, symbols)
|
|
56
|
+
{
|
|
57
|
+
const editor = this.editor,
|
|
58
|
+
co = editor.classOption;
|
|
59
|
+
|
|
60
|
+
this.categoriesEl = $lib.element('', '', '', '', { class: editor.getCssClass(co.SYMBOL_CATEGORIES) });
|
|
61
|
+
this.symbolViewEl = $lib.element('', '', '', '', { class: editor.getCssClass(co.SYMBOL_VIEW) });
|
|
62
|
+
this.headerEl = $lib.element(this.symbolViewEl, '', 'header', '', { class: editor.getCssClass(co.SYMBOL_HEADER) });
|
|
63
|
+
|
|
64
|
+
this.searchEl = $lib.element(
|
|
65
|
+
this.headerEl, '', 'input', '',
|
|
66
|
+
{ type: 'text', placeholder: editor.labels.symbolSearchInputPlaceholder },
|
|
67
|
+
{
|
|
68
|
+
onfocus: () => { editor.eventManager.disposeEvents(); },
|
|
69
|
+
onblur: () => { editor.eventManager.bindEvents(); },
|
|
70
|
+
oninput: this.#renderCategory.bind(this)
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
this.symbolsEl = $lib.element(this.symbolViewEl, '', '', '', { class: editor.getCssClass(co.SYMBOL_ITEMS) });
|
|
75
|
+
this.footerEl = $lib.element(this.symbolViewEl, '', 'footer', '', { class: editor.getCssClass(co.SYMBOL_FOOTER) });
|
|
76
|
+
this.nameEl = $lib.element(this.footerEl, '', 'span');
|
|
77
|
+
|
|
78
|
+
// "All" category link
|
|
79
|
+
$lib.element(this.categoriesEl, '', 'a', catLabels[0], { class: editor.getCssClass(co.SYMBOL_CATEGORY) }, { onclick: this.#selectCategory.bind(this, null) });
|
|
80
|
+
|
|
81
|
+
// Per-category links
|
|
82
|
+
$lib.each(symbols, (cat, index) =>
|
|
83
|
+
{
|
|
84
|
+
$lib.element(this.categoriesEl, '', 'a', catLabels[index + 1] || cat.name, { class: editor.getCssClass(co.SYMBOL_CATEGORY) }, { onclick: this.#selectCategory.bind(this, index) });
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const cssClass = editor.getCssClass(co.SYMBOL_PICKER_BOX) + ' ' + pickerCssClass;
|
|
88
|
+
const box = this.cf.createBox(id, cloneId, editor.element, { cssClass: cssClass, content: [this.categoriesEl, this.symbolViewEl] });
|
|
89
|
+
box.animation.showType = box.animation.hideType = 0;
|
|
90
|
+
box.events.onShowComplete.priorityAdd(() => { this.#onShow(); });
|
|
91
|
+
box.events.onHideComplete.priorityAdd(() => { this.#onHide(); });
|
|
92
|
+
|
|
93
|
+
box.render();
|
|
94
|
+
return box;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Selects a category index (null = all) and re-renders the symbol grid.
|
|
99
|
+
* @param {number|null} cat
|
|
100
|
+
*/
|
|
101
|
+
#selectCategory(cat)
|
|
102
|
+
{
|
|
103
|
+
if (cat === undefined)
|
|
104
|
+
this.selectedCategory = cat = null;
|
|
105
|
+
else if (cat === this.selectedCategory && this.searchFilter === this.searchEl.value)
|
|
106
|
+
return;
|
|
107
|
+
|
|
108
|
+
this.selectedCategory = cat;
|
|
109
|
+
this.#renderCategory();
|
|
110
|
+
this.#updateActiveCategory();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#updateActiveCategory()
|
|
114
|
+
{
|
|
115
|
+
const activeCssClass = this.editor.getCssClass(this.editor.classOption.ACTIVE);
|
|
116
|
+
const catCssClass = this.editor.getCssClass(this.editor.classOption.SYMBOL_CATEGORY);
|
|
117
|
+
const index = this.selectedCategory === null ? 0 : this.selectedCategory + 1;
|
|
118
|
+
|
|
119
|
+
this.categoriesEl.querySelectorAll(`.${catCssClass}`).forEach((el, i) =>
|
|
120
|
+
el.classList.toggle(activeCssClass, i === index));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* (Re-)renders the symbol grid, applying the current category filter and search term.
|
|
125
|
+
*/
|
|
126
|
+
#renderCategory()
|
|
127
|
+
{
|
|
128
|
+
const selCat = this.selectedCategory,
|
|
129
|
+
co = this.editor.classOption;
|
|
130
|
+
|
|
131
|
+
this.searchFilter = this.searchEl.value.toLowerCase();
|
|
132
|
+
this.symbolsEl.innerHTML = '';
|
|
133
|
+
|
|
134
|
+
$lib.each(this.symbols, (cat, index) =>
|
|
135
|
+
{
|
|
136
|
+
if (selCat != null && selCat !== index)
|
|
137
|
+
return;
|
|
138
|
+
|
|
139
|
+
$lib.each(cat.values, (symbol) =>
|
|
140
|
+
{
|
|
141
|
+
if (!this.searchFilter || (symbol.name || '').toLowerCase().includes(this.searchFilter))
|
|
142
|
+
{
|
|
143
|
+
$lib.element(
|
|
144
|
+
this.symbolsEl, '', 'a', symbol.value,
|
|
145
|
+
{ class: this.editor.getCssClass(co.SYMBOL), title: symbol.name },
|
|
146
|
+
{
|
|
147
|
+
onpointerover: this.#showInfo.bind(this, symbol),
|
|
148
|
+
onfocus: this.#showInfo.bind(this, symbol),
|
|
149
|
+
onclick: this.#selectSymbol.bind(this, symbol)
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (selCat != null)
|
|
156
|
+
return false; // stop after the selected category
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#onShow()
|
|
161
|
+
{
|
|
162
|
+
const sr = this.editor.selectionRange;
|
|
163
|
+
this.editor.storeRange(sr.ensureTextRange(sr.getRange()).cloneRange());
|
|
164
|
+
this.searchEl.value = '';
|
|
165
|
+
this.#selectCategory(this.selectedCategory);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#onHide()
|
|
169
|
+
{
|
|
170
|
+
const stored = this.editor.getStoredRange(),
|
|
171
|
+
current = this.editor.selectionRange.getRange();
|
|
172
|
+
|
|
173
|
+
if (stored !== current)
|
|
174
|
+
this.editor.selectionRange.restoreRange(stored);
|
|
175
|
+
|
|
176
|
+
setTimeout(() => { this.editor.getEditorElement().focus(); }, 0);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#showInfo(symbol)
|
|
180
|
+
{
|
|
181
|
+
this.nameEl.textContent = symbol.name;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#selectSymbol(symbol, e)
|
|
185
|
+
{
|
|
186
|
+
const editor = this.editor;
|
|
187
|
+
|
|
188
|
+
editor.activateDocument();
|
|
189
|
+
|
|
190
|
+
if (!editor.contentManager.hasContent())
|
|
191
|
+
editor.contentManager.insertParagraph();
|
|
192
|
+
|
|
193
|
+
const node = editor.getDoc().createTextNode(symbol.value);
|
|
194
|
+
|
|
195
|
+
editor.contentManager.insertHTML({ node });
|
|
196
|
+
|
|
197
|
+
const sr = editor.selectionRange,
|
|
198
|
+
range = sr.ensureTextRange(sr.getRange());
|
|
199
|
+
|
|
200
|
+
editor.storeRange(range);
|
|
201
|
+
this.box.hide();
|
|
202
|
+
editor.toolbar.hideBoxes(e);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
var SymbolPicker = componyx.UI.editor_modules.SymbolPicker;
|
|
207
|
+
|
|
208
|
+
export { SymbolPicker as default };
|