alchemy-widget 0.2.6 → 0.2.8
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 +10 -0
- package/README.md +0 -0
- package/assets/stylesheets/alchemy_widgets.scss +72 -0
- package/bootstrap.js +0 -0
- package/controller/alchemy_widgets_controller.js +0 -0
- package/element/00-widget_base_element.js +0 -0
- package/element/05-widget_element.js +0 -0
- package/element/10-container_elements.js +0 -0
- package/element/11-alchemy_widgets_list_element.js +0 -0
- package/element/20-add_area_element.js +0 -0
- package/element/30-base_toolbar_element.js +231 -0
- package/element/editor_toolbar_element.js +30 -0
- package/element/table_of_contents_element.js +0 -0
- package/element/user_avatar_element.js +137 -0
- package/element/user_avatar_group_element.js +131 -0
- package/element/widget_actionbar_element.js +0 -0
- package/element/widget_context_element.js +0 -0
- package/element/widget_toolbar_element.js +40 -20
- package/helper/document_watcher.js +284 -0
- package/helper/editor_toolbar_manager.js +296 -0
- package/helper/widget_action.js +0 -0
- package/helper/widgets/00-widget.js +3 -3
- package/helper/widgets/01-container.js +0 -0
- package/helper/widgets/05-column.js +0 -0
- package/helper/widgets/05-list.js +0 -0
- package/helper/widgets/05-row.js +0 -0
- package/helper/widgets/alchemy_field_widget.js +0 -0
- package/helper/widgets/alchemy_form_widget.js +0 -0
- package/helper/widgets/alchemy_table_widget.js +0 -0
- package/helper/widgets/alchemy_tabs_widget.js +0 -0
- package/helper/widgets/hawkejs_template.js +0 -0
- package/helper/widgets/header.js +0 -0
- package/helper/widgets/html.js +0 -0
- package/helper/widgets/markdown.js +65 -11
- package/helper/widgets/partial.js +0 -0
- package/helper/widgets/sourcecode.js +0 -0
- package/helper/widgets/table_of_contents.js +0 -0
- package/helper/widgets/text.js +0 -0
- package/helper/widgets_helper.js +0 -0
- package/helper_field/widget.js +0 -0
- package/helper_field/widgets.js +0 -0
- package/lib/conduit_extras.js +65 -0
- package/package.json +3 -3
- package/view/elements/table_of_contents.hwk +0 -0
- package/view/form/inputs/edit/widget.hwk +0 -0
- package/view/form/inputs/edit/widgets.hwk +0 -0
- package/view/widget/elements/al_editor_toolbar.hwk +3 -0
- package/view/widget/elements/al_user_avatar.hwk +5 -0
- package/view/widget/elements/al_widget_toolbar.hwk +7 -1
- package/view/widget/widget_config.hwk +0 -0
|
@@ -52,12 +52,68 @@ Markdown.setMethod(function populateWidget() {
|
|
|
52
52
|
*
|
|
53
53
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
54
54
|
* @since 0.1.0
|
|
55
|
-
* @version 0.2.
|
|
55
|
+
* @version 0.2.7
|
|
56
56
|
*/
|
|
57
57
|
Markdown.setMethod(async function _startEditor() {
|
|
58
58
|
|
|
59
59
|
Hawkejs.removeChildren(this.widget);
|
|
60
60
|
|
|
61
|
+
if (this.use_toast) {
|
|
62
|
+
this._startToastEditor();
|
|
63
|
+
} else {
|
|
64
|
+
this._startCodeEditor();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Stop the editor
|
|
70
|
+
*
|
|
71
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
72
|
+
* @since 0.1.0
|
|
73
|
+
* @version 0.2.7
|
|
74
|
+
*/
|
|
75
|
+
Markdown.setMethod(function _stopEditor() {
|
|
76
|
+
|
|
77
|
+
Hawkejs.removeChildren(this.widget);
|
|
78
|
+
|
|
79
|
+
if (this.use_toast) {
|
|
80
|
+
this._startToastEditor();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return this.loadWidget();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Start the code editor
|
|
88
|
+
*
|
|
89
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
90
|
+
* @since 0.2.7
|
|
91
|
+
* @version 0.2.7
|
|
92
|
+
*/
|
|
93
|
+
Markdown.setMethod(async function _startCodeEditor() {
|
|
94
|
+
|
|
95
|
+
let element = this.createElement('div');
|
|
96
|
+
element.classList.add('markdown-editor-container');
|
|
97
|
+
this.widget.append(element);
|
|
98
|
+
|
|
99
|
+
let code_input = this.createElement('al-code-input');
|
|
100
|
+
code_input.show_line_numbers = false;
|
|
101
|
+
element.append(code_input);
|
|
102
|
+
|
|
103
|
+
code_input.value = this.config.markdown || '';
|
|
104
|
+
|
|
105
|
+
this.code_input = code_input;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Start the toast editor
|
|
110
|
+
*
|
|
111
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
112
|
+
* @since 0.2.7
|
|
113
|
+
* @version 0.2.7
|
|
114
|
+
*/
|
|
115
|
+
Markdown.setMethod(async function _startToastEditor() {
|
|
116
|
+
|
|
61
117
|
hawkejs.scene.enableStyle('https://uicdn.toast.com/editor/latest/toastui-editor.min.css');
|
|
62
118
|
await hawkejs.require('https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js');
|
|
63
119
|
|
|
@@ -69,7 +125,7 @@ Markdown.setMethod(async function _startEditor() {
|
|
|
69
125
|
|
|
70
126
|
const editor = new Editor({
|
|
71
127
|
el : element,
|
|
72
|
-
height : '
|
|
128
|
+
height : '600px',
|
|
73
129
|
initialEditType : 'markdown',
|
|
74
130
|
previewStyle : 'vertical',
|
|
75
131
|
usageStatistics : false,
|
|
@@ -84,15 +140,13 @@ Markdown.setMethod(async function _startEditor() {
|
|
|
84
140
|
});
|
|
85
141
|
|
|
86
142
|
/**
|
|
87
|
-
* Stop the editor
|
|
143
|
+
* Stop the toast editor
|
|
88
144
|
*
|
|
89
145
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
90
|
-
* @since 0.
|
|
91
|
-
* @version 0.2.
|
|
146
|
+
* @since 0.2.7
|
|
147
|
+
* @version 0.2.7
|
|
92
148
|
*/
|
|
93
|
-
Markdown.setMethod(function
|
|
94
|
-
|
|
95
|
-
Hawkejs.removeChildren(this.widget);
|
|
149
|
+
Markdown.setMethod(function _stopToastEditor() {
|
|
96
150
|
|
|
97
151
|
if (this.toast_editor) {
|
|
98
152
|
try {
|
|
@@ -101,8 +155,6 @@ Markdown.setMethod(function _stopEditor() {
|
|
|
101
155
|
}
|
|
102
156
|
|
|
103
157
|
this.toast_editor = null;
|
|
104
|
-
|
|
105
|
-
return this.loadWidget();
|
|
106
158
|
});
|
|
107
159
|
|
|
108
160
|
/**
|
|
@@ -110,7 +162,7 @@ Markdown.setMethod(function _stopEditor() {
|
|
|
110
162
|
*
|
|
111
163
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
112
164
|
* @since 0.1.0
|
|
113
|
-
* @version 0.2.
|
|
165
|
+
* @version 0.2.7
|
|
114
166
|
*
|
|
115
167
|
* @return {Object}
|
|
116
168
|
*/
|
|
@@ -120,6 +172,8 @@ Markdown.setMethod(function syncConfig() {
|
|
|
120
172
|
|
|
121
173
|
if (this.toast_editor) {
|
|
122
174
|
value = this.toast_editor.getMarkdown();
|
|
175
|
+
} else if (this.code_input) {
|
|
176
|
+
value = this.code_input.value;
|
|
123
177
|
}
|
|
124
178
|
|
|
125
179
|
this.config.markdown = value;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/helper/widgets/text.js
CHANGED
|
File without changes
|
package/helper/widgets_helper.js
CHANGED
|
File without changes
|
package/helper_field/widget.js
CHANGED
|
File without changes
|
package/helper_field/widgets.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a method to the conduit class to set the toolbar manager
|
|
3
|
+
*
|
|
4
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
+
* @since 0.2.7
|
|
6
|
+
* @version 0.2.7
|
|
7
|
+
*
|
|
8
|
+
* @param {Alchemy.Document} document_or_model
|
|
9
|
+
*/
|
|
10
|
+
Classes.Alchemy.Conduit.Conduit.setMethod(function setToolbarInfo(document_or_model, scenario = 'frontend') {
|
|
11
|
+
try {
|
|
12
|
+
_setToolbarInfo.call(this, document_or_model, scenario);
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.error('Error setting toolbar info', err);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Add a method to the conduit class to set the toolbar manager
|
|
20
|
+
*
|
|
21
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
22
|
+
* @since 0.2.7
|
|
23
|
+
* @version 0.2.7
|
|
24
|
+
*
|
|
25
|
+
* @param {Alchemy.Document} document_or_model
|
|
26
|
+
*/
|
|
27
|
+
function _setToolbarInfo(document_or_model, scenario = 'frontend') {
|
|
28
|
+
|
|
29
|
+
if (!this.hasPermission('alchemy.widgets.toolbar')) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let manager = Classes.Alchemy.Widget.EditorToolbarManager.create(this);
|
|
34
|
+
manager.scenario = scenario;
|
|
35
|
+
|
|
36
|
+
this.set('toolbar_manager', manager);
|
|
37
|
+
this.expose('toolbar_manager', manager);
|
|
38
|
+
|
|
39
|
+
let document_watcher,
|
|
40
|
+
document,
|
|
41
|
+
model;
|
|
42
|
+
|
|
43
|
+
if (document_or_model) {
|
|
44
|
+
if (document_or_model instanceof Classes.Alchemy.Document.Document) {
|
|
45
|
+
document = document_or_model;
|
|
46
|
+
} else {
|
|
47
|
+
model = document_or_model;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
document_watcher = manager.setDocument(document);
|
|
52
|
+
|
|
53
|
+
if (document) {
|
|
54
|
+
manager.setModel(document.$model_name);
|
|
55
|
+
document_watcher.addWatcher(this);
|
|
56
|
+
|
|
57
|
+
this.set('edit_model_name', document.$model_name);
|
|
58
|
+
this.set('edit_model_pk', document.$pk);
|
|
59
|
+
} else if (model) {
|
|
60
|
+
manager.setModel(model.model_name);
|
|
61
|
+
this.set('edit_model_name', model.model_name);
|
|
62
|
+
} else {
|
|
63
|
+
manager.setModel(null);
|
|
64
|
+
}
|
|
65
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemy-widget",
|
|
3
3
|
"description": "The widget plugin for the AlchemyMVC",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.8",
|
|
5
5
|
"author": "Jelle De Loecker <jelle@elevenways.be>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"alchemy",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"widget"
|
|
11
11
|
],
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"alchemymvc" : ">=1.
|
|
14
|
-
"alchemy-form": "~0.2.
|
|
13
|
+
"alchemymvc" : ">=1.3.0",
|
|
14
|
+
"alchemy-form": "~0.2.6"
|
|
15
15
|
},
|
|
16
16
|
"repository": "11ways/alchemy-widget",
|
|
17
17
|
"license": "MIT",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|