Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add RichTextField widget
dominik-zeglen6fe6b2ddbdde
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex d1a45dfb40..56888bc094 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -11,6 +11,7 @@ from ...product.models import (ProductImage, ProductVariant, Stock, StockLocation, VariantImage)from .widgets import ImagePreviewWidgetfrom . import ProductBulkAction+from ..widgets import RichTextEditorWidgetclass ProductClassSelectorForm(forms.Form):@@ -137,6 +138,7 @@ class ProductForm(forms.ModelForm):self.product_attributes = self.product_attributes.prefetch_related('values')self.prepare_fields_for_attributes()+ self.fields['description'].widget = RichTextEditorWidget()def prepare_fields_for_attributes(self):for attribute in self.product_attributes:diff --git a/saleor/dashboard/widgets.py b/saleor/dashboard/widgets.pyindex bd0629bd44..f5f8cca7fa 100644--- a/saleor/dashboard/widgets.py+++ b/saleor/dashboard/widgets.py@@ -1,5 +1,6 @@from django import formsfrom django.conf import settings+from django.forms import Textareafrom django_filters.widgets import RangeWidgetfrom django_prices.widgets import PriceInput@@ -22,3 +23,11 @@ class PriceRangeWidget(RangeWidget):class PhonePrefixWidget(StorefrontPhonePrefixWidget):template_name = 'dashboard/order/widget/phone_prefix_widget.html'+++class RichTextEditorWidget(Textarea):+ def __init__(self, attrs=None):+ default_attrs = {'class': 'rich-text-editor'}+ if attrs:+ default_attrs.update(attrs)+ super(Textarea, self).__init__(default_attrs)diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.jsindex 4853272739..cddeaa540e 100644--- a/saleor/static/dashboard/js/components/misc.js+++ b/saleor/static/dashboard/js/components/misc.js@@ -61,7 +61,7 @@ $('#product-is-published').on('click', (e) => {});// WYSIWYG editor-const editor = new MediumEditor('#id_description');+new MediumEditor('.rich-text-editor');// Styleguide sticky right menuonScroll(() => $('.styleguide__menu').toggleClass('fixed', $(window).scrollTop() > 100));diff --git a/saleor/static/dashboard/scss/components/_medium-editor.scss b/saleor/static/dashboard/scss/components/_rich-text-editor.scsssimilarity index 100%rename from saleor/static/dashboard/scss/components/_medium-editor.scssrename to saleor/static/dashboard/scss/components/_rich-text-editor.scssdiff --git a/saleor/static/dashboard/scss/dashboard.scss b/saleor/static/dashboard/scss/dashboard.scssindex 7685a64520..e07dc39019 100644--- a/saleor/static/dashboard/scss/dashboard.scss+++ b/saleor/static/dashboard/scss/dashboard.scss@@ -14,12 +14,12 @@@import "components/form";@import "components/formset";@import "components/list";-@import "components/medium-editor";@import "components/nav";@import "components/pagination";@import "components/modals";@import "components/product-gallery";@import "components/ppoi";+@import "components/rich-text-editor";@import "components/select2";@import "components/search";@import "components/tabs";