Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Move editor config to its own file

dominik-zeglen80e93f9d39aa
diff --git a/saleor/static/dashboard/js/components/editor.js b/saleor/static/dashboard/js/components/editor.js
new file mode 100644
index 0000000000..7e7bebfa01
--- /dev/null
+++ b/saleor/static/dashboard/js/components/editor.js
@@ -0,0 +1,59 @@
+import MediumEditor from 'medium-editor';
+
+new MediumEditor('.rich-text-editor', {
+ toolbar: {
+ buttons: [
+ {
+ name: 'bold',
+ aria: pgettext('Rich text editor option', 'Bold text')
+ },
+ {
+ name: 'italic',
+ aria: pgettext('Rich text editor option', 'Italic text')
+ },
+ {
+ name: 'h2',
+ aria: pgettext('Rich text editor option', 'Header'),
+ tagNames: ['h2'],
+ contentDefault: '<b>T</b>',
+ classList: ['custom-class-h1']
+ },
+ {
+ name: 'h3',
+ aria: pgettext('Rich text editor option', 'Subheader'),
+ tagNames: ['h3'],
+ contentDefault: '<b style="font-size: .75rem">T</b>',
+ classList: ['custom-class-h2']
+ },
+ {
+ name: 'quote',
+ aria: pgettext('Rich text editor option', 'Quote')
+ },
+ {
+ name: 'anchor',
+ aria: pgettext('Rich text editor option', 'Link'),
+ formSaveLabel: '<img src="/static/dashboard/images/done.svg">',
+ formCloseLabel: '<img src="/static/dashboard/images/close.svg">'
+ }
+ ]
+ },
+ keyboardCommands: {
+ commands: [
+ {
+ command: 'bold',
+ key: 'B',
+ meta: true,
+ shift: false,
+ alt: false
+ },
+ {
+ command: 'italic',
+ key: 'I',
+ meta: true,
+ shift: false,
+ alt: false
+ },
+
+ ]
+ }
+});
diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.js
index 08f77731f3..35880e463f 100644
--- a/saleor/static/dashboard/js/components/misc.js
+++ b/saleor/static/dashboard/js/components/misc.js
@@ -1,5 +1,4 @@
import SVGInjector from 'svg-injector-2';
-import MediumEditor from 'medium-editor';
import { initSelects } from './selects';
import { onScroll } from './utils';
@@ -60,65 +59,6 @@ $('#product-is-published').on('click', (e) => {
}
});
-// WYSIWYG editor
-new MediumEditor('.rich-text-editor', {
- toolbar: {
- buttons: [
- {
- name: 'bold',
- aria: pgettext('Rich text editor option', 'Bold text')
- },
- {
- name: 'italic',
- aria: pgettext('Rich text editor option', 'Italic text')
- },
- {
- name: 'h2',
- aria: pgettext('Rich text editor option', 'Header'),
- tagNames: ['h2'],
- contentDefault: '<b>T</b>',
- classList: ['custom-class-h1']
- },
- {
- name: 'h3',
- aria: pgettext('Rich text editor option', 'Subheader'),
- tagNames: ['h3'],
- contentDefault: '<b style="font-size: .75rem">T</b>',
- classList: ['custom-class-h2']
- },
- {
- name: 'quote',
- aria: pgettext('Rich text editor option', 'Quote')
- },
- {
- name: 'anchor',
- aria: pgettext('Rich text editor option', 'Link'),
- formSaveLabel: '<img src="/static/dashboard/images/done.svg">',
- formCloseLabel: '<img src="/static/dashboard/images/close.svg">'
- }
- ]
- },
- keyboardCommands: {
- commands: [
- {
- command: 'bold',
- key: 'B',
- meta: true,
- shift: false,
- alt: false
- },
- {
- command: 'italic',
- key: 'I',
- meta: true,
- shift: false,
- alt: false
- },
-
- ]
- }
-});
-
// Styleguide sticky right menu
onScroll(() => $('.styleguide__menu').toggleClass('fixed', $(window).scrollTop() > 100));