@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.1 → 1.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,90 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/tools/UeditorResourceLoader.ts
20
+ var UeditorResourceLoader_exports = {};
21
+ __export(UeditorResourceLoader_exports, {
22
+ default: () => UeditorResourceLoader_default
23
+ });
24
+ module.exports = __toCommonJS(UeditorResourceLoader_exports);
25
+ var import_loadScript = require("./loadScript");
26
+ var UeditorResourceLoader = class {
27
+ constructor() {
28
+ this.callbackList = [];
29
+ this.errorCallbackList = [];
30
+ this.isReady = false;
31
+ this.loading = false;
32
+ this.initError = false;
33
+ }
34
+ static async startLoad(jsList) {
35
+ const inst = this.getInstance();
36
+ if (!inst.loading && !inst.isReady || inst.initError) {
37
+ inst.loading = true;
38
+ inst.initError = false;
39
+ try {
40
+ await (0, import_loadScript.loadScriptSync)(jsList);
41
+ if (window.UE) {
42
+ inst.isReady = true;
43
+ inst.loading = false;
44
+ while (inst.callbackList.length) {
45
+ const cb = inst.callbackList.pop();
46
+ cb && cb();
47
+ }
48
+ } else {
49
+ inst.loading = false;
50
+ inst.isReady = false;
51
+ inst.initError = true;
52
+ while (inst.errorCallbackList.length) {
53
+ const cb = inst.errorCallbackList.pop();
54
+ cb && cb();
55
+ }
56
+ }
57
+ } catch (error) {
58
+ inst.loading = false;
59
+ inst.isReady = false;
60
+ }
61
+ }
62
+ }
63
+ static getInstance() {
64
+ if (!this.instance) {
65
+ this.instance = new UeditorResourceLoader();
66
+ }
67
+ return this.instance;
68
+ }
69
+ /**
70
+ * 加载完成执行
71
+ * @param callback 回调函数
72
+ */
73
+ static onReady(callback) {
74
+ const inst = this.getInstance();
75
+ if (inst.isReady) {
76
+ callback();
77
+ } else {
78
+ inst.callbackList.push(callback);
79
+ }
80
+ }
81
+ /**
82
+ * 资源加载失败执行
83
+ * @param callback
84
+ */
85
+ static onLoadError(callback) {
86
+ const inst = this.getInstance();
87
+ inst.errorCallbackList.push(callback);
88
+ }
89
+ };
90
+ var UeditorResourceLoader_default = UeditorResourceLoader;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 同步加载js
3
+ * @param strs 路径地址
4
+ */
5
+ export declare const loadScriptSync: (strs: string[]) => Promise<void>;
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/tools/loadScript.ts
20
+ var loadScript_exports = {};
21
+ __export(loadScript_exports, {
22
+ loadScriptSync: () => loadScriptSync
23
+ });
24
+ module.exports = __toCommonJS(loadScript_exports);
25
+ var loadScriptSync = async (strs) => {
26
+ for (let i = 0; i < strs.length; i += 1) {
27
+ const script = document.createElement("script");
28
+ script.src = strs[i];
29
+ script.async = false;
30
+ document.body.appendChild(script);
31
+ await new Promise((resolve) => {
32
+ script.onload = resolve;
33
+ });
34
+ }
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ loadScriptSync
39
+ });
package/lib/type.d.ts ADDED
@@ -0,0 +1,142 @@
1
+ import React from 'react';
2
+ interface IUeditorStype extends React.CSSProperties {
3
+ toolbarColor?: string;
4
+ }
5
+ export interface ILcdpUeditorProps {
6
+ /**
7
+ * ueditor产物路径 默认 ./ueditor-resource
8
+ */
9
+ ueditorPath?: string;
10
+ /**
11
+ * 样式类名
12
+ */
13
+ className?: string;
14
+ /**
15
+ * 编辑器样式
16
+ */
17
+ style?: IUeditorStype;
18
+ /**
19
+ * 禁用
20
+ */
21
+ disabled?: boolean;
22
+ /**
23
+ * 富文本配置
24
+ */
25
+ config?: {
26
+ /**
27
+ * 编辑器高度 默认300px
28
+ */
29
+ height?: number;
30
+ /**
31
+ * 图片类型
32
+ */
33
+ imageType: 'file' | 'base64';
34
+ /**
35
+ * 上传大小限制,单位B,默认值:10485760
36
+ */
37
+ imageMaxSize?: number;
38
+ /**
39
+ * 上传图片格式显示 [".png", ".jpg", ".jpeg", ".gif", ".bmp"]
40
+ */
41
+ imageAllowFiles?: string[];
42
+ /**
43
+ * 上传大小限制,单位B,默认值:104857600
44
+ */
45
+ fileMaxSize?: number;
46
+ /**
47
+ * 上传文件格式限制
48
+ */
49
+ fileAllowFiles?: string[];
50
+ /**
51
+ * 上传音频大小限制,单位B,默认值:104857600
52
+ */
53
+ audioMaxSize?: number;
54
+ /**
55
+ * 上传音频格式限制
56
+ */
57
+ audioAllowFiles?: string[];
58
+ /**
59
+ * 上传视频大小限制,单位B,默认值:104857600
60
+ */
61
+ videoMaxSize?: number;
62
+ /**
63
+ * 上传视频格式限制
64
+ */
65
+ videoAllowFiles?: string[];
66
+ };
67
+ /**
68
+ * 语言 默认 zh-cn
69
+ * zh-cn 中文 en 英文
70
+ */
71
+ lang?: 'zh-cn' | 'en' | 'zh-tw';
72
+ /**
73
+ * 上传方法
74
+ * @param file 文件
75
+ * @param fileType 文件类型
76
+ */
77
+ uploadFunction(file: File): Promise<{
78
+ state: 'SUCCESS' | 'FAIL';
79
+ url?: string;
80
+ title?: string;
81
+ original?: string;
82
+ }>;
83
+ /**
84
+ * 编辑器挂载
85
+ * @param inst
86
+ */
87
+ onMount?(inst: ILcdpUeditorInst): void;
88
+ /**
89
+ * 内容
90
+ */
91
+ value?: string;
92
+ /**
93
+ * 内容改变事件
94
+ * @param val 编辑器内容
95
+ */
96
+ onChange?(val: string): void;
97
+ }
98
+ export interface ILcdpUeditorInst {
99
+ /**
100
+ * 获取整个html内容
101
+ */
102
+ getAllHtml(): string;
103
+ /**
104
+ * 获取内容
105
+ */
106
+ getContent(): string;
107
+ /**
108
+ * 设置内容
109
+ * @param content 内容
110
+ * @param isAppend 是否追加
111
+ */
112
+ setContent(content: string, isAppend?: boolean): void;
113
+ /**
114
+ * 获取纯文本内容
115
+ */
116
+ getContentTxt(): string;
117
+ /**
118
+ * 获得带格式的纯文本
119
+ */
120
+ getPlainTxt(): string;
121
+ /**
122
+ * 判断是否有内容
123
+ */
124
+ hasContents(): boolean;
125
+ /**
126
+ * 使编辑器获得焦点
127
+ */
128
+ focus(): void;
129
+ /**
130
+ * 编辑器是否获得焦点
131
+ */
132
+ isFocus(): boolean;
133
+ /**
134
+ * 编辑器失去焦点
135
+ */
136
+ setBlur(): void;
137
+ /**
138
+ * 获得当前选中的文本
139
+ */
140
+ getSelectText(): string;
141
+ }
142
+ export {};
package/lib/type.js ADDED
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/type.ts
16
+ var type_exports = {};
17
+ module.exports = __toCommonJS(type_exports);
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@lingxiteam/lcdp-ueditor-react",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.11",
4
4
  "module": "es/index.js",
