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

Vditor lute is undefined and TypeError - e is null #1494

Closed
Sabin-Adhikari opened this issue Nov 7, 2023 · 1 comment
Closed

Vditor lute is undefined and TypeError - e is null #1494

Sabin-Adhikari opened this issue Nov 7, 2023 · 1 comment

Comments

@Sabin-Adhikari
Copy link

Sabin-Adhikari commented Nov 7, 2023

编辑模式

普通模式(编)

描述问题

在编辑模式下使用 vditor 时出现两个错误。即使内容为空也会出现问题。

  1. this.vditor.lute 未定义
  2. 类型错误 - e 为 null

预期成绩

渲染 vditor 时不应出现错误。

萤幕截图或录影

image
image (1)

版本资讯

  • 版本:3.8.7
  • 作业系统: Mac OS
  • 浏览器:火狐

其他资讯

对于问题#1:我可以看到 ute.min.js 已正确下载。当尝试在单一画面中使用 3 4 个独立的 vditor 实例时,我注意到了 this.vditor.lute 问题。我使用以下程式码来初始化编辑器。

对于问题 #2:TypeError(e 为 null)间歇性发生。

    try{
      const activeEl = document.activeElement as HTMLElement
      const lang = this.getEditorLanguage();
      this.vditor = new Vditor(this.id, {
        lang: lang,
        minHeight: this.getMinimumHeight(),
        height: 'auto',
        placeholder: this.placeHolder ? this.placeHolder : '',
        toolbar: [
          "headings",
          "bold",
          "italic",
          "strike",
          "link",
          "|",
          "list",
          "ordered-list",
          "check",
          "outdent",
          "indent",
          "|",
          "quote",
          "line",
          "code",
          "inline-code",
          "insert-before",
          "insert-after",
          "|",
          "table",
          "|",
          "undo",
          "redo",
          "|",
          "fullscreen",
          "edit-mode",
          {
            name: "more",
            toolbar: [
              "both",
              "code-theme",
              "content-theme",
              "export",
              "outline",
              "preview",
              "devtools",
              "info",
              "help",
            ],
          },
        ],
        toolbarConfig: {
          pin: true,
        },
        cache: {
          enable: false,
        },
        value: this.value === undefined || this.value ==="" || this.value=== null ? " " : this.value ,
        after: () => {
            this.vditor?.setValue(this?.value);
            // stop autofocus
           setTimeout(() => { activeEl.focus() }, 100)        
        },
        blur: (value) =>this.change.emit({id: this.id,value : value}),
      
      })
    }
    catch(error){
      console.log("Error caught while initializing Vditor",error);
    }
  
@Vanessa219
Copy link
Owner

this.vditor.lute 是在哪里使用过?是不是作用域不对? Demo 上没有这样的问题。

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

2 participants