简体   繁体   English

在 django 中调整 TinyMCE 的大小

[英]Resizing TinyMCE in django

I am trying to write a widget to resize my django tinymce but it doesn't seem to work...我正在尝试编写一个小部件来调整我的 django tinymce 的大小,但它似乎不起作用......

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%'}))}

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;我弄清楚了问题所在;我的 static 文件夹中有一个 app.js 文件,该文件具有为 tinymce 编辑器设置样式的配置; 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 }"});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM