-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/app/frontend/editor/initializers/dynamic-inputs.js b/app/frontend/editor/initializers/dynamic-inputs.js
new file mode 100644
index 00000000..9611c8fb
--- /dev/null
+++ b/app/frontend/editor/initializers/dynamic-inputs.js
@@ -0,0 +1,23 @@
+import { registerInput, getInputs } from '@/misc/dynamic-inputs'
+
+import TextInput from '@/components/kit/polymorphic-text-input.vue'
+import ImageInput from '@/components/kit/image-input.vue'
+import LinkInput from '@/components/kit/link-input.vue'
+import SimpleSelect from '@/components/kit/simple-select.vue'
+import CollectionItemInput from '@/components/kit/collection-item-input.vue'
+import CheckboxInput from '@/components/kit/checkbox-input.vue'
+import ColorInput from '@/components/kit/color-input.vue'
+import IconInput from '@/components/kit/icon-input.vue'
+import Divider from '@/components/kit/divider.vue'
+import Hint from '@/components/kit/hint.vue'
+
+registerInput('text', TextInput, (props, options) => ({ ...props, options }))
+registerInput('image', ImageInput)
+registerInput('link', LinkInput, (props, options) => ({ ...props, withText: options.withText }))
+registerInput('select', SimpleSelect, (props, options) => ({ ...props, selectOptions: options.selectOptions }))
+registerInput('collection_item', CollectionItemInput, (props, options) => ({ ...props, collectionId: options.collectionId }))
+registerInput('checkbox', CheckboxInput)
+registerInput('icon', IconInput)
+registerInput('color', ColorInput, (props, options) => ({ ...props, presets: options.presets }))
+registerInput('divider', Divider, (props, options) => ({ text: props.label, withHint: options.withHint }))
+registerInput('hint', Hint, (props, options) => ({ text: props.label }))
\ No newline at end of file
diff --git a/app/frontend/editor/plugins/event-bus.js b/app/frontend/editor/initializers/event-bus.js
similarity index 100%
rename from app/frontend/editor/plugins/event-bus.js
rename to app/frontend/editor/initializers/event-bus.js
diff --git a/app/frontend/editor/plugins/filters.js b/app/frontend/editor/initializers/filters.js
similarity index 84%
rename from app/frontend/editor/plugins/filters.js
rename to app/frontend/editor/initializers/filters.js
index fb993cb5..1cfccea3 100644
--- a/app/frontend/editor/plugins/filters.js
+++ b/app/frontend/editor/initializers/filters.js
@@ -1,5 +1,5 @@
import Vue from 'vue'
-import i18n from '@/plugins/i18n.js'
+import i18n from '@/initializers/i18n.js'
import { numberToHumanSize, truncate, formatPath } from '@/misc/utils'
Vue.filter('numberToHumanSize', (size) => numberToHumanSize(size, i18n))
diff --git a/app/frontend/editor/plugins/i18n.js b/app/frontend/editor/initializers/i18n.js
similarity index 100%
rename from app/frontend/editor/plugins/i18n.js
rename to app/frontend/editor/initializers/i18n.js
diff --git a/app/frontend/editor/plugins/index.js b/app/frontend/editor/initializers/index.js
similarity index 54%
rename from app/frontend/editor/plugins/index.js
rename to app/frontend/editor/initializers/index.js
index 76c29d14..1cac41e2 100644
--- a/app/frontend/editor/plugins/index.js
+++ b/app/frontend/editor/initializers/index.js
@@ -1,3 +1,5 @@
import './i18n'
import './tooltip'
import './filters'
+import './dynamic-inputs'
+import './plugins'
diff --git a/app/frontend/editor/initializers/plugins.js b/app/frontend/editor/initializers/plugins.js
new file mode 100644
index 00000000..3d34f2ed
--- /dev/null
+++ b/app/frontend/editor/initializers/plugins.js
@@ -0,0 +1,5 @@
+const modules = import.meta.glob('@/plugins/*.js')
+
+for (const path in modules) {
+ modules[path]()
+}
diff --git a/app/frontend/editor/plugins/tooltip.js b/app/frontend/editor/initializers/tooltip.js
similarity index 100%
rename from app/frontend/editor/plugins/tooltip.js
rename to app/frontend/editor/initializers/tooltip.js
diff --git a/app/frontend/editor/main.js b/app/frontend/editor/main.js
index eca1dd6e..fe8df802 100644
--- a/app/frontend/editor/main.js
+++ b/app/frontend/editor/main.js
@@ -1,10 +1,10 @@
import Vue from 'vue'
import App from './App.vue'
import store from '@/store'
-import i18n from '@/plugins/i18n'
+import i18n from '@/initializers/i18n'
import router from '@/router'
import '@/mixins'
-import '@/plugins'
+import '@/initializers'
import '@/components/kit'
Vue.config.productionTip = false
diff --git a/app/frontend/editor/misc/__tests__/utils.spec.js b/app/frontend/editor/misc/__tests__/utils.spec.js
index c95f112a..9968e42a 100644
--- a/app/frontend/editor/misc/__tests__/utils.spec.js
+++ b/app/frontend/editor/misc/__tests__/utils.spec.js
@@ -1,5 +1,5 @@
import * as utils from '../utils'
-import i18n from '@/plugins/i18n.js'
+import i18n from '@/initializers/i18n.js'
describe('numberToHumanSize', () => {
it('takes a number and converts it into a human string', () => {
diff --git a/app/frontend/editor/misc/dynamic-inputs.js b/app/frontend/editor/misc/dynamic-inputs.js
new file mode 100644
index 00000000..6f1900f8
--- /dev/null
+++ b/app/frontend/editor/misc/dynamic-inputs.js
@@ -0,0 +1,22 @@
+const dynamicInputs = {}
+
+const defaultTransformProps = (props, options) => props
+
+export const registerInput = function(name, component, transformProps = null) {
+ dynamicInputs[name] = {
+ component,
+ transformProps: transformProps ?? defaultTransformProps
+ }
+}
+
+export const getInput = function(name) {
+ const input = dynamicInputs[name]
+
+ if (!input) console.log(`🚨 [Maglev ERROR] Unable to find the ${name} type input. Are you sure you registered it correctly?`)
+
+ return dynamicInputs[name]
+}
+
+export const getInputs = function() {
+ return dynamicInputs
+}
diff --git a/app/frontend/editor/mixins/global.js b/app/frontend/editor/mixins/global.js
index 3f4347f4..b2e7bcca 100644
--- a/app/frontend/editor/mixins/global.js
+++ b/app/frontend/editor/mixins/global.js
@@ -1,6 +1,6 @@
import Vue from 'vue'
import { mapState, mapActions } from 'vuex'
-import { ModalBus } from '@/plugins/event-bus'
+import { ModalBus } from '@/initializers/event-bus'
import services from '@/services'
import { isBlank } from '@/misc/utils'
@@ -106,6 +106,9 @@ Vue.mixin({
tablet: 1024,
}
},
+ modalBus() {
+ return ModalBus
+ }
},
methods: {
...mapActions([
diff --git a/app/frontend/editor/plugins/.keep b/app/frontend/editor/plugins/.keep
new file mode 100644
index 00000000..4f07f1ca
--- /dev/null
+++ b/app/frontend/editor/plugins/.keep
@@ -0,0 +1 @@
+.keep
\ No newline at end of file
diff --git a/app/helpers/maglev/admin/themes_helper.rb b/app/helpers/maglev/admin/themes_helper.rb
index 208772dc..626f69cd 100644
--- a/app/helpers/maglev/admin/themes_helper.rb
+++ b/app/helpers/maglev/admin/themes_helper.rb
@@ -20,7 +20,7 @@ def section_template_path(section)
end
def section_screenshot_path(section)
- services.fetch_section_screenshot_path.call(section: section)
+ services.fetch_section_screenshot_path.call(section:)
end
end
end
diff --git a/app/helpers/maglev/editor_helper.rb b/app/helpers/maglev/editor_helper.rb
index 0e62d2c0..2048a0da 100644
--- a/app/helpers/maglev/editor_helper.rb
+++ b/app/helpers/maglev/editor_helper.rb
@@ -81,7 +81,7 @@ def editor_asset_path(source, default_source)
def editor_custom_translations
I18n.available_locales.index_with do |locale|
- ::I18n.t('maglev', locale: locale, default: nil)
+ ::I18n.t('maglev', locale:, default: nil)
end
end
end
diff --git a/app/helpers/maglev/page_preview_helper.rb b/app/helpers/maglev/page_preview_helper.rb
index 985bd463..16cafedf 100644
--- a/app/helpers/maglev/page_preview_helper.rb
+++ b/app/helpers/maglev/page_preview_helper.rb
@@ -20,9 +20,9 @@ def render_maglev_section(type, site: nil, theme: nil, page: nil, page_sections:
end
render_maglev_sections(
- site: site,
- theme: theme,
- page: page,
+ site:,
+ theme:,
+ page:,
page_sections: sections
)
end
diff --git a/app/helpers/maglev/sitemap_helper.rb b/app/helpers/maglev/sitemap_helper.rb
index 15bba249..387dff37 100644
--- a/app/helpers/maglev/sitemap_helper.rb
+++ b/app/helpers/maglev/sitemap_helper.rb
@@ -3,7 +3,7 @@
module Maglev
module SitemapHelper
def sitemap_url(host, page, locale = nil)
- path = maglev_services.get_page_fullpath.call(page: page, locale: locale)
+ path = maglev_services.get_page_fullpath.call(page:, locale:)
return path if path =~ %r{^https?://}
diff --git a/app/models/concerns/maglev/sections_concern.rb b/app/models/concerns/maglev/sections_concern.rb
index 462db56b..6ace8594 100644
--- a/app/models/concerns/maglev/sections_concern.rb
+++ b/app/models/concerns/maglev/sections_concern.rb
@@ -47,7 +47,7 @@ def prepare_block(theme, section_type, block)
def prepare_settings(theme, section_type, block_type, settings)
# NOTE: in the theme definition file, we allow developers to declare
# default content like this: {