@silexlabs/silex 3.3.1-1 → 3.3.1-3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silexlabs/silex",
3
3
  "description": "Free and easy website builder for everyone.",
4
- "version": "3.3.1-1",
4
+ "version": "3.3.1-3",
5
5
  "version:backwardcompat": "3.0.0",
6
6
  "author": {
7
7
  "name": "Alex Hoyau",
@@ -105,7 +105,7 @@
105
105
  "dependencies": {
106
106
  "@fontsource/ubuntu": "^5.0.13",
107
107
  "@fortawesome/fontawesome-free": "6.6.0",
108
- "@silexlabs/grapesjs-advanced-selector": "1.2.1-0",
108
+ "@silexlabs/grapesjs-advanced-selector": "1.2.1-2",
109
109
  "@silexlabs/grapesjs-filter-styles": "1.1.0",
110
110
  "@silexlabs/grapesjs-fonts": "1.1.0",
111
111
  "@silexlabs/grapesjs-keymaps-dialog": "1.1.0",
@@ -117,6 +117,9 @@
117
117
  #gjs-clm-tags-field.gjs-field {
118
118
  margin: 0;
119
119
  }
120
+ .gjs-field.gjs-field-integer {
121
+ width: 100%;
122
+ }
120
123
  .gjs-clm-tags {
121
124
  padding-top: 7px;
122
125
  padding-bottom: 0;
@@ -124,6 +127,10 @@
124
127
  #gjs-clm-up {
125
128
  margin-top: 0;
126
129
  }
130
+ .gjs-sm-icon[title]:not([title=""])::after {
131
+ content: "?";
132
+ margin-left: 0.5em;
133
+ }
127
134
 
128
135
  /*
129
136
  */
@@ -220,3 +227,8 @@
220
227
  display: block;
221
228
  color: var(--gjs-color-warn);
222
229
  }
230
+
231
+ // FIXME: Workaround, why is this needed?
232
+ .gjs-field .gjs-sel-arrow {
233
+ z-index: 999;
234
+ }
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import { Editor } from 'grapesjs'
19
+ import { registerSector } from './sectors'
19
20
 
20
21
  /**
21
22
  * @fileoverview Adds various css properties
@@ -61,7 +62,7 @@ export default (editor: Editor, opts) => {
61
62
  { id: 'initial', value: 'initial', name: 'initial' },
62
63
  { id: 'unset', value: 'unset', name: 'unset' },
63
64
  ],
64
- info: 'The visibility CSS property shows or hides an element without changing the layout of a document. The property can also hide rows or columns in a <table>.',
65
+ info: 'Controls element visibility without changing layout.',
65
66
  })
66
67
  editor.StyleManager.removeProperty('general', 'float')
67
68
  editor.StyleManager.removeProperty('general', 'position')
@@ -120,15 +121,36 @@ export default (editor: Editor, opts) => {
120
121
  units: [ 'px', '%', 'em', 'rem', 'vh', 'vw' ],
121
122
  info: '',
122
123
  })
123
- const contentProp = editor.StyleManager.addProperty('general', {
124
+ registerSector(editor, {
125
+ id: 'content',
124
126
  name: 'Content',
125
- property: 'content',
126
- type: 'text',
127
- defaults: '',
128
- info: 'The content CSS property replaces an element with a generated value. Objects inserted using the content property are anonymous replaced elements.',
129
- full: true,
130
- visible: false,
131
- }, { at: 0 })
127
+ props: [{
128
+ name: 'Content',
129
+ property: 'content',
130
+ type: 'text',
131
+ defaults: '',
132
+ info: 'Generates content for an element.',
133
+ full: true,
134
+ visible: false,
135
+ }],
136
+ shouldShow: async () => {
137
+ return new Promise<boolean>((resolve, reject) => {
138
+ requestAnimationFrame(() => {
139
+ try {
140
+ const state = editor.StyleManager
141
+ .getSelected()
142
+ .get('state')
143
+ if (['before', 'after'].includes(state)) {
144
+ return resolve(true)
145
+ }
146
+ return resolve(false)
147
+ } catch(e) {
148
+ reject(e)
149
+ }
150
+ })
151
+ })
152
+ },
153
+ }, 0)
132
154
  /***************/
133
155
  /* Dimension */
134
156
  /***************/
@@ -217,8 +239,22 @@ export default (editor: Editor, opts) => {
217
239
  { id: 'unset', value: 'unset', name: 'unset' },
218
240
  ],
219
241
  }],
