@jx3box/jx3box-editor 2.0.3 → 2.0.5

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.
package/src/Tinymce.vue CHANGED
@@ -1,36 +1,21 @@
1
1
  <template>
2
- <div class="c-editor-tinymce">
3
-
4
- <slot name="prepend"></slot>
5
-
6
- <div class="c-editor-header">
7
- <Upload v-if="attachmentEnable" @insert="insertAttachments" />
8
- <Resource v-if="resourceEnable" @insert="insertResource" />
9
- <BoxResource v-if="resourceEnable" @insert="insertResource" />
10
- </div>
11
- <Emotion class="c-editor-emotion" @selected="emotionSelected"></Emotion>
12
-
13
- <slot></slot>
14
-
15
- <editor
16
- id="tinymce"
17
- v-model="data"
18
- :init="init"
19
- class="c-tinymce"
20
- placeholder="✔ 图片可右键粘贴或拖拽至编辑器内自动上传 ✔ 支持word/excel内容一键粘贴"
21
- />
22
- <el-alert class="u-tutorial" type="warning" show-icon
23
- >进入特殊区域(代码块,折叠块等等)脱离或使用工具栏触发后,请使用键盘方向
24
- → ↓
25
- 键进行脱离,回车只是正常在区块内换行。去掉样式点击第二行第一个&lt;清除格式&gt;即可复位。<a
26
- href="/collection/31"
27
- target="_blank"
28
- >[编辑器使用指南]</a
29
- >
30
- </el-alert>
31
-
32
- <slot name="append"></slot>
33
- </div>
2
+ <div class="c-editor-tinymce">
3
+ <slot name="prepend"></slot>
4
+
5
+ <div class="c-editor-header">
6
+ <Upload v-if="attachmentEnable" @insert="insertAttachments" />
7
+ <Resource v-if="resourceEnable" @insert="insertResource" />
8
+ <BoxResource v-if="resourceEnable" @insert="insertResource" />
9
+ </div>
10
+ <Emotion class="c-editor-emotion" @selected="emotionSelected"></Emotion>
11
+
12
+ <slot></slot>
13
+
14
+ <editor id="tinymce" v-model="data" :init="init" class="c-tinymce" placeholder="✔ 图片可右键粘贴或拖拽至编辑器内自动上传 ✔ 支持word/excel内容一键粘贴" />
15
+ <el-alert class="u-tutorial" type="warning" show-icon>进入特殊区域(代码块,折叠块等等)脱离或使用工具栏触发后,请使用键盘方向 → ↓ 键进行脱离,回车只是正常在区块内换行。去掉样式点击第二行第一个&lt;清除格式&gt;即可复位。<a href="/collection/31" target="_blank">[编辑器使用指南]</a> </el-alert>
16
+
17
+ <slot name="append"></slot>
18
+ </div>
34
19
  </template>
35
20
 
36
21
  <script>
@@ -41,188 +26,141 @@ import Resource from "./Resource";
41
26
  import BoxResource from "./BoxResource";
42
27
  import { __cms } from "@jx3box/jx3box-common/data/jx3box.json";
