首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Web组件中使用Wiris编辑器

在Web组件中使用Wiris编辑器
EN

Stack Overflow用户
提问于 2017-08-15 22:48:51
回答 1查看 519关注 0票数 0

我已经创建了一个托管Wiris的Web组件。然而,当组件被渲染时,Wiris编辑器的格式(非常)很糟糕:

你可以在here上看到这个问题。

代码如下:

代码语言:javascript
复制
class WirisComponent extends HTMLElement {
 constructor() {
  // Always call super first in constructor
  super();

  // Create a shadow root
  var shadow = this.attachShadow( { mode: 'open' } );

  // Create a div to host the Wiris editor
  var div = document.createElement('div');
  div.id = 'editorContainer';

  var wirisDefaultConfig = {
    'language': 'en'
  };

  var editor = com.wiris.jsEditor.JsEditor.newInstance(wirisDefaultConfig);

  // Insert the Wiris instance into the div
  editor.insertInto(div);      

  // Append it to the shadow route
  shadow.appendChild(div);
 }
}

// Define the new element
customElements.define('wiris-component', WirisComponent);

HTML标记是:

代码语言:javascript
复制
<wiris-component></wiris-component>

请注意,我已经在Chrome上尝试过了,它完全支持web组件。

知道问题出在哪里吗?该问题是否与this问题中发现的样式问题有关?

EN

回答 1

Stack Overflow用户

发布于 2017-08-16 00:29:20

不要使用Shadow DOM:与库一起导入的样式不适用于它。

代码语言:javascript
复制
class WirisComponent extends HTMLElement {
  connectedCallback() {
    var wirisDefaultConfig = {
      'language': 'en'
    };

    var editor = com.wiris.jsEditor.JsEditor.newInstance(wirisDefaultConfig);
    editor.insertInto(this);
  }
}

// Define the new element
customElements.define('wiris-component', WirisComponent);
代码语言:javascript
复制
<script src="https://www.wiris.net/demo/editor/editor"></script>
<wiris-component></wiris-component>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45695409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档