220
- info: 'The overflow CSS property sets what to do when an element\'s content is too big to fit in its block formatting context. It is a shorthand for overflow-x and overflow-y.',
242
+ info: 'Controls content overflow in a block.',
221
243
  }, { at: 6 })
244
+
245
+ editor.StyleManager.addProperty('dimension', {
246
+ name: 'Scroll Behavior',
247
+ property: 'scroll-behavior',
248
+ type: 'select',
249
+ defaults: '',
250
+ options: [
251
+ { id: '', value: '', name: '' },
252
+ { id: 'auto', value: 'auto', name: 'auto' },
253
+ { id: 'smooth', value: 'smooth', name: 'smooth' }
254
+ ],
255
+ info: 'Sets smooth or auto scroll behavior.',
256
+ }, { at: 7 })
257
+
222
258
  editor.StyleManager.removeProperty('dimension', 'margin')
223
259
  editor.StyleManager.addProperty('dimension', {
224
260
  name: 'Margin',
@@ -256,7 +292,7 @@ export default (editor: Editor, opts) => {
256
292
  fixedValues: [ 'initial', 'inherit', 'auto' ],
257
293
  units: [ 'px', '%', 'em', 'rem', 'vh', 'vw' ],
258
294
  }],
259
- }, { at: 7 })
295
+ }, { at: 8 })
260
296
  editor.StyleManager.removeProperty('dimension', 'padding')
261
297
  editor.StyleManager.addProperty('dimension', {
262
298
  name: 'Padding',
@@ -297,64 +333,8 @@ export default (editor: Editor, opts) => {
297
333
  fixedValues: [ 'initial', 'inherit', 'auto' ],
298
334
  units: [ 'px', '%', 'em', 'rem', 'vh', 'vw' ],
299
335
  }],
300
- }, { at: 8 })
301
-
302
- editor.StyleManager.addProperty('extra', {
303
- name: 'Scroll Snap Type',
304
- property: 'scroll-snap-type',
305
- type: 'composite',
306
- properties: [{
307
- name: 'Direction',
308
- property: 'scroll-snap-type-direction',
309
- type: 'select',
310
- defaults: '',
311
- options: [
312
- { id: '', value: '', name: '' },
313
- { id: 'none', value: 'none', name: 'none' },
314
- { id: 'x', value: 'x', name: 'x' },
315
- { id: 'y', value: 'y', name: 'y' },
316
- { id: 'block', value: 'block', name: 'block' },
317
- { id: 'inline', value: 'inline', name: 'inline' },
318
- { id: 'both', value: 'both', name: 'both' },
319
- ],
320
- }, {
321
- name: 'Mode',
322
- property: 'scroll-snap-type-mode',
323
- type: 'select',
324
- defaults: '',
325
- options: [
326
- { id: '', value: '', name: '' },
327
- { id: 'proximity', value: 'proximity', name: 'proximity' },
328
- { id: 'mandatory', value: 'mandatory', name: 'mandatory' },
329
- ],
330
- }],
331
- info: 'The scroll-snap-type CSS property sets the direction and mode of enforced snap points on the scroll container.',
332
336
  }, { at: 9 })
333
337
 
334
- editor.StyleManager.addProperty('extra', {
335
- name: 'Scroll Padding',
336
- property: 'scroll-padding',
337
- type: 'integer',
338
- defaults: '',
339
- units: ['px', 'em', 'rem', '%'],
340
- info: 'The scroll-padding CSS property defines offsets for the optimal snap position when scrolling is loaded by the browser.',
341
- }, { at: 10 })
342
-
343
- editor.StyleManager.addProperty('extra', {
344
- name: 'Scroll Snap Align',
345
- property: 'scroll-snap-align',
346
- type: 'select',
347
- defaults: '',
348
- options: [
349
- { id: '', value: '', name: '' },
350
- { id: 'none', value: 'none', name: 'none' },
351
- { id: 'start', value: 'start', name: 'start' },
352
- { id: 'end', value: 'end', name: 'end' },
353
- { id: 'center', value: 'center', name: 'center' },
354
- ],
355
- info: 'The scroll-snap-align property specifies how strictly the snap points are enforced on the element in the container.',
356
- }, { at: 11 })
357
-
358
338
  /***************/
359
339
  /* Typography */
360
340
  /***************/
@@ -752,6 +732,15 @@ export default (editor: Editor, opts) => {
752
732
  default: '',
753
733
  fixedValues: ['normal', 'inherit', 'initial', 'revert', 'unset'],
754
734
  }, { at: 6 })
