说明

集成库文件

1、将如下编辑器源码文件放入工程目录, 示例:ThinkEditor.Vue3.Ts.element-plus.Demo\src\components\editor

  • 编辑器源码目录可自定义

2、将编辑器库文件ThinkEditor.wasm部署到工程静态资源目录,示例:ThinkEditor.Vue3.Ts.element-plus.Demo\public\static\editor

  • 编辑器库文件目录在使用ThinkEditor时可通过参数editorParam.lib指定路径

3、第三方结合自己的项目(前端框架)确保编辑器显示区域(containerDiv)可见

  • 编辑器不会影响containerDiv本身的行为和尺寸。所以在不引入编辑器到项目中时,应当编写前端代码确保编辑器显示区域(containerDiv)可见
  • containerDiv的命名第三方可自定义,确保和thinkEditor.Load(containerDiv)中使用的一致即可

打开文档

打开文档
HTML
|
运行代码
var thinkEditor = new ThinkEditor(editorParam);

await thinkEditor.InitAsync();

/********************************************************************/
thinkEditor.ParseDoc(docName, docXml, E_DOCS_ORGANIZE_MODE.Single);
/********************************************************************/

thinkEditor.SetViewMode(E_VIEW_MODE.Edit);

thinkEditor.Load(document.querySelector("#container"));
新建文档
HTML
|
运行代码
var thinkEditor = new ThinkEditor(editorParam);

await thinkEditor.InitAsync();

/********************************************************************/
thinkEditor.NewDoc(docName, E_DOC_TYPE.Entity);
/********************************************************************/

thinkEditor.SetViewMode(E_VIEW_MODE.Edit);

thinkEditor.Load(document.querySelector("#container"));

隐藏文档

  • 文档不直接在浏览器显示时调用,比如父级containerDiv隐藏或关闭时
  • 编辑器不再与containerDiv关联
  • 文档不再实时绘制
thinkEditor.UnLoad();

显示文档

  • 文档恢复在浏览器显示时调用
  • 编辑器再次和containerDiv关联(每次Load的containerDiv可以不同)
  • 文档恢复实时绘制
thinkEditor.Load(containerDiv);

关闭文档

  • 关闭文档,编辑器停止工作,内存即刻释放。比如UI文档tab页签被关闭,或点击了文档关闭按钮
  • 该thinkEditor一般不再给其他新文档使用
//关闭文档
thinkEditor.CloseDoc(docName);
或
thinkEditor.CloseAllDoc();

//释放编辑器
thinkEditor.UnInit();
文档更新时间: 2025-04-16 19:49   作者:admin