I am trying to create a custom font size drop-down for the toolbar in ReactQuill. I decided to strip out the original code for font-size from quilljs and expand on it (as seen below):
import Parchment from 'parchment';
let SizeClass = new Parchment.Attributor.Class('size', 'ql-size', {
scope: Parchment.Scope.INLINE,
whitelist: ['8', '9', '10', '11', '12', '13', '14', '16', '18', '24', '36']
});
let SizeStyle = new Parchment.Attributor.Style('size', 'font-size', {
scope: Parchment.Scope.INLINE,
whitelist: ['8px', '9px', '10px', '11px', '12px', '13px', '14px', '16px', '18px', '24px', '36px']
});
export { SizeClass, SizeStyle };
When I try to import and register the SizeStyle in my App.js I am receiving the error in the title.
import React, { Component } from 'react';
import ReactQuill, {Quill} from 'react-quill'
import { SizeClass, SizeStyle } from './font-size'
import { ImageDrop } from 'quill-image-drop-module'
import { ImageResize } from 'quill-image-resize-module'
Quill.register(SizeStyle, true)
Quill.register('modules/imageDrop', ImageDrop)
Quill.register('modules/imageResize', ImageResize)
I then have my own HTML toolbar that has all of the size attributes in a drop down:
<div id="toolbar">
<select className="ql-size">
<option value="8px"></option>
<option value="9px"></option>
<option value="10px"></option>
<option value="11px"></option>
<option value="12"></option>
<option value="13"></option>
<option value="14"></option>
<option value="16"></option>
<option value="18"></option>
<option value="24"></option>
<option value="36"></option>
</select>
</div>
any suggestions?!
I was getting the same error until I changed how I was importing Parchment.
Try var Parchment = Quill.import('parchment');
instead of import Parchment from 'parchment';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With