43
28
  import { __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
44
- import Emotion from "@jx3box/jx3box-emotion/src/Emotion.vue"
45
- import hljs_languages from "../assets/js/item/hljs_languages.js"
29
+ import Emotion from "@jx3box/jx3box-emotion/src/Emotion.vue";
30
+ import hljs_languages from "../assets/js/item/hljs_languages.js";
46
31
  const API_Root = process.env.NODE_ENV === "production" ? __cms : "/";
47
32
  const API = API_Root + "api/cms/upload/tinymce";
48
33
 
49
- // directive
34
+ // directive
50
35
  import { draggable } from "../assets/js/drag";
51
- Vue.directive('draggable', draggable);
36
+ Vue.directive("draggable", draggable);
52
37
 
53
38
  export default {
54
- name: "Tinymce",
55
- props: ["content", "height", "attachmentEnable", "resourceEnable"],
56
- data: function() {
57
- return {
58
- data: this.content,
59
- init: {
60
- // 选择器
61
- selector: "#tinymce",
62
-
63
- // 语言
64
- language: "zh_CN",
65
-
66
- // 设置
67
- convert_urls: false,
68
-
69
- // 样式
70
- // TODO:
71
- content_css: process.env.VUE_APP_DEV_COMPONENT == 'true' ? '/css/article.css' : `https://cdn.jx3box.com/static/jx3box-editor/css/article.css`,
72
- // content_css: `http://localhost:3000/skins/content/default/content.min.css`,
73
- body_class: "c-article c-article-editor c-article-tinymce",
74
- height: this.height || 800,
75
- autosave_ask_before_unload: false,
76
-
77
- // UI
78
- icons: "custom",
79
- menubar: false,
80
- branding: false,
81
- contextmenu: "",
82
- plugins: [
83
- "link autolink",
84
- "hr lists advlist table codeinline codesample checklist foldtext latex anchor",
85
- "image emoticons media videox macro qixue talent2",
86
- "code fullscreen wordcount powerpaste pagebreak printpage pz", // template anchor jx3icon autosave
87
- ],
88
- toolbar: [
89
- "undo | formatselect | fontsizeselect | forecolor backcolor | bold italic underline strikethrough superscript subscript | link unlink | fullscreen code", //anchor restoredraft
90
- "removeformat | hr alignleft aligncenter alignright alignjustify indent outdent | bullist numlist checklist table blockquote foldtext codeinline codesample latex | emoticons image media videox | macro pz qixue talent2 pagebreak printpage", // template anchor jx3icon
91
- ],
92
- mobile: {
93
- toolbar_drawer: true,
94
- toolbar: [
95
- "undo emoticons bold forecolor backcolor removeformat pagebreak fullscreen",
96
- "hr alignleft aligncenter alignright alignjustify indent outdent bullist numlist checklist table blockquote codesample latex macro qixue talent2 media",
97
- ],
98
- },
99
- block_formats:
100
- "段落=p;一级标题=h1;二级标题=h2;三级标题=h3;四级标题=h4;五级标题=h5;六级标题=h6;",
101
- fontsize_formats:
102
- "12px 14px 16px 18px 22px 24px 26px 28px 32px 48px 72px",
103
- color_map: [
104
- "FF99CC",
105
- "浅粉",
106
- "FF3399",
107
- "深粉",
108
- "FF0000",
109
- "正红",
110
- "CC99FF",
111
- "紫色",
112
- "9933ff",
113
- "深紫",
114
-
115
- "FFFF99",
116
- "浅黄",
117
- "FFFF00",
118
- "金黄",
119
- "FFCC00",
120
- "亮黄",
121
- "FFCC99",
122
- "浅桃",
123
- "FF6600",
124
- "橘色",
125
-
126
- "CCFFCC",
127
- "浅绿",
128
- "9bf915",
129
- "荧光绿",
130
- "00FF00",
131
- "辣眼绿",
132
- "49c10f",
133
- "深绿",
134
- "008080",
135
- "深青",
136
-
137
- "CCFFFF",
138
- "浅蓝",
139
- "00FFFF",
140
- "参考线",
141
- "00CCFF",
142
- "天蓝",
143
- "99CCFF",
144
- "蔚蓝",
145
- "0000FF",
146
- "辣眼蓝",
147
-
148
- "CC0000",
149
- "深红",
150
- "000000",
151
- "黑色",
152
- ],
153
-
154
- codesample_languages: hljs_languages,
155
-
156
- // Image
157
- image_advtab: true,
158
- // paste_data_images: true,
159
- file_picker_types: "file image",
160
- images_upload_url: API,
161
- automatic_uploads: true,
162
- images_upload_credentials: true,
163
-
164
- // Hook
165
- // setup: this.setup,
166
- // init_instance_callback: this.ready,
167
-
168
- // Template
169
- // templates: [
170
- // {
171
- // title: "剑三宏",
172
- // description: "",
173
- // content: `
174
- // <pre class="e-jx3macro-area w-jx3macro">/cast 自绝经脉</pre>
175
- // `,
176
- // },
177
- // ],
178
- },
179
- mode : 'tinymce'
180
- };
181
- },
182
- model: {
183
- prop: "content",
184
- event: "update",
185
- },
186
- watch: {
187
- data: function(newval) {
188
- this.$emit("update", newval);
189
- },
190
- content: function(newval) {
191
- this.data = newval;
192
- },
193
- },
194
- methods: {
195
- setup: function(editor) {
196
- // console.log("ID为: " + editor.id + " 的编辑器即将初始化.");
197
- },
198
- ready: function(editor) {
199
- // console.log("ID为: " + editor.id + " 的编辑器已初始化完成.");
200
- },
201
- insertAttachments: function(data) {
202
- tinyMCE.editors["tinymce"].insertContent(data.html);
203
- },
204
- insertResource: function(data) {
205
- tinyMCE.editors["tinymce"].insertContent(data);
206
- },
207
- emotionSelected: function(emotion) {
208
- const src = `${__imgPath}emotion/output/${emotion.filename}`
209
- const IMAGE = `<img class="t-emotion" src="${src}" alt="${src}" />`
210
- tinyMCE.editors["tinymce"].insertContent(IMAGE)
211
- },
212
- },
213
- mounted: function() {
214
- },
215
- components: {
216
- Editor,
217
- Upload,
218
- Resource,
219
- Emotion,
220
- BoxResource
221
- },
39
+ name: "Tinymce",
40
+ props: ["content", "height", "attachmentEnable", "resourceEnable"],
41
+ data: function () {
42
+ return {
43
+ data: this.content,
44
+ init: {
45
+ // 选择器
46
+ selector: "#tinymce",
47
+
48
+ // 语言
49
+ language: "zh_CN",
50
+
51
+ // 设置
52
+ convert_urls: false,
53
+
54
+ // 样式
55
+ // TODO:
56
+ // content_css: process.env.VUE_APP_DEV_COMPONENT == "true" ? "/css/article.css" : `https://cdn.jx3box.com/static/jx3box-editor/css/article.css`,
57
+ content_css:"/css/article.css",
58
+ // content_css: `http://localhost:3000/skins/content/default/content.min.css`,
59
+ body_class: "c-article c-article-editor c-article-tinymce",
60
+ height: this.height || 800,
61
+ autosave_ask_before_unload: false,
62
+ content_style: "",
63
+
64
+ // UI
65
+ icons: "custom",
66
+ menubar: false,
67
+ branding: false,
68
+ contextmenu: "",
69
+ plugins: [
70
+ "link autolink",
71
+ "hr lists advlist table codeinline codesample checklist foldtext latex anchor",
72
+ "image emoticons media videox macro qixue talent2",
73
+ "code fullscreen wordcount powerpaste pagebreak printpage pz", // template anchor jx3icon autosave
74
+ ],
75
+ toolbar: [
76
+ "undo | formatselect | fontsizeselect | forecolor backcolor | bold italic underline strikethrough superscript subscript | link unlink | fullscreen code", //anchor restoredraft
77
+ "removeformat | hr alignleft aligncenter alignright alignjustify indent outdent | bullist numlist checklist table blockquote foldtext codeinline codesample latex | emoticons image media videox | macro pz qixue talent2 pagebreak printpage", // template anchor jx3icon
78
+ ],
79
+ mobile: {
80
+ toolbar_drawer: true,
81
+ toolbar: ["undo emoticons bold forecolor backcolor removeformat pagebreak fullscreen", "hr alignleft aligncenter alignright alignjustify indent outdent bullist numlist checklist table blockquote codesample latex macro qixue talent2 media"],
82
+ },
83
+ block_formats: "段落=p;一级标题=h1;二级标题=h2;三级标题=h3;四级标题=h4;五级标题=h5;六级标题=h6;",
84
+ fontsize_formats: "12px 14px 16px 18px 22px 24px 26px 28px 32px 48px 72px",
85
+ color_map: ["FF99CC", "浅粉", "FF3399", "深粉", "FF0000", "正红", "CC99FF", "紫色", "9933ff", "深紫", "FFFF99", "浅黄", "FFFF00", "金黄", "FFCC00", "亮黄", "FFCC99", "浅桃", "FF6600", "橘色", "CCFFCC", "浅绿", "9bf915", "荧光绿", "00FF00", "辣眼绿", "49c10f", "深绿", "008080", "深青", "CCFFFF", "浅蓝", "00FFFF", "参考线", "00CCFF", "天蓝", "99CCFF", "蔚蓝", "0000FF", "辣眼蓝", "CC0000", "深红", "000000", "黑色"],
86
+
87
+ codesample_languages: hljs_languages,
88
+
89
+ // Image
90
+ image_advtab: true,
91
+ // paste_data_images: true,
92
+ file_picker_types: "file image",
93
+ images_upload_url: API,
94
+ automatic_uploads: true,
95
+ images_upload_credentials: true,
96
+
97
+ // Hook
98
+ // setup: this.setup,
99
+ // init_instance_callback: this.ready,
100
+
101
+ // Template
102
+ // templates: [
103
+ // {
104
+ // title: "剑三宏",
105
+ // description: "",
106
+ // content: `
107
+ // <pre class="e-jx3macro-area w-jx3macro">/cast 自绝经脉</pre>
108
+ // `,
109
+ // },
110
+ // ],
111
+ valid_children: "+body[style]",
112
+ },
113
+ mode: "tinymce",
114
+ style: "",
115
+ };
116
+ },
117
+ model: {
118
+ prop: "content",
119
+ event: "update",
120
+ },
121
+ watch: {
122
+ data: function (newval) {
123
+ this.$emit("update", newval);
124
+ },
125
+ content: function (newval) {
126
+ this.data = newval;
127
+ },
128
+ style(val) {
129
+ this.init.content_style = val;
130
+ },
131
+ },
132
+ methods: {
133
+ setup: function (editor) {
134
+ // console.log("ID为: " + editor.id + " 的编辑器即将初始化.");
135
+ },
136
+ ready: function (editor) {
137
+ // console.log("ID为: " + editor.id + " 的编辑器已初始化完成.");
138
+ },
139
+ insertAttachments: function (data) {
140
+ tinyMCE.editors["tinymce"].insertContent(data.html);
141
+ },
142
+ insertResource: function (data) {
143
+ tinyMCE.editors["tinymce"].insertContent(data);
144
+ },
145
+ emotionSelected: function (emotion) {
146
+ const src = `${__imgPath}emotion/output/${emotion.filename}`;
147
+ const IMAGE = `<img class="t-emotion" src="${src}" alt="${src}" />`;
148
+ tinyMCE.editors["tinymce"].insertContent(IMAGE);
149
+ },
150
+ },
151
+ mounted: function () {},
152
+ components: {
153
+ Editor,
154
+ Upload,
155
+ Resource,
156
+ Emotion,
157
+ BoxResource,
158
+ },
222
159
  };
223
160
  </script>
224
161
 
225
162
  <style lang="less">
226
163
  @import "../assets/css/tinymce.less";
227
164
  @import "../assets/css/tinymce/combo.less";
165
+
228
166
  </style>
@@ -0,0 +1,37 @@
1
+ <template>
2
+ <div class="e-letter" v-html="html"></div>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ name: "Letter",
8
+ props: {
9
+ data: {
10
+ type: Object,
11
+ default: () => {},
12
+ },
13
+ },
14
+ data() {
15
+ return {
16
+ html: "",
17
+ };
18
+ },
19
+ watch: {
20
+ data: {
21
+ immediate: true,
22
+ deep: true,
23
+ handler(obj) {
24
+ this.html = this.htmlDemo(obj);
25
+ },
26
+ },
27
+ },
28
+ methods: {
29
+ // 默认html
30
+ htmlDemo({ slug, style }) {
31
+ const titleHtml = `<div class="e-letter-title letter-title--${slug}">我是标题</div>`;
32
+ const contentHtml = `<div class="e-letter-content letter-body--${slug}"><div class="u-letter-content--header letter-header--${slug}"><div class="u-letter-content--footer letter-footer--${slug}"><p contenteditable="true">明月几时有,把酒问青天。</p></div></div></div>`;
33
+ return `<div class="e-letter letter--${slug}">${titleHtml}<br/> ${contentHtml}</div></div><style>${style}</style>`;
34
+ },
35
+ },
36
+ };
37
+ </script>
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <div class="c-letter-paper">
3
+ <div
4
+ :class="`c-letter-title c-letter-title__${data.slug}`"
5
+ :style="{
6
+ backgroundImage: `url(${data.img_title || ''})`,
7
+ backgroundRepeat: 'no-repeat',
8
+ backgroundSize: 'cover',
9
+ }"
10
+ >
11
+ 我是抬头
12
+ </div>
13
+ <div
14
+ :class="`c-letter-content c-letter-content__${data.slug}`"
15
+ :style="{
16
+ backgroundImage: `url(${data.img_body || ''})`,
17
+ }"
18
+ >
19
+ <div
20
+ class="u-header"
21
+ :style="{
22
+ backgroundImage: `url(${data.img_header || ''})`,
23
+ backgroundRepeat: 'no-repeat',
24
+ backgroundPosition: 'top center',
25
+ }"
26
+ >
27
+ <div
28
+ class="u-footer"
29
+ :style="{
30
+ backgroundImage: `url(${data.img_footer || ''})`,
31
+ backgroundRepeat: 'no-repeat',
32
+ backgroundPosition: 'bottom center',
33
+ }"
34
+ >
35
+ <p v-for="o in 4" :key="o">明月几时有,把酒问青天。</p>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </template>
41
+
42
+ <script>
43
+ export default {
44
+ name: "letter-demo",
45
+ props: {
46
+ data: {
47
+ type: Object,
48
+ default: () => {},
49
+ },
50
+ },
51
+ data() {
52
+ return {
53
+ styleTag: null,
54
+ };
55
+ },
56
+ watch: {
57
+ "data.style": {
58
+ immediate: true,
59
+ handler(val) {
60
+ this.insertStyle(val);
61
+ },
62
+ },
63
+ },
64
+ methods: {
65
+ insertStyle(style) {
66
+ if (this.styleTag) {
67
+ document.body.removeChild(this.styleTag);
68
+ }
69
+ this.styleTag = document.createElement("style");
70
+ this.styleTag.textContent = style;
71
+ document.body.appendChild(this.styleTag);
72
+ },
73
+ },
74
+ };
75
+ </script>
76
+ <style lang="less">
77
+ .c-letter-title {
78
+ background-size: cover;
79
+ }
80
+ .c-letter-content {
81
+ margin-top: 20px;
82
+ background-repeat: repeat-y;
83
+ background-size: contain;
84
+ }
85
+ .c-letter-content .u-header,
86
+ .c-letter-content .u-footer {
87
+ background-size: contain;
88
+ background-repeat: no-repeat;
89
+ }
90
+ .c-letter-content .u-footer {
91
+ background-position: bottom;
92
+ }
93
+ </style>