5
+ "main": "lib/index.js",
5
6
  "license": "MIT",
6
7
  "files": [
7
8
  "ueditor-resource",
8
- "es"
9
+ "es",
10
+ "lib"
9
11
  ],
10
12
  "publishConfig": {
11
13
  "access": "public",
@@ -16,7 +18,7 @@
16
18
  "scripts": {
17
19
  "build": "father build",
18
20
  "dev": "father dev",
19
- "prepublishOnly": "npm run build"
21
+ "prepublishOnly": "npm run build && cd ../../ueditor-plus && npm run prepublish"
20
22
  },
21
23
  "peerDependencies": {
22
24
  "react": "^16.12.0 || ^17.0.0"
@@ -277,7 +277,7 @@
277
277
  const location = window.parent.location;
278
278
  const host = location.protocol + '//' + location.host + location.pathname;
279
279
  if (url) {
280
- preview.innerHTML = '<img src="' + host + url + '" width="' + width + '" height="' + height + '" border="' + border + 'px solid #000" title="' + title + '" />';
280
+ preview.innerHTML = '<img src="' + encodeURI(host + url) + '" width="' + width + '" height="' + height + '" border="' + border + 'px solid #000" title="' + title + '" />';
281
281
  }
282
282
  },
283
283
  getInsertList: function () {
@@ -307,7 +307,7 @@
307
307
 
308
308
  $G("preview").innerHTML = '<div class="previewMsg"><span>' + lang.urlError + '</span></div>' +
309
309
  '<iframe class="previewVideo" ' +
310
- ' src="' + host + conUrl + '"' +
310
+ ' src="' + encodeURI(host + conUrl) + '"' +
311
311
  ' width="' + 420 + '"' +
312
312
  ' height="' + 280 + '"' +
313
313
  ' frameborder=0 allowfullscreen>' +
@@ -1,146 +1,146 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <title>UEditorPlus 完整演示</title>
5
- <meta name="viewport" content="width=device-width, minimum-scale=0.5, maximum-scale=5, user-scalable=no">
6
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
8
- <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
9
- <script type="text/javascript" charset="utf-8" src="ueditor.all.js"></script>
10
- <script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?8c5d8442"></script>
11
- <script src="./plugins/demo/demo.js"></script>
12
- <script>
13
- // window.UEDITOR_CONFIG.toolbars[0].push('undo');
14
- </script>
15
- <script>var _hmt = _hmt || [];
16
- (function () {
17
- var hm = document.createElement("script");
18
- hm.src = "https://hm.baidu.com/hm.js?f84f35a44b5cc5c0b10c3fabdf0f322b";
19
- var s = document.getElementsByTagName("script")[0];
20
- s.parentNode.insertBefore(hm, s);
21
- })();</script>
22
- <style>
23
- :root {
24
- /*--ueditor-top-offset: 20px;*/
25
- }
26
- </style>
27
- <link rel="stylesheet" href="./style.css"/>
28
- </head>
29
- <body class="demo-editor-page">
30
- <div>
31
- <h1>完整示例</h1>
32
- <div>
33
- <script id="editor" type="text/plain" style="height:300px;">
34
- <h1>
35
- 你好 UEditorPlus
36
- </h1>
37
- <p>
38
- UEditorPlus 是基于 UEditor 二次开发的富文本编辑器,让 UEditor <span style="color: #E36C09;">焕<span style="color: #0070C0;">然</span><span style="color: #31859B;"><span style="color: #00B050;">一</span><span style="color: #FF0000;">新</span></span></span>
39
- </p>
40
-
41
- <table data-sort="sortDisabled">
42
- <tbody>
43
- <tr class="firstRow">
44
- <td valign="top" style="word-break: break-all;" rowspan="1" colspan="3">
45
- 我是表格
46
- </td>
47
- </tr>
48
- <tr>
49
- <td width="273" valign="top" style="word-break: break-all;">
50
- 如果
51
- </td>
52
- <td width="273" valign="top" style="word-break: break-all;">
53
- 有一天
54
- </td>
55
- <td width="273" valign="top" style="word-break: break-all;">
56
- 我离开了
57
- </td>
58
- </tr>
59
- <tr>
60
- <td valign="top" colspan="1" rowspan="1" style="word-break: break-all;">
61
- 怎么才能
62
- </td>
63
- <td valign="top" colspan="1" rowspan="1" style="word-break: break-all;">
64
- 证明我
65
- </td>
66
- <td valign="top" colspan="1" rowspan="1" style="word-break: break-all;">
67
- 曾经来过
68
- </td>
69
- </tr>
70
- </tbody>
71
- </table>
72
- <pre class="brush:html;toolbar:false">&lt;div&gt;
73
- &lt;span&gt;这里是HTML标签&lt;/span&gt;
74
- &lt;/div&gt;</pre>
75
- <h2>
76
- 公式支持
77
- </h2>
78
- <p>
79
- <img src="https://r.latexeasy.com/image.svg?%5Cint%20%5Cfrac%7B1%7D%7Bx%7D%20dx%20%3D%20%5Cln%20%5Cleft%7C%20x%20%5Cright%7C%20%2B%20C"
80
- data-formula-image="%5Cint%20%5Cfrac%7B1%7D%7Bx%7D%20dx%20%3D%20%5Cln%20%5Cleft%7C%20x%20%5Cright%7C%20%2B%20C"/>
81
- </p>
82
- <p>
83
- <br/>
84
- </p>
85
-
86
- </script>
87
- </div>
88
- <div id="btns" style="margin-top:20px;">
89
- <div>
90
-
91
- <button onclick="alert(UE.getEditor('editor').getAllHtml())">获得整个html的内容</button>
92
- <button onclick="alert(UE.getEditor('editor').getContent())">获得内容</button>
93
- <button onclick="UE.getEditor('editor').setContent('<p>欢迎使用 UEditorPlus</p>', false)">写入内容</button>
94
- <button onclick="UE.getEditor('editor').setContent('<p>欢迎使用 UEditorPlus</p>', true)">追加内容</button>
95
- <button onclick="alert(UE.getEditor('editor').getContentTxt())">获得纯文本</button>
96
- <button onclick="alert(UE.getEditor('editor').getPlainTxt())">获得带格式的纯文本</button>
97
- <button onclick="alert(UE.getEditor('editor').hasContents())">判断是否有内容</button>
98
- <button onclick="UE.getEditor('editor').focus()">使编辑器获得焦点</button>
99
- <button onmousedown="isFocus()">编辑器是否获得焦点</button>
100
- <button onmousedown="setBlur()">编辑器失去焦点</button>
101
- <button onclick="getSelectText()">获得当前选中的文本</button>
102
- <button onclick="UE.getEditor('editor').execCommand('insertHtml', '插入的内容')">插入内容</button>
103
- <button onclick="UE.getEditor('editor').setEnabled()">设定可编辑</button>
104
- <button onclick="UE.getEditor('editor').setDisabled('fullscreen')">设定不可编辑</button>
105
- <button onclick="UE.getEditor('editor').setHide()">隐藏编辑器</button>
106
- <button onclick="UE.getEditor('editor').setShow()">显示编辑器</button>
107
- <button onclick="UE.getEditor('editor').setHeight(300)">设置固定高度</button>
108
- <button onclick="UE.getEditor('editor')">创建编辑器</button>
109
- <button onclick="UE.getEditor('editor').destroy()">销毁编辑器</button>
110
- <button onclick="alert( UE.getEditor('editor').execCommand('get_auto_save_content') )">草稿箱-获取</button>
111
- <button onclick="UE.getEditor('editor').execCommand('clear_auto_save_content'); alert('已清空草稿箱')">草稿箱-清空
112
- </button>
113
- <button onclick="UE.getEditor('editor').execCommand('set_auto_save_content'); alert('已保存')">草稿箱-立即保存
114
- </button>
115
- <button onclick="UE.getEditor('editor').execCommand('auto_save_restore')">草稿箱-恢复到编辑器</button>
116
- </div>
117
- </div>
118
-
119
- <script type="text/javascript">
120
- var ue = UE.getEditor('editor',{
121
- // autoHeightEnabled: false,
122
- });
123
- ue.on('contentchange', function () {
124
- // console.log('contentchange', ue.getContent());
125
- });
126
-
127
- function isFocus(e) {
128
- alert(UE.getEditor('editor').isFocus());
129
- UE.dom.domUtils.preventDefault(e)
130
- }
131
-
132
- function setBlur(e) {
133
- UE.getEditor('editor').blur();
134
- UE.dom.domUtils.preventDefault(e)
135
- }
136
-
137
- function getSelectText() {
138
- var range = UE.getEditor('editor').selection.getRange();
139
- range.select();
140
- var txt = UE.getEditor('editor').selection.getText();
141
- alert(txt)
142
- }
143
- </script>
144
- </div>
145
- </body>
146
- </html>
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>UEditorPlus 完整演示</title>
5
+ <meta name="viewport" content="width=device-width, minimum-scale=0.5, maximum-scale=5, user-scalable=no">
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
8
+ <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="ueditor.all.js"></script>
10
+ <script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?8c5d8442"></script>
11
+ <script src="./plugins/demo/demo.js"></script>
12
+ <script>
13
+ // window.UEDITOR_CONFIG.toolbars[0].push('undo');
14
+ </script>
15
+ <script>var _hmt = _hmt || [];
16
+ (function () {
17
+ var hm = document.createElement("script");
18
+ hm.src = "https://hm.baidu.com/hm.js?f84f35a44b5cc5c0b10c3fabdf0f322b";
19
+ var s = document.getElementsByTagName("script")[0];
20
+ s.parentNode.insertBefore(hm, s);
21
+ })();</script>
22
+ <style>
23
+ :root {
24
+ /*--ueditor-top-offset: 20px;*/
25
+ }
26
+ </style>
27
+ <link rel="stylesheet" href="./style.css"/>
28
+ </head>
29
+ <body class="demo-editor-page">
30
+ <div>
31
+ <h1>完整示例</h1>
32
+ <div>
33
+ <script id="editor" type="text/plain" style="height:300px;">
34
+ <h1>
35
+ 你好 UEditorPlus
36
+ </h1>
37
+ <p>
38
+ UEditorPlus 是基于 UEditor 二次开发的富文本编辑器,让 UEditor <span style="color: #E36C09;">焕<span style="color: #0070C0;">然</span><span style="color: #31859B;"><span style="color: #00B050;">一</span><span style="color: #FF0000;">新</span></span></span>
39
+ </p>
40
+
41
+ <table data-sort="sortDisabled">
42
+ <tbody>
43
+ <tr class="firstRow">
44
+ <td valign="top" style="word-break: break-all;" rowspan="1" colspan="3">
45
+ 我是表格
46
+ </td>
47
+ </tr>
48
+ <tr>
49
+ <td width="273" valign="top" style="word-break: break-all;">
50
+ 如果
51
+ </td>
52
+ <td width="273" valign="top" style="word-break: break-all;">
53
+ 有一天
54
+ </td>
55
+ <td width="273" valign="top" style="word-break: break-all;">
56
+ 我离开了
57
+ </td>
58
+ </tr>
59
+ <tr>
60
+ <td valign="top" colspan="1" rowspan="1" style="word-break: break-all;">
61
+ 怎么才能
62
+ </td>
63
+ <td valign="top" colspan="1" rowspan="1" style="word-break: break-all;">
64
+ 证明我
65
+ </td>
66
+ <td valign="top" colspan="1" rowspan="1" style="word-break: break-all;">
67
+ 曾经来过
68
+ </td>
69
+ </tr>
70
+ </tbody>
71
+ </table>
72
+ <pre class="brush:html;toolbar:false">&lt;div&gt;
73
+ &lt;span&gt;这里是HTML标签&lt;/span&gt;
74
+ &lt;/div&gt;</pre>
75
+ <h2>
76
+ 公式支持
77
+ </h2>
78
+ <p>
79
+ <img src="https://r.latexeasy.com/image.svg?%5Cint%20%5Cfrac%7B1%7D%7Bx%7D%20dx%20%3D%20%5Cln%20%5Cleft%7C%20x%20%5Cright%7C%20%2B%20C"
80
+ data-formula-image="%5Cint%20%5Cfrac%7B1%7D%7Bx%7D%20dx%20%3D%20%5Cln%20%5Cleft%7C%20x%20%5Cright%7C%20%2B%20C"/>
81
+ </p>
82
+ <p>
83
+ <br/>
84
+ </p>
85
+
86
+ </script>
87
+ </div>
88
+ <div id="btns" style="margin-top:20px;">
89
+ <div>
90
+
91
+ <button onclick="alert(UE.getEditor('editor').getAllHtml())">获得整个html的内容</button>
92
+ <button onclick="alert(UE.getEditor('editor').getContent())">获得内容</button>
93
+ <button onclick="UE.getEditor('editor').setContent('<p>欢迎使用 UEditorPlus</p>', false)">写入内容</button>
94
+ <button onclick="UE.getEditor('editor').setContent('<p>欢迎使用 UEditorPlus</p>', true)">追加内容</button>
95
+ <button onclick="alert(UE.getEditor('editor').getContentTxt())">获得纯文本</button>
96
+ <button onclick="alert(UE.getEditor('editor').getPlainTxt())">获得带格式的纯文本</button>
97
+ <button onclick="alert(UE.getEditor('editor').hasContents())">判断是否有内容</button>
98
+ <button onclick="UE.getEditor('editor').focus()">使编辑器获得焦点</button>
99
+ <button onmousedown="isFocus()">编辑器是否获得焦点</button>
100
+ <button onmousedown="setBlur()">编辑器失去焦点</button>
101
+ <button onclick="getSelectText()">获得当前选中的文本</button>
102
+ <button onclick="UE.getEditor('editor').execCommand('insertHtml', '插入的内容')">插入内容</button>
103
+ <button onclick="UE.getEditor('editor').setEnabled()">设定可编辑</button>
104
+ <button onclick="UE.getEditor('editor').setDisabled('fullscreen')">设定不可编辑</button>
105
+ <button onclick="UE.getEditor('editor').setHide()">隐藏编辑器</button>
106
+ <button onclick="UE.getEditor('editor').setShow()">显示编辑器</button>
107
+ <button onclick="UE.getEditor('editor').setHeight(300)">设置固定高度</button>
108
+ <button onclick="UE.getEditor('editor')">创建编辑器</button>
109
+ <button onclick="UE.getEditor('editor').destroy()">销毁编辑器</button>
110
+ <button onclick="alert( UE.getEditor('editor').execCommand('get_auto_save_content') )">草稿箱-获取</button>
111
+ <button onclick="UE.getEditor('editor').execCommand('clear_auto_save_content'); alert('已清空草稿箱')">草稿箱-清空
112
+ </button>
113
+ <button onclick="UE.getEditor('editor').execCommand('set_auto_save_content'); alert('已保存')">草稿箱-立即保存
114
+ </button>
115
+ <button onclick="UE.getEditor('editor').execCommand('auto_save_restore')">草稿箱-恢复到编辑器</button>
116
+ </div>
117
+ </div>
118
+
119
+ <script type="text/javascript">
120
+ var ue = UE.getEditor('editor',{
121
+ // autoHeightEnabled: false,
122
+ });
123
+ ue.on('contentchange', function () {
124
+ // console.log('contentchange', ue.getContent());
125
+ });
126
+
127
+ function isFocus(e) {
128
+ alert(UE.getEditor('editor').isFocus());
129
+ UE.dom.domUtils.preventDefault(e)
130
+ }
131
+
132
+ function setBlur(e) {
133
+ UE.getEditor('editor').blur();
134
+ UE.dom.domUtils.preventDefault(e)
135
+ }
136
+
137
+ function getSelectText() {
138
+ var range = UE.getEditor('editor').selection.getRange();
139
+ range.select();
140
+ var txt = UE.getEditor('editor').selection.getText();
141
+ alert(txt)
142
+ }
143
+ </script>
144
+ </div>
145
+ </body>
146
+ </html>