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

nextjs question plz..... #374

Open
suCozy opened this issue Jul 19, 2023 · 0 comments
Open

nextjs question plz..... #374

suCozy opened this issue Jul 19, 2023 · 0 comments

Comments

@suCozy
Copy link

suCozy commented Jul 19, 2023

I'm going to write a froala editor on nextjs.
I'm currently studying, but I can't click the image upload button itself, so I wonder what the problem is. The byurl part of the Insert image works, but clicking on the upload image does not change anything

/* eslint-disable no-return-await */
/* eslint-disable import/extensions */
import dynamic from 'next/dynamic';
import 'froala-editor/css/plugins/colors.min.css';
// import 'froala-editor/js/plugins/image.min.js';

const FroalaEditor = dynamic(
  async () => {
    const editorModule = await import('react-froala-wysiwyg');

    await Promise.all([
      import('froala-editor/js/plugins/align.min.js'),
      import('froala-editor/js/plugins/font_size.min.js'),
      import('froala-editor/js/plugins/link.min.js'),
      import('froala-editor/js/plugins/file.min.js'),
      import('froala-editor/js/plugins/files_manager.min.js'),
      import('froala-editor/js/plugins/colors.min.js'),
      import('froala-editor/js/plugins/image.min.js'),
      //   import('froala-editor/js/plugins/image_manager.min.js'),
      import('froala-editor/js/plugins/table.min.js'),
    ]);

    return editorModule;
  },
  { ssr: false }
);

export default function MyComponent({ content, setContent }) {
  const handleImageUpload = (e, editor, files) => {
    console.log(files);
    e.preventDefault();
  };

  const config = {
    pluginsEnabled: [
      'fontSize',
      'image',
      'imageManager',
      'table',
      'align',
      'colors',
      'emoticons',
      'paragraphFormat',
      'paragraphStyle',
      'quote',
      'url',
    ],
    toolbarButtons: [
      'fontSize',
      'colors',
      'bold',
      'italic',
      'underline',
      'strikeThrough',
      '|',

      'textColor',
      'backgroundColor',
      '|',

      'alignLeft',
      'alignCenter',
      'alignRight',
      '|',

      'insertImage',
      'insertTable',
      'horizon',

      '|',
      'insertHR',
      'insertFile',
      'fileM',
    ],
    fontSize: [
      '8',
      '10',
      '12',
      '14',
      '18',
      '24',
      '30',
      '36',
      '48',
      '60',
      '72',
      '96',
    ],

    fontSizeDefaultSelection: '12',
    fontFamily: {
      'Arial,Helvetica,sans-serif': 'Arial',
      'Georgia,serif': 'Georgia',
      'Impact,Charcoal,sans-serif': 'Impact',
      'Tahoma,Geneva,sans-serif': 'Tahoma',
      "'Times New Roman',Times,serif": 'Times New Roman',
      'Verdana,Geneva,sans-serif': 'Verdana',
    },
    fontFamilySelection: true,

    imageEditButtons: [
      'imageReplace',
      'imageAlign',
      'imageRemove',
      '|',
      'imageLink',
      'linkOpen',
      'linkEdit',
      'linkRemove',
      '-',
      'imageDisplay',
      'imageStyle',
      'imageAlt',
      'imageSize',
    ],
    placeholderText: 'Edit Your Content Here!',

    imageInsertButtons: ['imageBack', '|', 'imageUpload', 'imageByURL'],
    imageUploadMethod: 'POST',
    // Set the image upload URL.
    imageUploadURL: 'upload.php',

    imageManagerLoadURL: 'image_manager/load_images.php',
    // Set the image delete URL.
    imageManagerDeleteURL: 'delete_image.php',
    // Validation
    imageAllowedTypes: ['jpeg', 'jpg', 'png'],
    // Set max image size to 10MB.
    imageMaxSize: 1024 * 1024 * 10,
    events: {
      'froalaEditor.image.beforeUpload': function () {
        console.log('digh');
      },
    },
  };

  return (
    <div>
      <FroalaEditor
        tag="textarea"
        model={content}
        onModelChange={(newContent) => setContent(newContent)}
        config={config}
      />
    </div>
  );
}
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