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

Cannot read properties of undefined (reading 'width') #108

Open
SathyanaryanaNaidu opened this issue Nov 27, 2024 · 1 comment
Open

Cannot read properties of undefined (reading 'width') #108

SathyanaryanaNaidu opened this issue Nov 27, 2024 · 1 comment

Comments

@SathyanaryanaNaidu
Copy link

const modules = {
  table: false, // disable default quill table module in favor of quill-better-table
  'better-table': {
    operationMenu: {
      // these fields have bugs in the module so we're just disabling them since they're not necessary
      items: {
        unmergeCells: false,
        mergeCells: false,
        insertColumnRight: false, // inserting columns can be handled by "insert column left"
      },
    },
  }, // use defaults for quill-better-table
  imageResize: {
    modules: ['Resize', 'DisplaySize', 'Toolbar'], // Resizing options
  },
  toolbar: [
    [{ header: [1, 2, 3, false] }], // Header options
    [{ font: [] }], // Font family options
    [{ color: [] }, { background: [] }], // Color and background color
    ['bold', 'italic', 'underline', 'strike'],
    [{ list: 'ordered' }, { list: 'bullet' }],
    ['link', 'image'],
    ['clean'],
    ['table'],
  ],
};
const QuillEditor = React.memo<QuillEditorPropType>((props: QuillEditorPropType) => {
  if (__BROWSER__) {
    registerEmbeds(ReactQuill.Quill);
    ReactQuill.Quill.register(
      {
        'modules/better-table': QuillBetterTable,
      },
      true
    );
  }

  const {
    modules,
    formats,
    onEditorRendered,
    onChange,
    placeholder,
    theme = 'snow',
    value,
    style,
    className = '',
    isDisabled = false,
    id,
    bounds,
    hashtags = [],
    ...rest
  } = props;

  const [css] = useStyletron();
  const editorRef = useRef(null);
  const editorWrapperId = useRef(uuidv4()).current;
  const anchor = useRef(-1);

  const memoisedModules = useMemo(() => merge({}, QUILL_MODULES, modules), [modules]);
  const memoisedFormats = useMemo(() => (formats ? formats : QUILL_SUPPORTED_FORMATS), [formats]);

  return (
    <div id={containerID} className={textDirectionStyles} onKeyDown={handleKeyDown}>
      <ReactQuill
        id={id}
        ref={editorRef}
        modules={memoisedModules}
        formats={memoisedFormats}
        // @ts-ignore
        onEditorRendered={onEditorRendered}
        onChange={handleChange}
        placeholder={placeholder}
        theme={theme}
        style={style}
        className={className}
        readOnly={isDisabled}
        bounds={bounds}
        scrollingContainer={`#${containerID}`}
        {...valueObj}
        {...keyObj}
        {...rest}
      />
   )
});

versions

  "quill-better-table": "^1.2.10",
  "quill-delta": "^5.1.0",
  "react-quill-new": "^3.3.2",
@SathyanaryanaNaidu
Copy link
Author

is the quill-better-table team is still on this project ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant