Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: image/video resize and html edit in RichText editor #1032

Merged
merged 4 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
"next-auth": "^4.10.3",
"next-i18next": "^11.2.2",
"nookies": "^2.5.2",
"quill-blot-formatter": "^1.0.5",
"quill-html-edit-button": "^2.2.12",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-gtm-module": "2.0.11",
Expand Down
6 changes: 5 additions & 1 deletion src/components/campaigns/grid/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ import FileUpload from 'components/file-upload/FileUpload'
import GenericForm from 'components/common/form/GenericForm'
import SubmitButton from 'components/common/form/SubmitButton'
import FormTextField from 'components/common/form/FormTextField'
import FormRichTextField from 'components/common/form/FormRichTextField'
import AcceptTermsField from 'components/common/form/AcceptTermsField'

import dynamic from 'next/dynamic'
const FormRichTextField = dynamic(() => import('components/common/form/FormRichTextField'), {
ssr: false,
})

import { ApiErrors, isAxiosError, matchValidator } from 'service/apiErrors'
import { useCreateCampaign, useUploadCampaignFiles } from 'service/campaign'
import { CampaignFileRole, FileRole, UploadCampaignFiles } from 'components/campaign-file/roles'
Expand Down
6 changes: 5 additions & 1 deletion src/components/campaigns/grid/EditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import { createSlug } from 'common/util/createSlug'
import GenericForm from 'components/common/form/GenericForm'
import SubmitButton from 'components/common/form/SubmitButton'
import FormTextField from 'components/common/form/FormTextField'
import FormRichTextField from 'components/common/form/FormRichTextField'

import dynamic from 'next/dynamic'
const FormRichTextField = dynamic(() => import('components/common/form/FormRichTextField'), {
ssr: false,
})

import { ApiErrors, isAxiosError, matchValidator } from 'service/apiErrors'
import {
Expand Down
20 changes: 18 additions & 2 deletions src/components/common/form/FormRichTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ import { Typography } from '@mui/material'
import { translateError } from 'common/form/useForm'
import { TranslatableField } from 'common/form/validation'

import dynamic from 'next/dynamic'
import 'react-quill/dist/quill.snow.css'
const ReactQuill = dynamic(() => import('react-quill'), { ssr: false })

import ReactQuill, { Quill } from 'react-quill'

import BlotFormatter from 'quill-blot-formatter/'
Quill.register('modules/blotFormatter', BlotFormatter)

import htmlEditButton from 'quill-html-edit-button'
Quill.register({
'modules/htmlEditButton': htmlEditButton,
})

export type RegisterFormProps = {
name: string
Expand All @@ -30,6 +38,14 @@ const modules = {
// toggle to add extra line breaks when pasting HTML:
matchVisual: false,
},
blotFormatter: {
overlay: {
style: {
border: '2px solid red',
},
},
},
htmlEditButton: {},
}

export default function FormRichTextField({ name }: RegisterFormProps) {
Expand Down
1 change: 0 additions & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ function CustomApp({
defaultOptions: {
queries: {
queryFn,
staleTime: 25000,
},
},
}),
Expand Down
18 changes: 16 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3231,7 +3231,7 @@ deep-is@~0.1.3:
resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz"
integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==

deepmerge@^2.1.1:
deepmerge@^2.0.0, deepmerge@^2.1.1:
version "2.2.1"
resolved "https://registry.npmjs.org/deepmerge/-/deepmerge-2.2.1.tgz"
integrity sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==
Expand Down Expand Up @@ -6528,6 +6528,13 @@ quick-lru@^4.0.1:
resolved "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz"
integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==

quill-blot-formatter@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/quill-blot-formatter/-/quill-blot-formatter-1.0.5.tgz#934cadd10ed9cf68b54b22b99d1e0a6a06f4479d"
integrity sha512-iVmuEdmMIpvERBnnDfosWul6VAVN6tqQRruUzAEwA9ZbQ/Ef7DTHGZDUR4KklXpxM+z50opFp6m1NhNdN6HJhw==
dependencies:
deepmerge "^2.0.0"

quill-delta@^3.6.2:
version "3.6.3"
resolved "https://registry.yarnpkg.com/quill-delta/-/quill-delta-3.6.3.tgz#b19fd2b89412301c60e1ff213d8d860eac0f1032"
Expand All @@ -6537,7 +6544,14 @@ quill-delta@^3.6.2:
extend "^3.0.2"
fast-diff "1.1.2"

quill@^1.3.7:
quill-html-edit-button@^2.2.12:
version "2.2.12"
resolved "https://registry.yarnpkg.com/quill-html-edit-button/-/quill-html-edit-button-2.2.12.tgz#45f7ad9f907252d9efdf9f5b5590834a2f5484f9"
integrity sha512-lrCJmf2XpvkpjpofRW77ShsCj5x9JhL4Mji03aIKZWR6uGKeKal0IKI22buW8tG6hFekTHzv7UBl2Jz0Yd+BTQ==
dependencies:
quill "^1.x"

quill@^1.3.7, quill@^1.x:
version "1.3.7"
resolved "https://registry.yarnpkg.com/quill/-/quill-1.3.7.tgz#da5b2f3a2c470e932340cdbf3668c9f21f9286e8"
integrity sha512-hG/DVzh/TiknWtE6QmWAF/pxoZKYxfe3J/d/+ShUWkDvvkZQVTPeVmUJVu1uE6DDooC4fWTiCLh84ul89oNz5g==
Expand Down