froala / react-froala-wysiwyg

React component for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
562 stars 130 forks source link

"window is not defined" On Next.js 14.0.0 with App Router #385

Open Iulian-Dragomirescu opened 10 months ago

Iulian-Dragomirescu commented 10 months ago

Hi, my code is like this:

import FroalaEditorComponent from "react-froala-wysiwyg";
import { Controller } from "react-hook-form";

// Load a plugin.
import "froala-editor/css/froala_editor.pkgd.min.css";
import "froala-editor/css/froala_style.min.css";
import "froala-editor/js/plugins/char_counter.min.js";
import "froala-editor/js/plugins/colors.min.js";
import "froala-editor/js/plugins/font_size.min.js";
import "froala-editor/js/plugins/lists.min.js";

export default function Editor({ control, errors }) {
  let config = {
    heightMin: 300,
    placeholderText: `Edit Your Content Here!`,
    charCounterCount: true,
  };

  return (
    <>
      <Controller
        name="description"
        control={control}
        rules={{
          required: true,
        }}
        render={({ field }) => (
          <FroalaEditorComponent
            tag="textarea"
            config={config}
            model={field.value}
            onModelChange={field.onChange}
          />
        )}
      />
    </>
  );
}

And the miraculous error..

null
 ✓ Compiled in 1030ms (800 modules)
 ⨯ node_modules\react-froala-wysiwyg\index.js (1:321) @ eval
 ⨯ ReferenceError: window is not defined
[...]

Any idea to fix this? Thanks!

nugthan commented 10 months ago

Question answered on #212