735
+ editor.StyleManager.addProperty('extra', {
736
+ name: 'Row Gap',
737
+ property: 'row-gap',
738
+ type: 'integer',
739
+ units: ['px', '%', 'em'],
740
+ info: 'The row-gap CSS property sets the size of the gap (gutter) between an element\'s rows.',
741
+ default: '',
742
+ fixedValues: ['normal', 'inherit', 'initial', 'revert', 'unset'],
743
+ }, { at: 7 })
755
744
  editor.StyleManager.addProperty('extra', {
756
745
  name: 'Column rule',
757
746
  property: 'column-rule',
@@ -791,7 +780,7 @@ export default (editor: Editor, opts) => {
791
780
  defaults: '',
792
781
  info: 'The column-rule-color CSS property sets the color of the line drawn between columns in a multi-column layout.',
793
782
  }],
794
- }, { at: 7 })
783
+ }, { at: 8 })
795
784
  editor.StyleManager.addProperty('extra', {
796
785
  name: 'Column span',
797
786
  property: 'column-span',
@@ -803,17 +792,61 @@ export default (editor: Editor, opts) => {
803
792
  { id: 'all', value: 'all', name: 'all' },
804
793
  ],
805
794
  info: 'The column-span CSS property makes it possible for an element to span across all columns when its value is set to all.',
806
- }, { at: 8 })
807
- function refreshContentProp() {
808
- const state = editor.SelectorManager.getState()
809
- if (['before', 'after'].includes(state)) {
810
- contentProp.set('visible', true)
811
- } else {
812
- contentProp.set('visible', false)
813
- }
814
- }
815
- editor.on('selector:state component:selected component:styleUpdate style:sector:update', (state, opts) => setTimeout(() => refreshContentProp()))
816
- editor.StyleManager.getSector('general').on('change', () => refreshContentProp())
795
+ }, { at: 9 })
796
+ editor.StyleManager.addProperty('extra', {
797
+ name: 'Scroll Snap Type',
798
+ property: 'scroll-snap-type',
799
+ type: 'composite',
800
+ properties: [{
801
+ name: 'Direction',
802
+ property: 'scroll-snap-type-direction',
803
+ type: 'select',
804
+ defaults: '',
805
+ options: [
806
+ { id: '', value: '', name: '' },
807
+ { id: 'none', value: 'none', name: 'none' },
808
+ { id: 'x', value: 'x', name: 'x' },
809
+ { id: 'y', value: 'y', name: 'y' },
810
+ { id: 'block', value: 'block', name: 'block' },
811
+ { id: 'inline', value: 'inline', name: 'inline' },
812
+ { id: 'both', value: 'both', name: 'both' },
813
+ ],
814
+ }, {
815
+ name: 'Mode',
816
+ property: 'scroll-snap-type-mode',
817
+ type: 'select',
818
+ defaults: '',
819
+ options: [
820
+ { id: '', value: '', name: '' },
821
+ { id: 'proximity', value: 'proximity', name: 'proximity' },
822
+ { id: 'mandatory', value: 'mandatory', name: 'mandatory' },
823
+ ],
824
+ }],
825
+ info: 'The scroll-snap-type CSS property sets the direction and mode of enforced snap points on the scroll container.',
826
+ }, { at: 10 })
827
+ editor.StyleManager.addProperty('extra', {
828
+ name: 'Scroll Padding',
829
+ property: 'scroll-padding',
830
+ type: 'integer',
831
+ defaults: '',
832
+ units: ['px', 'em', 'rem', '%'],
833
+ info: 'Defines offsets for scroll snapping.',
834
+ }, { at: 11 })
835
+ editor.StyleManager.addProperty('extra', {
836
+ name: 'Scroll Snap Align',
837
+ property: 'scroll-snap-align',
838
+ type: 'select',
839
+ defaults: '',
840
+ options: [
841
+ { id: '', value: '', name: '' },
842
+ { id: 'none', value: 'none', name: 'none' },
843
+ { id: 'start', value: 'start', name: 'start' },
844
+ { id: 'end', value: 'end', name: 'end' },
845
+ { id: 'center', value: 'center', name: 'center' },
846
+ ],
847
+ info: 'Aligns elements to scroll snaps.',
848
+ }, { at: 11 })
849
+
817
850
  editor.SelectorManager.states.add({name: 'before', label: 'Before'})
818
851
  editor.SelectorManager.states.add({name: 'after', label: 'After'})
819
852
  editor.SelectorManager.states.add({name: 'active', label: 'Active'})
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Dynamic plugin loader for external GrapesJS plugins
3
+ * These plugins are loaded at runtime to reduce initial bundle size
4
+ */
5
+
6
+ export interface PluginDefinition {
7
+ name: string
8
+ value: any
9
+ }
10
+
11
+ /**
12
+ * Load all external plugins dynamically
13
+ */
14
+ export async function loadDynamicPlugins(): Promise<PluginDefinition[]> {
15
+ const [
16
+ blocksBasicPlugin,
17
+ styleFilterPlugin,
18
+ formPlugin,
19
+ codePlugin,
20
+ filterStyles,
21
+ symbolsPlugin,
22
+ loadingPlugin,
23
+ fontsDialogPlugin,
24
+ selectorPlugin,
25
+ rateLimitPlugin,
26
+ borderPlugin,
27
+ backgroundPlugin,
28
+ notificationsPlugin,
29
+ keymapsDialogPlugin,
30
+ ] = await Promise.all([
31
+ import('grapesjs-blocks-basic').then(m => m.default),
32
+ import('grapesjs-style-filter').then(m => m.default),
33
+ import('grapesjs-plugin-forms').then(m => m.default),
34
+ import('grapesjs-custom-code').then(m => m.default),
35
+ import('@silexlabs/grapesjs-filter-styles').then(m => m.default),
36
+ import('@silexlabs/grapesjs-symbols').then(m => m.default),
37
+ import('@silexlabs/grapesjs-loading').then(m => m.default),
38
+ import('@silexlabs/grapesjs-fonts').then(m => m.default),
39
+ import('@silexlabs/grapesjs-advanced-selector').then(m => m.default),
40
+ import('@silexlabs/grapesjs-storage-rate-limit').then(m => m.default),
41
+ import('grapesjs-style-border').then(m => m.default),
42
+ import('grapesjs-style-bg').then(m => m.default),
43
+ import('@silexlabs/grapesjs-notifications').then(m => m.default),
44
+ import('@silexlabs/grapesjs-keymaps-dialog').then(m => m.default),
45
+ ])
46
+
47
+ return [
48
+ { name: 'grapesjs-blocks-basic', value: blocksBasicPlugin },
49
+ { name: 'grapesjs-style-filter', value: styleFilterPlugin },
50
+ { name: 'grapesjs-plugin-forms', value: formPlugin },
51
+ { name: 'grapesjs-custom-code', value: codePlugin },
52
+ { name: '@silexlabs/grapesjs-filter-styles', value: filterStyles },
53
+ { name: '@silexlabs/grapesjs-symbols', value: symbolsPlugin },
54
+ { name: '@silexlabs/grapesjs-loading', value: loadingPlugin },
55
+ { name: '@silexlabs/grapesjs-fonts', value: fontsDialogPlugin },
56
+ { name: '@silexlabs/grapesjs-advanced-selector', value: selectorPlugin },
57
+ { name: '@silexlabs/grapesjs-storage-rate-limit', value: rateLimitPlugin },
58
+ { name: 'grapesjs-style-border', value: borderPlugin },
59
+ { name: 'grapesjs-style-bg', value: backgroundPlugin },
60
+ { name: '@silexlabs/grapesjs-notifications', value: notificationsPlugin },
61
+ { name: '@silexlabs/grapesjs-keymaps-dialog', value: keymapsDialogPlugin },
62
+ ]
63
+ }
@@ -14,7 +14,7 @@
14
14
  * You should have received a copy of the GNU Affero General Public License
15
15
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
  */
17
- import { Editor } from 'grapesjs'
17
+ import { Component, Editor } from 'grapesjs'
18
18
  import { SectorConfig, registerSector } from './sectors'
19
19
 
20
20
  /**
@@ -22,62 +22,63 @@ import { SectorConfig, registerSector } from './sectors'
22
22
  *
23
23
  */
24
24
 
