0

I am trying to write a widget to resize my django tinymce but it doesn't seem to work...

Does anyone know what the problem is with this code snippet?

from django import forms 
from .models import blog, comment, reply, like, subscription
from tinymce.widgets import TinyMCE

class blogform(forms.ModelForm):
    class Meta:
        model = blog
        fields  = ['content', 'title', 'blog_pic']
        widgets = {'content': (TinyMCE(attrs={'style':'height:100vh; width:60%'}))}
Javad
  • 2,033
  • 3
  • 13
  • 23
BJ_GOST
  • 31
  • 2

1 Answers1

0

I figured out what the problem was;I had an app.js file in my static folder that had a configuration to style the tinymce editor; all i had to do was change the width or height to fit my needs...this is the code

    tinymce.init({
        selector: "textarea",      
        height: "700",
        width: "60%",
        plugins: "insertdatetime media image preview",
        toolbar: "undo redo |  bold italic | alignleft alignright                           aligncenter alignjustify | image media | preview",
        image_title: true,
image_caption: true,
automatic_uploads: true,
image_advtab: true,
file_picker_types: "image media",

file_picker_callback: function (cb, value, meta) {
  var input = document.createElement("input");
  input.setAttribute("type", "file");
  if (meta.filetype == "image") {
      input.setAttribute("accept", "image/*");}
  if (meta.filetype == "media") {
  input.setAttribute("accept", "video/*");}

  input.onchange = function () {     
      var file = this.files[0];
      var reader = new FileReader();
      reader.onload = function () {
          var id = "blobid" + (new Date()).getTime();
          var blobCache =  tinymce.activeEditor.editorUpload.blobCache;
          var base64 = reader.result.split(",")[1];
          var blobInfo = blobCache.create(id, file, base64);
          blobCache.add(blobInfo);
         cb(blobInfo.blobUri(), { title: file.name });
       };
       reader.readAsDataURL(file);
   };
   input.click();
},
content_style: "body { font-family:Helvetica,Arial,sans-serif; font-size:14px }"});
BJ_GOST
  • 31
  • 2