alchemy-widget 0.1.6 → 0.2.0
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/CHANGELOG.md +9 -0
- package/assets/stylesheets/{alchemy-widgets.scss → alchemy_widgets.scss} +158 -48
- package/bootstrap.js +4 -2
- package/element/00-widget_base_element.js +96 -4
- package/element/05-widget_element.js +4 -13
- package/element/10-container_elements.js +15 -15
- package/element/11-alchemy_widgets_list_element.js +2 -2
- package/element/20-add_area_element.js +22 -22
- package/element/table_of_contents_element.js +104 -8
- package/element/widget_actionbar_element.js +92 -0
- package/element/widget_context_element.js +39 -23
- package/element/widget_toolbar_element.js +295 -50
- package/helper/widget_action.js +10 -10
- package/helper/widgets/00-widget.js +54 -18
- package/helper/widgets/01-container.js +7 -7
- package/helper/widgets/05-list.js +1 -1
- package/helper/widgets/alchemy_field_widget.js +112 -0
- package/helper/widgets/alchemy_form_widget.js +183 -0
- package/helper/widgets/alchemy_table_widget.js +71 -0
- package/helper/widgets/alchemy_tabs_widget.js +195 -0
- package/helper/widgets/header.js +3 -3
- package/helper/widgets/markdown.js +17 -10
- package/helper/widgets/sourcecode.js +4 -4
- package/helper/widgets/table_of_contents.js +2 -2
- package/helper/widgets_helper.js +26 -0
- package/package.json +3 -2
- package/view/elements/table_of_contents.hwk +23 -9
- package/view/form/inputs/edit/widget.hwk +2 -2
- package/view/form/inputs/edit/widgets.hwk +2 -2
- package/view/widget/elements/al_widget_toolbar.hwk +49 -0
- package/view/widget/widget_config.hwk +7 -4
- package/assets/stylesheets/alchemy-widget-symbols.scss +0 -191
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Field Widget class
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.0
|
|
8
|
+
* @version 0.1.0
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} data
|
|
11
|
+
*/
|
|
12
|
+
const AlchemyField = Function.inherits('Alchemy.Widget', 'AlchemyField');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Prepare the schema
|
|
16
|
+
*
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
* @version 0.1.12
|
|
20
|
+
*/
|
|
21
|
+
AlchemyField.constitute(function prepareSchema() {
|
|
22
|
+
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Find the al-form parent
|
|
30
|
+
*
|
|
31
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
32
|
+
* @since 0.1.4
|
|
33
|
+
* @version 0.2.0
|
|
34
|
+
*/
|
|
35
|
+
AlchemyField.enforceProperty(function alchemy_form(new_value) {
|
|
36
|
+
|
|
37
|
+
if (!new_value && this.config && this.config.alchemy_form) {
|
|
38
|
+
new_value = this.config.alchemy_form;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!new_value) {
|
|
42
|
+
|
|
43
|
+
let parent = this.parent_instance;
|
|
44
|
+
|
|
45
|
+
while (parent) {
|
|
46
|
+
|
|
47
|
+
new_value = parent.alchemy_form;
|
|
48
|
+
|
|
49
|
+
if (new_value) {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (parent.element) {
|
|
54
|
+
new_value = parent.element.querySelector('al-form');
|
|
55
|
+
|
|
56
|
+
if (new_value) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
parent = parent.parent_instance;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return new_value;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Populate the widget
|
|
70
|
+
*
|
|
71
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
72
|
+
* @since 0.1.0
|
|
73
|
+
* @version 0.2.0
|
|
74
|
+
*/
|
|
75
|
+
AlchemyField.setMethod(function populateWidget() {
|
|
76
|
+
|
|
77
|
+
let config = this.config;
|
|
78
|
+
|
|
79
|
+
let alchemy_form = this.alchemy_form;
|
|
80
|
+
|
|
81
|
+
let field_el = this.createElement('al-field');
|
|
82
|
+
|
|
83
|
+
if (alchemy_form) {
|
|
84
|
+
field_el.alchemy_form = alchemy_form;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
field_el.field_name = config.field;
|
|
88
|
+
|
|
89
|
+
field_el.applyOptions(config);
|
|
90
|
+
|
|
91
|
+
this.element.append(field_el);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get the config of this widget
|
|
96
|
+
*
|
|
97
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
98
|
+
* @since 0.1.0
|
|
99
|
+
* @version 0.1.0
|
|
100
|
+
*
|
|
101
|
+
* @return {Object}
|
|
102
|
+
*/
|
|
103
|
+
AlchemyField.setMethod(function syncConfig() {
|
|
104
|
+
|
|
105
|
+
let config = this.config;
|
|
106
|
+
|
|
107
|
+
if (!config) {
|
|
108
|
+
config = this.config = {};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return this.config;
|
|
112
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Form Widget class
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.0
|
|
8
|
+
* @version 0.1.0
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} data
|
|
11
|
+
*/
|
|
12
|
+
const AlchemyForm = Function.inherits('Alchemy.Widget', 'AlchemyForm');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Prepare the schema
|
|
16
|
+
*
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
|
+
* @since 0.1.12
|
|
19
|
+
* @version 0.1.12
|
|
20
|
+
*/
|
|
21
|
+
AlchemyForm.constitute(function prepareSchema() {
|
|
22
|
+
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Populate the widget
|
|
30
|
+
*
|
|
31
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
* @version 0.2.0
|
|
34
|
+
*/
|
|
35
|
+
AlchemyForm.setMethod(function populateWidget() {
|
|
36
|
+
|
|
37
|
+
let config = this.config,
|
|
38
|
+
form = this.createElement('al-form');
|
|
39
|
+
|
|
40
|
+
let col_el = this.createElement('al-widgets-column'),
|
|
41
|
+
col = col_el.instance;
|
|
42
|
+
|
|
43
|
+
col.parent_instance = this;
|
|
44
|
+
|
|
45
|
+
form.classList.add('al-widgets-container');
|
|
46
|
+
|
|
47
|
+
if (config.purpose) {
|
|
48
|
+
form.purpose = config.purpose;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (config.mode) {
|
|
52
|
+
form.mode = config.mode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this.config && this.config.widgets) {
|
|
56
|
+
let widgets = this.config.widgets.slice(0),
|
|
57
|
+
widget,
|
|
58
|
+
i;
|
|
59
|
+
|
|
60
|
+
for (i = 0; i < widgets.length; i++) {
|
|
61
|
+
widget = widgets[i];
|
|
62
|
+
|
|
63
|
+
if (widget.type == 'alchemy_field') {
|
|
64
|
+
widget = Object.assign({}, widget);
|
|
65
|
+
widget.config = Object.assign({}, widget.config);
|
|
66
|
+
widget.config.alchemy_form = form;
|
|
67
|
+
widgets[i] = widget;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
col.widget.value = widgets;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let record = this.element.getContextVariable('record');
|
|
75
|
+
|
|
76
|
+
if (record) {
|
|
77
|
+
form.document = record;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (config.model) {
|
|
81
|
+
form.model = config.model;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (config.view_type) {
|
|
85
|
+
form.view_type = config.view_type;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
form.append(col.widget);
|
|
89
|
+
|
|
90
|
+
this.element.append(form);
|
|
91
|
+
|
|
92
|
+
let violations = this.element.getContextVariable('form_violations');
|
|
93
|
+
|
|
94
|
+
if (violations) {
|
|
95
|
+
form.showError(violations);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get the nested column
|
|
101
|
+
*
|
|
102
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
103
|
+
* @since 0.1.0
|
|
104
|
+
* @version 0.2.0
|
|
105
|
+
*/
|
|
106
|
+
AlchemyForm.setMethod(function getNestedColumn(widget) {
|
|
107
|
+
|
|
108
|
+
if (!widget) {
|
|
109
|
+
widget = this.widget;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!widget) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let col = widget.querySelector('al-form > al-widgets-column');
|
|
117
|
+
|
|
118
|
+
return col;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Start the editor
|
|
123
|
+
*
|
|
124
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
125
|
+
* @since 0.1.0
|
|
126
|
+
* @version 0.1.0
|
|
127
|
+
*/
|
|
128
|
+
AlchemyForm.setMethod(function _startEditor() {
|
|
129
|
+
|
|
130
|
+
let col = this.getNestedColumn();
|
|
131
|
+
|
|
132
|
+
if (!col) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
col.startEditor();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Stop the editor
|
|
141
|
+
*
|
|
142
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
143
|
+
* @since 0.1.0
|
|
144
|
+
* @version 0.1.0
|
|
145
|
+
*/
|
|
146
|
+
AlchemyForm.setMethod(function _stopEditor() {
|
|
147
|
+
|
|
148
|
+
let col = this.getNestedColumn();
|
|
149
|
+
|
|
150
|
+
if (!col) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
col.stopEditor();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get the config of this widget
|
|
159
|
+
*
|
|
160
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
161
|
+
* @since 0.1.0
|
|
162
|
+
* @version 0.1.0
|
|
163
|
+
*
|
|
164
|
+
* @return {Object}
|
|
165
|
+
*/
|
|
166
|
+
AlchemyForm.setMethod(function syncConfig() {
|
|
167
|
+
|
|
168
|
+
let config = this.config;
|
|
169
|
+
|
|
170
|
+
if (!config) {
|
|
171
|
+
config = this.config = {};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let col = this.getNestedColumn();
|
|
175
|
+
|
|
176
|
+
if (col) {
|
|
177
|
+
config.widgets = col.instance.syncConfig();
|
|
178
|
+
} else {
|
|
179
|
+
config.widgets = [];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return this.config;
|
|
183
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Table Widget class
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.1.0
|
|
8
|
+
* @version 0.1.0
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} data
|
|
11
|
+
*/
|
|
12
|
+
const AlchemyTable = Function.inherits('Alchemy.Widget', 'AlchemyTable');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Prepare the schema
|
|
16
|
+
*
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
|
+
* @since 0.1.12
|
|
19
|
+
* @version 0.1.12
|
|
20
|
+
*/
|
|
21
|
+
AlchemyTable.constitute(function prepareSchema() {
|
|
22
|
+
|
|
23
|
+
this.setAddChecker(function(widget_element) {
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Populate the widget
|
|
30
|
+
*
|
|
31
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
* @version 0.2.0
|
|
34
|
+
*/
|
|
35
|
+
AlchemyTable.setMethod(function populateWidget() {
|
|
36
|
+
|
|
37
|
+
let table = this.createElement('al-table'),
|
|
38
|
+
config = this.config;
|
|
39
|
+
|
|
40
|
+
if (config.id) {
|
|
41
|
+
table.id = config.id;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Always enable the actions?
|
|
45
|
+
table.has_actions = true;
|
|
46
|
+
|
|
47
|
+
if (config.fieldset) {
|
|
48
|
+
table.fieldset = config.fieldset;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (config.page_size) {
|
|
52
|
+
table.page_size = config.page_size;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (config.show_filters) {
|
|
56
|
+
table.show_filters = config.show_filters;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (config.recordsource) {
|
|
60
|
+
table.recordsource = config.recordsource;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (config.use_url_pagination) {
|
|
64
|
+
table.use_url_pagination = config.use_url_pagination;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
table.purpose = config.purpose || 'view';
|
|
68
|
+
table.mode = config.mode || 'inline';
|
|
69
|
+
|
|
70
|
+
this.element.append(table);
|
|
71
|
+
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Widget Tabs class
|
|
3
|
+
*
|
|
4
|
+
* @constructor
|
|
5
|
+
*
|
|
6
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
|
+
* @since 0.2.0
|
|
8
|
+
* @version 0.2.0
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} data
|
|
11
|
+
*/
|
|
12
|
+
const Tabs = Function.inherits('Alchemy.Widget', 'AlchemyTabs');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Prepare the schema
|
|
16
|
+
*
|
|
17
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
|
+
* @since 0.2.0
|
|
19
|
+
* @version 0.2.0
|
|
20
|
+
*/
|
|
21
|
+
Tabs.constitute(function prepareSchema() {
|
|
22
|
+
|
|
23
|
+
let tab_entry = alchemy.createSchema();
|
|
24
|
+
|
|
25
|
+
tab_entry.addField('name', 'String', {
|
|
26
|
+
title : 'Tab Name',
|
|
27
|
+
description : 'Used as the Tab\'s ID',
|
|
28
|
+
widget_config_editable : true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
tab_entry.addField('title', 'String', {
|
|
32
|
+
title : 'Tab Title',
|
|
33
|
+
description : 'Used in the navigation menu',
|
|
34
|
+
widget_config_editable : true,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
tab_entry.addField('icon', 'String', {
|
|
38
|
+
title : 'Tab Icon',
|
|
39
|
+
description : 'Optional icon to use in the navigation menu',
|
|
40
|
+
widget_config_editable : true,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
tab_entry.addField('contents', 'Widgets', {
|
|
44
|
+
widget_config_editable : false,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.schema.addField('tabs', tab_entry, {
|
|
48
|
+
widget_config_editable : true,
|
|
49
|
+
array: true,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get the config of this widget
|
|
55
|
+
*
|
|
56
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
57
|
+
* @since 0.2.0
|
|
58
|
+
* @version 0.2.0
|
|
59
|
+
*
|
|
60
|
+
* @return {Object}
|
|
61
|
+
*/
|
|
62
|
+
Tabs.setMethod(function syncConfig() {
|
|
63
|
+
|
|
64
|
+
const config = this.config || {},
|
|
65
|
+
tabs = config.tabs || [],
|
|
66
|
+
widgets = this.getSubWidgets();
|
|
67
|
+
|
|
68
|
+
for (let tab_config of tabs) {
|
|
69
|
+
|
|
70
|
+
if (!tab_config.name) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let widget = widgets[tab_config.name];
|
|
75
|
+
|
|
76
|
+
tab_config.contents = widget?.value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return this.config;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Populate the widget
|
|
85
|
+
*
|
|
86
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
87
|
+
* @since 0.2.0
|
|
88
|
+
* @version 0.2.0
|
|
89
|
+
*
|
|
90
|
+
* @param {HTMLElement} widget
|
|
91
|
+
*/
|
|
92
|
+
Tabs.setMethod(function populateWidget() {
|
|
93
|
+
|
|
94
|
+
const config = this.config || {},
|
|
95
|
+
tabs = config.tabs || [];
|
|
96
|
+
|
|
97
|
+
let wrapper = this.createElement('al-tab-context'),
|
|
98
|
+
tablist = this.createElement('al-tab-list');
|
|
99
|
+
|
|
100
|
+
wrapper.append(tablist);
|
|
101
|
+
|
|
102
|
+
for (let tab_config of tabs) {
|
|
103
|
+
|
|
104
|
+
if (!tab_config?.name) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let tab_button = this.createElement('al-tab-button');
|
|
109
|
+
tab_button.tab_name = tab_config.name;
|
|
110
|
+
tab_button.id = 'tab-' + tab_config.name;
|
|
111
|
+
|
|
112
|
+
if (tab_config.icon) {
|
|
113
|
+
let ico = this.createElement('al-icon');
|
|
114
|
+
ico.icon_name = tab_config.icon;
|
|
115
|
+
tab_button.append(ico);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let span = this.createElement('span');
|
|
119
|
+
span.textContent = tab_config.title;
|
|
120
|
+
tab_button.append(span);
|
|
121
|
+
|
|
122
|
+
tablist.append(tab_button);
|
|
123
|
+
|
|
124
|
+
let tab_content = this.createElement('al-tab-panel');
|
|
125
|
+
tab_content.tab_name = tab_config.name;
|
|
126
|
+
wrapper.append(tab_content);
|
|
127
|
+
|
|
128
|
+
let widgets = this.createElement('al-widgets');
|
|
129
|
+
widgets.value = tab_config.contents;
|
|
130
|
+
widgets.setAttribute('data-tab-name', tab_config.name);
|
|
131
|
+
|
|
132
|
+
tab_content.append(widgets);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
Hawkejs.replaceChildren(this.widget, wrapper);
|
|
136
|
+
|
|
137
|
+
return populateWidget.super.call(this);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get all the sub widgets
|
|
142
|
+
*
|
|
143
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
144
|
+
* @since 0.2.0
|
|
145
|
+
* @version 0.2.0
|
|
146
|
+
*
|
|
147
|
+
* @return {Object}
|
|
148
|
+
*/
|
|
149
|
+
Tabs.setMethod(function getSubWidgets() {
|
|
150
|
+
|
|
151
|
+
let elements = this.widget.queryAllNotNested('al-widgets[data-tab-name]'),
|
|
152
|
+
result = {};
|
|
153
|
+
|
|
154
|
+
for (let element of elements) {
|
|
155
|
+
result[element.dataset.tabName] = element;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return result;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Start the editor
|
|
163
|
+
*
|
|
164
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
165
|
+
* @since 0.2.0
|
|
166
|
+
* @version 0.2.0
|
|
167
|
+
*/
|
|
168
|
+
Tabs.setMethod(function _startEditor() {
|
|
169
|
+
|
|
170
|
+
let sub_widgets = this.getSubWidgets();
|
|
171
|
+
|
|
172
|
+
for (let name in sub_widgets) {
|
|
173
|
+
let sub_widget = sub_widgets[name];
|
|
174
|
+
sub_widget.startEditor();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Stop the editor
|
|
180
|
+
*
|
|
181
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
182
|
+
* @since 0.2.0
|
|
183
|
+
* @version 0.2.0
|
|
184
|
+
*/
|
|
185
|
+
Tabs.setMethod(function _stopEditor() {
|
|
186
|
+
|
|
187
|
+
let sub_widgets = this.getSubWidgets();
|
|
188
|
+
|
|
189
|
+
for (let name in sub_widgets) {
|
|
190
|
+
let sub_widget = sub_widgets[name];
|
|
191
|
+
sub_widget.stopEditor();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this.populateWidget();
|
|
195
|
+
});
|
package/helper/widgets/header.js
CHANGED
|
@@ -43,7 +43,7 @@ Header.constitute(function addActions() {
|
|
|
43
43
|
for (let level of levels) {
|
|
44
44
|
let level_action = this.createAction('make-level-' + level, 'Level ' + level);
|
|
45
45
|
|
|
46
|
-
level_action.setHandler(function setLevelAction(widget, handle,
|
|
46
|
+
level_action.setHandler(function setLevelAction(widget, handle, actionbar) {
|
|
47
47
|
|
|
48
48
|
let content = widget.querySelector(query);
|
|
49
49
|
|
|
@@ -54,8 +54,8 @@ Header.constitute(function addActions() {
|
|
|
54
54
|
widget.instance.config.level = level;
|
|
55
55
|
widget.instance.rerender();
|
|
56
56
|
|
|
57
|
-
// Rerender the
|
|
58
|
-
|
|
57
|
+
// Rerender the actionbar
|
|
58
|
+
actionbar.showWidgetActions(widget);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
level_action.setIcon({html: '<span class="aw-header-h">H</span><span class="aw-header-level">' + level + '</span>'});
|
|
@@ -54,17 +54,21 @@ Markdown.setMethod(function populateWidget() {
|
|
|
54
54
|
*
|
|
55
55
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
56
56
|
* @since 0.1.0
|
|
57
|
-
* @version 0.
|
|
57
|
+
* @version 0.2.0
|
|
58
58
|
*/
|
|
59
|
-
Markdown.setMethod(function _startEditor() {
|
|
59
|
+
Markdown.setMethod(async function _startEditor() {
|
|
60
60
|
|
|
61
61
|
Hawkejs.removeChildren(this.widget);
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
hawkejs.scene.enableStyle('https://unpkg.com/easymde/dist/easymde.min.css');
|
|
64
|
+
await hawkejs.require('https://unpkg.com/easymde/dist/easymde.min.js');
|
|
65
|
+
|
|
66
|
+
let element = this.createElement('textarea');
|
|
67
|
+
this.widget.append(element);
|
|
68
|
+
element.value = this.config.markdown || '';
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
const easyMDE = new EasyMDE({element});
|
|
71
|
+
this.easy_mde = easyMDE;
|
|
68
72
|
});
|
|
69
73
|
|
|
70
74
|
/**
|
|
@@ -77,6 +81,7 @@ Markdown.setMethod(function _startEditor() {
|
|
|
77
81
|
Markdown.setMethod(function _stopEditor() {
|
|
78
82
|
|
|
79
83
|
Hawkejs.removeChildren(this.widget);
|
|
84
|
+
this.easy_mde = null;
|
|
80
85
|
|
|
81
86
|
this.populateWidget();
|
|
82
87
|
});
|
|
@@ -86,17 +91,19 @@ Markdown.setMethod(function _stopEditor() {
|
|
|
86
91
|
*
|
|
87
92
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
88
93
|
* @since 0.1.0
|
|
89
|
-
* @version 0.
|
|
94
|
+
* @version 0.2.0
|
|
90
95
|
*
|
|
91
96
|
* @return {Object}
|
|
92
97
|
*/
|
|
93
98
|
Markdown.setMethod(function syncConfig() {
|
|
94
99
|
|
|
95
|
-
let
|
|
100
|
+
let value = '';
|
|
96
101
|
|
|
97
|
-
if (
|
|
98
|
-
|
|
102
|
+
if (this.easy_mde) {
|
|
103
|
+
value = this.easy_mde.value();
|
|
99
104
|
}
|
|
100
105
|
|
|
106
|
+
this.config.markdown = value;
|
|
107
|
+
|
|
101
108
|
return this.config;
|
|
102
109
|
});
|
|
@@ -65,13 +65,13 @@ Sourcecode.setMethod(function populateWidget() {
|
|
|
65
65
|
*
|
|
66
66
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
67
67
|
* @since 0.1.0
|
|
68
|
-
* @version 0.
|
|
68
|
+
* @version 0.2.0
|
|
69
69
|
*/
|
|
70
70
|
Sourcecode.setMethod(function _startEditor() {
|
|
71
71
|
|
|
72
72
|
Hawkejs.removeChildren(this.widget);
|
|
73
73
|
|
|
74
|
-
let input = this.createElement('
|
|
74
|
+
let input = this.createElement('al-code-input');
|
|
75
75
|
input.textContent = this.config[this.sourcecode_field] || '';
|
|
76
76
|
|
|
77
77
|
this.widget.append(input);
|
|
@@ -96,13 +96,13 @@ Sourcecode.setMethod(function _stopEditor() {
|
|
|
96
96
|
*
|
|
97
97
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
98
98
|
* @since 0.1.0
|
|
99
|
-
* @version 0.
|
|
99
|
+
* @version 0.2.0
|
|
100
100
|
*
|
|
101
101
|
* @return {Object}
|
|
102
102
|
*/
|
|
103
103
|
Sourcecode.setMethod(function syncConfig() {
|
|
104
104
|
|
|
105
|
-
let input = this.widget.querySelector('
|
|
105
|
+
let input = this.widget.querySelector('al-code-input, textarea');
|
|
106
106
|
|
|
107
107
|
if (input) {
|
|
108
108
|
this.config[this.sourcecode_field] = input.value;
|
|
@@ -16,13 +16,13 @@ const Toc = Function.inherits('Alchemy.Widget', 'TableOfContents');
|
|
|
16
16
|
*
|
|
17
17
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
18
18
|
* @since 0.1.2
|
|
19
|
-
* @version 0.
|
|
19
|
+
* @version 0.2.0
|
|
20
20
|
*/
|
|
21
21
|
Toc.setMethod(function populateWidget() {
|
|
22
22
|
|
|
23
23
|
populateWidget.super.call(this);
|
|
24
24
|
|
|
25
|
-
let toc = this.createElement('
|
|
25
|
+
let toc = this.createElement('al-toc');
|
|
26
26
|
|
|
27
27
|
if (this.config.parent_selector) {
|
|
28
28
|
toc.parent_selector = this.config.parent_selector;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Widgets helper
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 0.2.0
|
|
7
|
+
*
|
|
8
|
+
* @param {ViewRender} view
|
|
9
|
+
*/
|
|
10
|
+
const Widgets = Function.inherits('Alchemy.Helper', 'Widgets');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Function to execute on the client side, when the scene is made
|
|
14
|
+
*
|
|
15
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
16
|
+
* @since 0.2.0
|
|
17
|
+
* @version 0.2.0
|
|
18
|
+
*
|
|
19
|
+
* @param {Scene} scene
|
|
20
|
+
* @param {Object} options
|
|
21
|
+
*/
|
|
22
|
+
Widgets.setStatic(function onScene(scene, options) {
|
|
23
|
+
Blast.setImmediate(() => {
|
|
24
|
+
Classes.Alchemy.Element.Widget.WidgetToolbar.show();
|
|
25
|
+
});
|
|
26
|
+
});
|