25
- export default (editor: Editor) => {
26
- const sectorConfigs: SectorConfig[] = [{
27
- name: 'Flex Item',
28
- props: [
29
- {
30
- id: 'order',
31
- name: 'Order',
32
- property: 'order',
33
- type: 'integer',
34
- defaults: 0,
35
- },
36
- {
37
- id: 'flex-grow',
38
- name: 'Flex Grow',
39
- property: 'flex-grow',
40
- type: 'integer',
41
- defaults: 0,
42
- },
43
- {
44
- id: 'flex-shrink',
45
- name: 'Flex Shrink',
46
- property: 'flex-shrink',
47
- type: 'integer',
48
- defaults: 1,
49
- },
50
- {
51
- id: 'flex-basis',
52
- name: 'Flex Basis',
53
- property: 'flex-basis',
54
- type: 'text',
55
- defaults: 'auto',
56
- },
57
- {
58
- id: 'align-self',
59
- name: 'Align Self',
60
- property: 'align-self',
61
- type: 'select',
62
- options: [
63
- { id: '', label: '' },
64
- { id: 'auto', label: 'auto' },
65
- { id: 'flex-start', label: 'flex-start' },
66
- { id: 'flex-end', label: 'flex-end' },
67
- { id: 'center', label: 'center' },
68
- { id: 'baseline', label: 'baseline' },
69
- { id: 'stretch', label: 'stretch' },
70
- ],
71
- },
72
- ],
73
- shouldShow: comp => {
74
- const parent = comp.parent()
75
- const display = parent?.getStyle()['display'] as string || ''
76
- return display.includes('flex')
77
- }
78
- }]
25
+ const FLEX_PROPS = [
26
+ 'flex-direction',
27
+ 'flex-wrap',
28
+ 'justify-content',
29
+ 'align-items',
30
+ 'align-content',
31
+ 'row-gap',
32
+ 'column-gap',
33
+ ]
34
+
35
+ const FLEX_ITEM_PROPS = [
36
+ 'flex-grow',
37
+ 'flex-shrink',
38
+ 'flex-basis',
39
+ 'order',
40
+ 'align-self',
41
+ ]
79
42
 
43
+ export default (editor: Editor) => {
80
44
  editor.on('load', () => {
81
- sectorConfigs.forEach(sectorConfig => registerSector(editor, sectorConfig, 2))
45
+ const sector = editor.StyleManager.getSector('flex')
46
+ // Add missing sectors
47
+ // FIXME: this makes grapesjs bug, all other props disappear
48
+ // FLEX_PROPS
49
+ // .concat(FLEX_ITEM_PROPS)
50
+ // .forEach(id => {
51
+ // if (!sector.getProperty(id)) {
52
+ // editor.StyleManager.addProperty('flex', {
53
+ // id,
54
+ // })
55
+ // }
56
+ // })
57
+ // Update the visibility
58
+ // This is a workaround grapesjs behavior: https://github.com/GrapesJS/grapesjs/issues/3123
59
+ sector.on('change:visible', () => applyVisibility())
60
+ editor.on('component:selected', comp => applyVisibility(comp))
61
+ function applyVisibility(comp: Component = editor.getSelected()) {
62
+ requestAnimationFrame(() => {
63
+ const computedDisplay = comp?.view?.el && getComputedStyle(comp.view.el)['display'] as string || ''
64
+ const isFlex = computedDisplay === 'flex' || computedDisplay === 'inline-flex'
65
+ const parent = comp.parent()
66
+ const parentComputedDisplay = parent?.view?.el && getComputedStyle(parent.view.el)['display'] as string || ''
67
+ const parentIsFlex = parentComputedDisplay === 'flex' || parentComputedDisplay === 'inline-flex'
68
+ if (parentIsFlex || isFlex) {
69
+ sector.set('visible', true)
70
+ }
71
+ if (parentIsFlex && isFlex) {
72
+ sector.getProperties()
73
+ .forEach(p => p.set('visible', true))
74
+ } else if (isFlex) {
75
+ sector.getProperties()
76
+ .forEach(p => p.set('visible', FLEX_PROPS.includes(p.getId())))
77
+ } else if (parentIsFlex) {
78
+ sector.getProperties()
79
+ .forEach(p => p.set('visible', FLEX_ITEM_PROPS.includes(p.getId())))
80
+ }
81
+ })
82
+ }
82
83
  })
83
84
  }
@@ -143,6 +143,7 @@ export function getEditorConfig(config: ClientConfig): EditorConfig {
143
143
  showDevices: true,
144
144
 
145
145
  //pageManager: {},
146
+ telemetry: false,
146
147
 
147
148
  layerManager: {
148
149
  appendTo: '.layer-manager-container',
@@ -25,6 +25,7 @@ import { SectorConfig, registerSector } from './sectors'
25
25
  export default (editor: Editor) => {
26
26
  const sectorConfigs: SectorConfig[] = [
27
27
  {
28
+ id: 'list',
28
29
  name: 'List',
29
30
  props: [
30
31
  {