alchemy-widget 0.3.0-alpha.1 → 0.3.0-alpha.2

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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.0-alpha.2 (2025-07-10)
2
+
3
+ * Make `main_class_names` widget config add classes to the first child of the wrapper
4
+ * Add `li_class_names` config to List widgets
5
+ * Don't return client-version of ToolbarManager on the server
6
+
1
7
  ## 0.3.0-alpha.1 (2024-02-15)
2
8
 
3
9
  * Upgrade to Alchemy v1.4.0
File without changes
@@ -740,7 +740,7 @@ Widget.setMethod(function populateWidget() {
740
740
  *
741
741
  * @author Jelle De Loecker <jelle@elevenways.be>
742
742
  * @since 0.1.0
743
- * @version 0.2.1
743
+ * @version 0.3.0
744
744
  */
745
745
  Widget.setMethod(function finalizePopulatedWidget() {
746
746
 
@@ -758,6 +758,22 @@ Widget.setMethod(function finalizePopulatedWidget() {
758
758
  }
759
759
  }
760
760
 
761
+ if (config.main_class_names) {
762
+ let main = this.widget?.children?.[0];
763
+
764
+ if (main) {
765
+ let name,
766
+ i;
767
+
768
+ let class_names = Array.cast(config.main_class_names);
769
+
770
+ for (i = 0; i < class_names.length; i++) {
771
+ name = class_names[i];
772
+ main.classList.add(name);
773
+ }
774
+ }
775
+ }
776
+
761
777
  if (config.language) {
762
778
  this.widget.setAttribute('lang', config.language);
763
779
  } else {
@@ -11,6 +11,23 @@
11
11
  */
12
12
  const List = Function.inherits('Alchemy.Widget.Container', 'List');
13
13
 
14
+ /**
15
+ * Prepare the schema
16
+ *
17
+ * @author Jelle De Loecker <jelle@elevenways.be>
18
+ * @since 0.3.0
19
+ * @version 0.3.0
20
+ */
21
+ List.constitute(function prepareSchema() {
22
+
23
+ // Classnames for the li elements
24
+ this.schema.addField('li_class_names', 'String', {
25
+ title : 'Li-element CSS classes',
26
+ description : 'Configure extra CSS classes for the list items',
27
+ array: true,
28
+ });
29
+ });
30
+
14
31
  /**
15
32
  * Get a list of elements that could be child widgets
16
33
  *
@@ -39,4 +56,38 @@ List.setMethod(function initContainer() {
39
56
  this.widget.list_element = ul;
40
57
 
41
58
  initContainer.super.call(this);
59
+ });
60
+
61
+ /**
62
+ * Populate the contents of the widget
63
+ *
64
+ * @author Jelle De Loecker <jelle@elevenways.be>
65
+ * @since 0.3.0
66
+ * @version 0.3.0
67
+ */
68
+ List.setMethod(function finalizePopulatedWidget() {
69
+
70
+ const config = this.config;
71
+
72
+ if (config?.li_class_names) {
73
+ let li_elements = this.widget.list_element.querySelectorAll(':scope > li');
74
+
75
+ if (li_elements.length) {
76
+ let name,
77
+ i;
78
+
79
+ let class_names = Array.cast(config.li_class_names);
80
+
81
+ for (i = 0; i < class_names.length; i++) {
82
+ name = class_names[i];
83
+
84
+ for (let li_element of li_elements) {
85
+ li_element.classList.add(name);
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+
92
+ return finalizePopulatedWidget.super.call(this);
42
93
  });
@@ -1,3 +1,5 @@
1
+ const MANAGER = Symbol('toolbar_manager');
2
+
1
3
  /**
2
4
  * Add a method to the conduit class to set the toolbar manager
3
5
  *
@@ -13,6 +15,8 @@ Classes.Alchemy.Conduit.Conduit.setMethod(function setToolbarInfo(document_or_mo
13
15
  } catch (err) {
14
16
  console.error('Error setting toolbar info', err);
15
17
  }
18
+
19
+ return this[MANAGER];
16
20
  });
17
21
 
18
22
  /**
@@ -30,11 +34,18 @@ function _setToolbarInfo(document_or_model, scenario = 'frontend') {
30
34
  return;
31
35
  }
32
36
 
33
- let manager = Classes.Alchemy.Widget.EditorToolbarManager.create(this);
34
- manager.scenario = scenario;
37
+ let manager = this[MANAGER] || this.set('toolbar_manager');
38
+
39
+ if (!manager) {
40
+ manager = Classes.Alchemy.Widget.EditorToolbarManager.create(this);
41
+ this[MANAGER] = manager;
42
+ this.set('toolbar_manager', manager);
43
+ this.expose('toolbar_manager', manager);
44
+ }
35
45
 
36
- this.set('toolbar_manager', manager);
37
- this.expose('toolbar_manager', manager);
46
+ if (scenario !== undefined) {
47
+ manager.scenario = scenario;
48
+ }
38
49
 
39
50
  let document_watcher,
40
51
  document,
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.3.0-alpha.1",
4
+ "version": "0.3.0-alpha.2",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",