Skip to content

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

Make editor pretty

dominik-zeglen1d81d7020ca9
diff --git a/saleor/static/dashboard/images/close.svg b/saleor/static/dashboard/images/close.svg
new file mode 100644
index 0000000000..6915a6b345
--- /dev/null
+++ b/saleor/static/dashboard/images/close.svg
@@ -0,0 +1,4 @@
+<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
+ <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
+ <path d="M0 0h24v24H0z" fill="none"/>
+</svg>
diff --git a/saleor/static/dashboard/images/done.svg b/saleor/static/dashboard/images/done.svg
new file mode 100644
index 0000000000..a7aebbc0a1
--- /dev/null
+++ b/saleor/static/dashboard/images/done.svg
@@ -0,0 +1,4 @@
+<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
+ <path d="M0 0h24v24H0z" fill="none"/>
+ <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/>
+</svg>
diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.js
index cddeaa540e..08f77731f3 100644
--- a/saleor/static/dashboard/js/components/misc.js
+++ b/saleor/static/dashboard/js/components/misc.js
@@ -61,7 +61,63 @@ $('#product-is-published').on('click', (e) => {
});
// WYSIWYG editor
-new MediumEditor('.rich-text-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));
diff --git a/saleor/static/dashboard/scss/components/_rich-text-editor.scss b/saleor/static/dashboard/scss/components/_rich-text-editor.scss
index 1bfbcabfa7..f7c0ee7c25 100644
--- a/saleor/static/dashboard/scss/components/_rich-text-editor.scss
+++ b/saleor/static/dashboard/scss/components/_rich-text-editor.scss
@@ -4,6 +4,7 @@
&-under:after {
border-color: $medium-editor-bgcolor transparent transparent transparent;
top: $medium-editor-button-size;
+ z-index: -1;
}
&-over:before {
border-color: transparent transparent $medium-editor-bgcolor transparent;
@@ -64,6 +65,7 @@
a {
color: $medium-editor-link-color;
transform: translateY(2px);
+ float: right;
}
}
@@ -72,8 +74,14 @@
box-sizing: border-box;
color: $medium-editor-link-color;
height: $medium-editor-button-size;
- padding-left: 16px;
width: 220px;
+ border-bottom: 1px $grey-color solid !important;
+ margin-bottom: .5rem !important;
+ padding: 0 1rem !important;
+ &:active, &:focus {
+ border-bottom-color: $secondary-color !important;
+ box-shadow: 0 0 0 1px $secondary-color;
+ }
&::placeholder {
color: rgba($medium-editor-placeholder-color, .8);