@seafile/sdoc-editor 0.1.99 → 0.1.101
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/dist/basic-sdk/comment/comment/style.css +1 -1
- package/dist/basic-sdk/comment/comment-decorate.js +5 -2
- package/dist/basic-sdk/extension/commons/color-menu/index.js +2 -2
- package/dist/basic-sdk/extension/constants/color.js +1 -1
- package/dist/basic-sdk/extension/constants/font.js +505 -13
- package/dist/basic-sdk/extension/constants/index.js +3 -3
- package/dist/basic-sdk/extension/plugins/font/helpers.js +73 -1
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/font-item.js +31 -0
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.css +24 -0
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +157 -0
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +4 -7
- package/dist/basic-sdk/extension/plugins/font/menu/index.js +4 -1
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +18 -4
- package/dist/utils/index.js +4 -0
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +4 -1
- package/public/locales/zh-CN/sdoc-editor.json +4 -1
|
@@ -8,7 +8,10 @@ export var commentDecorate = function commentDecorate(editor) {
|
|
|
8
8
|
path = _ref2[1];
|
|
9
9
|
var decorations = [];
|
|
10
10
|
var comments = ((_editor$element_comme = editor.element_comments_map) === null || _editor$element_comme === void 0 ? void 0 : _editor$element_comme[node.id]) || [];
|
|
11
|
-
|
|
11
|
+
var unresolvedComments = comments && comments.filter(function (item) {
|
|
12
|
+
return !item.resolved;
|
|
13
|
+
});
|
|
14
|
+
if (unresolvedComments && unresolvedComments.length > 0) {
|
|
12
15
|
var decoration = {
|
|
13
16
|
anchor: {
|
|
14
17
|
path: path,
|
|
@@ -21,7 +24,7 @@ export var commentDecorate = function commentDecorate(editor) {
|
|
|
21
24
|
};
|
|
22
25
|
// rgba prevents occlusion of the cursor
|
|
23
26
|
decoration['computed_bg_color'] = 'rgba(129, 237, 247, 0.5)';
|
|
24
|
-
decoration['comment_count'] =
|
|
27
|
+
decoration['comment_count'] = unresolvedComments === null || unresolvedComments === void 0 ? void 0 : unresolvedComments.length;
|
|
25
28
|
decorations.push(decoration);
|
|
26
29
|
}
|
|
27
30
|
return decorations;
|
|
@@ -4,7 +4,7 @@ import { withTranslation } from 'react-i18next';
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { UncontrolledPopover } from 'reactstrap';
|
|
6
6
|
import { ChromePicker } from 'react-color';
|
|
7
|
-
import { DEFAULT_COLORS, STANDARD_COLORS,
|
|
7
|
+
import { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST } from '../../constants';
|
|
8
8
|
import { LocalStorage } from '../../../../utils';
|
|
9
9
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
10
10
|
import ColorItem from './color-item';
|
|
@@ -27,7 +27,7 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
27
27
|
updateLastUsedColor = _ref.updateLastUsedColor;
|
|
28
28
|
var popoverRef = useRef(null);
|
|
29
29
|
var moreColorsPopoverRef = useRef(null);
|
|
30
|
-
var _useState = useState(LocalStorage.getItem(recentUsedColorsKey,
|
|
30
|
+
var _useState = useState(LocalStorage.getItem(recentUsedColorsKey, DEFAULT_RECENT_USED_LIST)),
|
|
31
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
32
|
recentUsedColors = _useState2[0],
|
|
33
33
|
setRecentUsedColors = _useState2[1];
|
|
@@ -262,7 +262,7 @@ export var STANDARD_COLORS = [{
|
|
|
262
262
|
}];
|
|
263
263
|
|
|
264
264
|
// Initialize the most recently used colors
|
|
265
|
-
export var
|
|
265
|
+
export var DEFAULT_RECENT_USED_LIST = new Array(10).fill('');
|
|
266
266
|
export var DEFAULT_FONT_COLOR = '#333333';
|
|
267
267
|
|
|
268
268
|
// default last used color
|
|
@@ -1,53 +1,105 @@
|
|
|
1
|
+
// font family
|
|
2
|
+
var SERIF = 'serif';
|
|
3
|
+
var SANS_SERIF = 'sans-serif';
|
|
4
|
+
var CURSIVE = 'cursive';
|
|
5
|
+
var MONOSPACE = 'monospace';
|
|
6
|
+
|
|
7
|
+
// font weight
|
|
8
|
+
var FONT_WEIGHT = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
9
|
+
var FONT_WEIGHT_100_TO_700 = [100, 200, 300, 400, 500, 600, 700];
|
|
10
|
+
// const FONT_WEIGHT_100_TO_800 = [100, 200, 300, 400, 500, 600, 700, 800];
|
|
11
|
+
|
|
12
|
+
var FONT_WEIGHT_200_TO_700 = [200, 300, 400, 500, 600, 700];
|
|
13
|
+
var FONT_WEIGHT_200_TO_800 = [200, 300, 400, 500, 600, 700, 800];
|
|
14
|
+
var FONT_WEIGHT_200_TO_900 = [200, 300, 400, 500, 600, 700, 800, 900];
|
|
15
|
+
var FONT_WEIGHT_300_TO_700 = [300, 400, 500, 600, 700];
|
|
16
|
+
var FONT_WEIGHT_300_TO_800 = [300, 400, 500, 600, 700, 800];
|
|
17
|
+
var FONT_WEIGHT_300_TO_900 = [300, 400, 500, 600, 700, 800, 900];
|
|
18
|
+
var FONT_WEIGHT_400_TO_700 = [400, 500, 600, 700];
|
|
19
|
+
var FONT_WEIGHT_400_TO_800 = [400, 500, 600, 700, 800];
|
|
20
|
+
var FONT_WEIGHT_400_TO_900 = [400, 500, 600, 700, 800, 900];
|
|
21
|
+
|
|
22
|
+
// 400 and odd
|
|
23
|
+
var FONT_WEIGHT_400_AND_ODD = [100, 300, 400, 500, 700, 900];
|
|
24
|
+
|
|
25
|
+
// system font weight
|
|
26
|
+
var FONT_WEIGHT_400_700 = [400, 700];
|
|
27
|
+
var FONT_WEIGHT_100_400_700 = [100, 400, 700];
|
|
28
|
+
var FONT_WEIGHT_100_400_700_800 = [100, 400, 700, 800];
|
|
1
29
|
export var SPECIAL_FONT_SIZE_NAME = ['初号', '小初', '一号', '小一', '二号', '小二', '三号', '小三', '四号', '小四', '五号', '小五'];
|
|
2
30
|
export var DEFAULT_COMMON_FONT_SIZE = 14;
|
|
3
31
|
export var FONT_SIZE = [{
|
|
4
32
|
name: '初号',
|
|
5
33
|
value: 42,
|
|
6
|
-
|
|
34
|
+
langOrder: {
|
|
35
|
+
'zh-cn': 0
|
|
36
|
+
}
|
|
7
37
|
}, {
|
|
8
38
|
name: '小初',
|
|
9
39
|
value: 36,
|
|
10
|
-
|
|
40
|
+
langOrder: {
|
|
41
|
+
'zh-cn': 0
|
|
42
|
+
}
|
|
11
43
|
}, {
|
|
12
44
|
name: '一号',
|
|
13
45
|
value: 26,
|
|
14
|
-
|
|
46
|
+
langOrder: {
|
|
47
|
+
'zh-cn': 0
|
|
48
|
+
}
|
|
15
49
|
}, {
|
|
16
50
|
name: '小一',
|
|
17
51
|
value: 24,
|
|
18
|
-
|
|
52
|
+
langOrder: {
|
|
53
|
+
'zh-cn': 0
|
|
54
|
+
}
|
|
19
55
|
}, {
|
|
20
56
|
name: '二号',
|
|
21
57
|
value: 22,
|
|
22
|
-
|
|
58
|
+
langOrder: {
|
|
59
|
+
'zh-cn': 0
|
|
60
|
+
}
|
|
23
61
|
}, {
|
|
24
62
|
name: '小二',
|
|
25
63
|
value: 18,
|
|
26
|
-
|
|
64
|
+
langOrder: {
|
|
65
|
+
'zh-cn': 0
|
|
66
|
+
}
|
|
27
67
|
}, {
|
|
28
68
|
name: '三号',
|
|
29
69
|
value: 16,
|
|
30
|
-
|
|
70
|
+
langOrder: {
|
|
71
|
+
'zh-cn': 0
|
|
72
|
+
}
|
|
31
73
|
}, {
|
|
32
74
|
name: '小三',
|
|
33
75
|
value: 15,
|
|
34
|
-
|
|
76
|
+
langOrder: {
|
|
77
|
+
'zh-cn': 0
|
|
78
|
+
}
|
|
35
79
|
}, {
|
|
36
80
|
name: '四号',
|
|
37
81
|
value: 14,
|
|
38
|
-
|
|
82
|
+
langOrder: {
|
|
83
|
+
'zh-cn': 0
|
|
84
|
+
}
|
|
39
85
|
}, {
|
|
40
86
|
name: '小四',
|
|
41
87
|
value: 12,
|
|
42
|
-
|
|
88
|
+
langOrder: {
|
|
89
|
+
'zh-cn': 0
|
|
90
|
+
}
|
|
43
91
|
}, {
|
|
44
92
|
name: '五号',
|
|
45
93
|
value: 10.5,
|
|
46
|
-
|
|
94
|
+
langOrder: {
|
|
95
|
+
'zh-cn': 0
|
|
96
|
+
}
|
|
47
97
|
}, {
|
|
48
98
|
name: '小五',
|
|
49
99
|
value: 9,
|
|
50
|
-
|
|
100
|
+
langOrder: {
|
|
101
|
+
'zh-cn': 0
|
|
102
|
+
}
|
|
51
103
|
}, {
|
|
52
104
|
name: '9',
|
|
53
105
|
value: 9
|
|
@@ -96,4 +148,444 @@ export var FONT_SIZE = [{
|
|
|
96
148
|
}, {
|
|
97
149
|
name: '72',
|
|
98
150
|
value: 72
|
|
99
|
-
}];
|
|
151
|
+
}];
|
|
152
|
+
export var GOOGLE_FONT_CLASS = 'sdoc-google-font';
|
|
153
|
+
export var DEFAULT_FONT = 'default_font';
|
|
154
|
+
export var RECENT_USED_FONTS_KEY = 'sdoc-recent-used-fonts';
|
|
155
|
+
export var FONT = [
|
|
156
|
+
// { name: '\u5fae\u8f6f\u96c5\u9ed1', fontFamilyName: { mac: 'Microsoft YaHei', windows: '\u5fae\u8f6f\u96c5\u9ed1' }, supportFontWeight: FONT_WEIGHT_100_400_700, isSystemOwn: true, usuallyFontFamilyName: SANS_SERIF }, // 微软雅黑
|
|
157
|
+
// { name: '\u5b8b\u4f53', fontFamilyName: { mac: 'SimSun', windows: '\u5b8b\u4f53' }, supportFontWeight: FONT_WEIGHT_100_400_700_800, isSystemOwn: true, usuallyFontFamilyName: SERIF }, // 宋体
|
|
158
|
+
// { name: '\u9ed1\u4f53', fontFamilyName: { mac: 'SimHei', windows: '\u9ed1\u4f53' }, supportFontWeight: [300, 500], isSystemOwn: true, usuallyFontFamilyName: SANS_SERIF }, // 黑体
|
|
159
|
+
// { name: '\u6977\u4f53', fontFamilyName: { mac: 'KaiTi', windows: '\u6977\u4f53' }, supportFontWeight: [400, 700, 800], isSystemOwn: true }, // 楷体
|
|
160
|
+
// { name: 'Arial', supportFontWeight: FONT_WEIGHT_400_700, isSystemOwn: true, usuallyFontFamilyName: SANS_SERIF, isDuplicate: true },
|
|
161
|
+
// { name: 'Helvetica', supportFontWeight: FONT_WEIGHT_400_700, isSystemOwn: true, usuallyFontFamilyName: SANS_SERIF, isDuplicate: true },
|
|
162
|
+
// { name: 'Times New Roman', supportFontWeight: FONT_WEIGHT_400_700, isSystemOwn: true, usuallyFontFamilyName: SERIF, isDuplicate: true },
|
|
163
|
+
// { disabled: true, type: 'divide' },
|
|
164
|
+
{
|
|
165
|
+
name: DEFAULT_FONT,
|
|
166
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
167
|
+
isSystemOwn: true,
|
|
168
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
169
|
+
isDefault: true,
|
|
170
|
+
langOrder: {
|
|
171
|
+
'zh-cn': 2
|
|
172
|
+
}
|
|
173
|
+
}, {
|
|
174
|
+
name: 'Arial',
|
|
175
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
176
|
+
isSystemOwn: true,
|
|
177
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
178
|
+
}, {
|
|
179
|
+
name: 'Arimo',
|
|
180
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
181
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
182
|
+
}, {
|
|
183
|
+
name: 'Assistant',
|
|
184
|
+
supportFontWeight: FONT_WEIGHT_200_TO_800,
|
|
185
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
186
|
+
}, {
|
|
187
|
+
name: 'Bitter',
|
|
188
|
+
supportFontWeight: FONT_WEIGHT,
|
|
189
|
+
usuallyFontFamilyName: SERIF
|
|
190
|
+
}, {
|
|
191
|
+
name: 'Cabin',
|
|
192
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
193
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
194
|
+
}, {
|
|
195
|
+
name: 'Catamaran',
|
|
196
|
+
supportFontWeight: FONT_WEIGHT,
|
|
197
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
198
|
+
}, {
|
|
199
|
+
name: 'Caveat',
|
|
200
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
201
|
+
usuallyFontFamilyName: CURSIVE
|
|
202
|
+
}, {
|
|
203
|
+
name: 'Cinzel',
|
|
204
|
+
supportFontWeight: FONT_WEIGHT_400_TO_900,
|
|
205
|
+
usuallyFontFamilyName: SERIF
|
|
206
|
+
}, {
|
|
207
|
+
name: 'Changa',
|
|
208
|
+
supportFontWeight: FONT_WEIGHT_200_TO_800,
|
|
209
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
210
|
+
}, {
|
|
211
|
+
name: 'Comfortaa',
|
|
212
|
+
supportFontWeight: FONT_WEIGHT_300_TO_700,
|
|
213
|
+
usuallyFontFamilyName: CURSIVE
|
|
214
|
+
}, {
|
|
215
|
+
name: 'Comic Sans MS',
|
|
216
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
217
|
+
isSystemOwn: true,
|
|
218
|
+
usuallyFontFamilyName: SERIF
|
|
219
|
+
}, {
|
|
220
|
+
name: 'Crimson Text',
|
|
221
|
+
supportFontWeight: FONT_WEIGHT_300_TO_900,
|
|
222
|
+
usuallyFontFamilyName: SERIF
|
|
223
|
+
}, {
|
|
224
|
+
name: 'Cuprum',
|
|
225
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
226
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
227
|
+
}, {
|
|
228
|
+
name: 'Dancing Script',
|
|
229
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
230
|
+
usuallyFontFamilyName: CURSIVE
|
|
231
|
+
}, {
|
|
232
|
+
name: 'Domine',
|
|
233
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
234
|
+
usuallyFontFamilyName: SERIF
|
|
235
|
+
}, {
|
|
236
|
+
name: 'Dosis',
|
|
237
|
+
supportFontWeight: FONT_WEIGHT_200_TO_800,
|
|
238
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
239
|
+
}, {
|
|
240
|
+
name: 'EB Garamond',
|
|
241
|
+
supportFontWeight: FONT_WEIGHT_400_TO_800,
|
|
242
|
+
usuallyFontFamilyName: SERIF
|
|
243
|
+
}, {
|
|
244
|
+
name: 'Encode Sans',
|
|
245
|
+
supportFontWeight: FONT_WEIGHT,
|
|
246
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
247
|
+
}, {
|
|
248
|
+
name: 'Exo',
|
|
249
|
+
supportFontWeight: FONT_WEIGHT,
|
|
250
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
251
|
+
}, {
|
|
252
|
+
name: 'Exo 2',
|
|
253
|
+
supportFontWeight: FONT_WEIGHT,
|
|
254
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
255
|
+
}, {
|
|
256
|
+
name: 'Faustina',
|
|
257
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
258
|
+
usuallyFontFamilyName: SERIF
|
|
259
|
+
}, {
|
|
260
|
+
name: 'Garamond',
|
|
261
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
262
|
+
isSystemOwn: true,
|
|
263
|
+
usuallyFontFamilyName: SERIF
|
|
264
|
+
}, {
|
|
265
|
+
name: 'Georgia',
|
|
266
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
267
|
+
isSystemOwn: true,
|
|
268
|
+
usuallyFontFamilyName: SERIF
|
|
269
|
+
}, {
|
|
270
|
+
name: 'Heebo',
|
|
271
|
+
supportFontWeight: FONT_WEIGHT,
|
|
272
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
273
|
+
}, {
|
|
274
|
+
name: 'Helvetica',
|
|
275
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
276
|
+
isSystemOwn: true,
|
|
277
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
278
|
+
}, {
|
|
279
|
+
name: 'Inconsolata',
|
|
280
|
+
supportFontWeight: FONT_WEIGHT_200_TO_900,
|
|
281
|
+
usuallyFontFamilyName: MONOSPACE
|
|
282
|
+
}, {
|
|
283
|
+
name: 'Inter',
|
|
284
|
+
supportFontWeight: FONT_WEIGHT,
|
|
285
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
286
|
+
}, {
|
|
287
|
+
name: 'Karla',
|
|
288
|
+
supportFontWeight: FONT_WEIGHT_200_TO_800,
|
|
289
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
290
|
+
}, {
|
|
291
|
+
name: 'Kreon',
|
|
292
|
+
supportFontWeight: FONT_WEIGHT_300_TO_700,
|
|
293
|
+
usuallyFontFamilyName: SERIF
|
|
294
|
+
}, {
|
|
295
|
+
name: 'Lemonada',
|
|
296
|
+
supportFontWeight: FONT_WEIGHT_300_TO_700,
|
|
297
|
+
usuallyFontFamilyName: CURSIVE
|
|
298
|
+
}, {
|
|
299
|
+
name: 'Libre Franklin',
|
|
300
|
+
supportFontWeight: FONT_WEIGHT,
|
|
301
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
302
|
+
}, {
|
|
303
|
+
name: 'Liu Jian Mao Cao',
|
|
304
|
+
supportFontWeight: [400],
|
|
305
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
306
|
+
langOrder: {
|
|
307
|
+
'zh-cn': 0
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
// Simplified Chinese
|
|
311
|
+
{
|
|
312
|
+
name: 'Long Cang',
|
|
313
|
+
supportFontWeight: [400],
|
|
314
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
315
|
+
langOrder: {
|
|
316
|
+
'zh-cn': 0
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
// Simplified Chinese
|
|
320
|
+
{
|
|
321
|
+
name: 'Lora',
|
|
322
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
323
|
+
usuallyFontFamilyName: SERIF
|
|
324
|
+
}, {
|
|
325
|
+
name: 'Lucida Family',
|
|
326
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
327
|
+
isSystemOwn: true,
|
|
328
|
+
usuallyFontFamilyName: SERIF
|
|
329
|
+
}, {
|
|
330
|
+
name: 'Josefin Sans',
|
|
331
|
+
supportFontWeight: FONT_WEIGHT_100_TO_700,
|
|
332
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
333
|
+
}, {
|
|
334
|
+
name: 'Josefin Slab',
|
|
335
|
+
supportFontWeight: FONT_WEIGHT_100_TO_700,
|
|
336
|
+
usuallyFontFamilyName: SERIF
|
|
337
|
+
}, {
|
|
338
|
+
name: 'Jura',
|
|
339
|
+
supportFontWeight: FONT_WEIGHT_300_TO_700,
|
|
340
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
341
|
+
}, {
|
|
342
|
+
name: 'Manuale',
|
|
343
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
344
|
+
usuallyFontFamilyName: SERIF
|
|
345
|
+
}, {
|
|
346
|
+
name: 'Markazi Text',
|
|
347
|
+
supportFontWeight: FONT_WEIGHT_400_TO_700,
|
|
348
|
+
usuallyFontFamilyName: SERIF
|
|
349
|
+
}, {
|
|
350
|
+
name: 'Maven Pro',
|
|
351
|
+
supportFontWeight: FONT_WEIGHT_400_TO_900,
|
|
352
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
353
|
+
}, {
|
|
354
|
+
name: 'Ma Shan Zheng',
|
|
355
|
+
supportFontWeight: [400],
|
|
356
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
357
|
+
langOrder: {
|
|
358
|
+
'zh-cn': 0
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
// Simplified Chinese
|
|
362
|
+
{
|
|
363
|
+
name: 'Merriweather Sans',
|
|
364
|
+
supportFontWeight: FONT_WEIGHT_300_TO_800,
|
|
365
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
366
|
+
langOrder: {
|
|
367
|
+
'zh-cn': 0
|
|
368
|
+
}
|
|
369
|
+
}, {
|
|
370
|
+
name: 'Noto Sans HK',
|
|
371
|
+
supportFontWeight: FONT_WEIGHT_400_AND_ODD,
|
|
372
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
373
|
+
langOrder: {
|
|
374
|
+
'zh-cn': 0
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
// Chinese Hong Kong
|
|
378
|
+
{
|
|
379
|
+
name: 'Noto Sans SC',
|
|
380
|
+
supportFontWeight: FONT_WEIGHT_400_AND_ODD,
|
|
381
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
382
|
+
langOrder: {
|
|
383
|
+
'zh-cn': 0
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
// Simplified Chinese
|
|
387
|
+
{
|
|
388
|
+
name: 'Noto Sans TC',
|
|
389
|
+
supportFontWeight: FONT_WEIGHT_400_AND_ODD,
|
|
390
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
391
|
+
langOrder: {
|
|
392
|
+
'zh-cn': 0
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
// traditional Chinese
|
|
396
|
+
{
|
|
397
|
+
name: 'Noto Serif SC',
|
|
398
|
+
supportFontWeight: [200, 300, 400, 500, 600, 700, 900],
|
|
399
|
+
usuallyFontFamilyName: SERIF,
|
|
400
|
+
langOrder: {
|
|
401
|
+
'zh-cn': 0
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
// Simplified Chinese
|
|
405
|
+
{
|
|
406
|
+
name: 'Noto Serif TC',
|
|
407
|
+
supportFontWeight: [200, 300, 400, 500, 600, 700, 900],
|
|
408
|
+
usuallyFontFamilyName: SERIF,
|
|
409
|
+
langOrder: {
|
|
410
|
+
'zh-cn': 0
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
// traditional Chinese
|
|
414
|
+
{
|
|
415
|
+
name: 'Orbitron',
|
|
416
|
+
supportFontWeight: FONT_WEIGHT_400_TO_900,
|
|
417
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
418
|
+
}, {
|
|
419
|
+
name: 'Oswald',
|
|
420
|
+
supportFontWeight: FONT_WEIGHT_200_TO_700,
|
|
421
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
422
|
+
}, {
|
|
423
|
+
name: 'Petrona',
|
|
424
|
+
supportFontWeight: FONT_WEIGHT,
|
|
425
|
+
usuallyFontFamilyName: SERIF
|
|
426
|
+
}, {
|
|
427
|
+
name: 'Playfair Display',
|
|
428
|
+
supportFontWeight: FONT_WEIGHT_400_TO_900,
|
|
429
|
+
usuallyFontFamilyName: SERIF
|
|
430
|
+
}, {
|
|
431
|
+
name: 'Podkova',
|
|
432
|
+
supportFontWeight: FONT_WEIGHT_400_TO_800,
|
|
433
|
+
usuallyFontFamilyName: SERIF
|
|
434
|
+
}, {
|
|
435
|
+
name: 'Quicksand',
|
|
436
|
+
supportFontWeight: FONT_WEIGHT_300_TO_700,
|
|
437
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
438
|
+
}, {
|
|
439
|
+
name: 'Raleway',
|
|
440
|
+
supportFontWeight: FONT_WEIGHT,
|
|
441
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
442
|
+
}, {
|
|
443
|
+
name: 'Roboto Mono',
|
|
444
|
+
supportFontWeight: FONT_WEIGHT_400_TO_900,
|
|
445
|
+
usuallyFontFamilyName: MONOSPACE
|
|
446
|
+
}, {
|
|
447
|
+
name: 'Roboto Slab',
|
|
448
|
+
supportFontWeight: FONT_WEIGHT,
|
|
449
|
+
usuallyFontFamilyName: SERIF
|
|
450
|
+
}, {
|
|
451
|
+
name: 'Rokkitt',
|
|
452
|
+
supportFontWeight: FONT_WEIGHT,
|
|
453
|
+
usuallyFontFamilyName: SERIF
|
|
454
|
+
}, {
|
|
455
|
+
name: 'Rosario',
|
|
456
|
+
supportFontWeight: FONT_WEIGHT_300_TO_700,
|
|
457
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
458
|
+
}, {
|
|
459
|
+
name: 'Rubik',
|
|
460
|
+
supportFontWeight: FONT_WEIGHT_300_TO_900,
|
|
461
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
462
|
+
}, {
|
|
463
|
+
name: 'Ruda',
|
|
464
|
+
supportFontWeight: FONT_WEIGHT_400_TO_900,
|
|
465
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
466
|
+
}, {
|
|
467
|
+
name: 'Saira',
|
|
468
|
+
supportFontWeight: FONT_WEIGHT,
|
|
469
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
470
|
+
}, {
|
|
471
|
+
name: 'Signika',
|
|
472
|
+
supportFontWeight: FONT_WEIGHT_300_TO_700,
|
|
473
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
474
|
+
}, {
|
|
475
|
+
name: 'Tahoma',
|
|
476
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
477
|
+
isSystemOwn: true,
|
|
478
|
+
usuallyFontFamilyName: SERIF
|
|
479
|
+
}, {
|
|
480
|
+
name: 'Times New Roman',
|
|
481
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
482
|
+
isSystemOwn: true,
|
|
483
|
+
usuallyFontFamilyName: SERIF
|
|
484
|
+
}, {
|
|
485
|
+
name: 'Verdana',
|
|
486
|
+
supportFontWeight: FONT_WEIGHT_400_700,
|
|
487
|
+
isSystemOwn: true,
|
|
488
|
+
usuallyFontFamilyName: SERIF
|
|
489
|
+
}, {
|
|
490
|
+
name: 'Vollkorn',
|
|
491
|
+
supportFontWeight: FONT_WEIGHT_400_TO_900,
|
|
492
|
+
usuallyFontFamilyName: SERIF
|
|
493
|
+
}, {
|
|
494
|
+
name: 'Work Sans',
|
|
495
|
+
supportFontWeight: FONT_WEIGHT,
|
|
496
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
497
|
+
}, {
|
|
498
|
+
name: 'Yanone Kaffeesatz',
|
|
499
|
+
supportFontWeight: FONT_WEIGHT_200_TO_700,
|
|
500
|
+
usuallyFontFamilyName: SANS_SERIF
|
|
501
|
+
}, {
|
|
502
|
+
name: 'ZCOOL KuaiLe',
|
|
503
|
+
supportFontWeight: [400],
|
|
504
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
505
|
+
langOrder: {
|
|
506
|
+
'zh-cn': 0
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
// Simplified Chinese
|
|
510
|
+
{
|
|
511
|
+
name: 'ZCOOL QingKe HuangYou',
|
|
512
|
+
supportFontWeight: [400],
|
|
513
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
514
|
+
langOrder: {
|
|
515
|
+
'zh-cn': 0
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
// Simplified Chinese
|
|
519
|
+
{
|
|
520
|
+
name: 'ZCOOL XiaoWei',
|
|
521
|
+
supportFontWeight: [400],
|
|
522
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
523
|
+
langOrder: {
|
|
524
|
+
'zh-cn': 0
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
// Simplified Chinese
|
|
528
|
+
{
|
|
529
|
+
name: 'Zhi Mang Xing',
|
|
530
|
+
supportFontWeight: [400],
|
|
531
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
532
|
+
langOrder: {
|
|
533
|
+
'zh-cn': 0
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
// Simplified Chinese
|
|
537
|
+
{
|
|
538
|
+
name: "\u5FAE\u8F6F\u96C5\u9ED1",
|
|
539
|
+
fontFamilyName: {
|
|
540
|
+
mac: 'Microsoft YaHei',
|
|
541
|
+
windows: "\u5FAE\u8F6F\u96C5\u9ED1"
|
|
542
|
+
},
|
|
543
|
+
supportFontWeight: FONT_WEIGHT_100_400_700,
|
|
544
|
+
isSystemOwn: true,
|
|
545
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
546
|
+
langOrder: {
|
|
547
|
+
'zh-cn': 1
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
// 微软雅黑
|
|
551
|
+
{
|
|
552
|
+
name: "\u5B8B\u4F53",
|
|
553
|
+
fontFamilyName: {
|
|
554
|
+
mac: 'SimSun',
|
|
555
|
+
windows: "\u5B8B\u4F53"
|
|
556
|
+
},
|
|
557
|
+
supportFontWeight: FONT_WEIGHT_100_400_700_800,
|
|
558
|
+
isSystemOwn: true,
|
|
559
|
+
usuallyFontFamilyName: SERIF,
|
|
560
|
+
langOrder: {
|
|
561
|
+
'zh-cn': 1
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
// 宋体
|
|
565
|
+
{
|
|
566
|
+
name: "\u9ED1\u4F53",
|
|
567
|
+
fontFamilyName: {
|
|
568
|
+
mac: 'SimHei',
|
|
569
|
+
windows: "\u9ED1\u4F53"
|
|
570
|
+
},
|
|
571
|
+
supportFontWeight: [300, 500],
|
|
572
|
+
isSystemOwn: true,
|
|
573
|
+
usuallyFontFamilyName: SANS_SERIF,
|
|
574
|
+
langOrder: {
|
|
575
|
+
'zh-cn': 1
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
// 黑体
|
|
579
|
+
{
|
|
580
|
+
name: "\u6977\u4F53",
|
|
581
|
+
fontFamilyName: {
|
|
582
|
+
mac: 'KaiTi',
|
|
583
|
+
windows: "\u6977\u4F53"
|
|
584
|
+
},
|
|
585
|
+
supportFontWeight: [400, 700, 800],
|
|
586
|
+
isSystemOwn: true,
|
|
587
|
+
langOrder: {
|
|
588
|
+
'zh-cn': 1
|
|
589
|
+
}
|
|
590
|
+
} // 楷体
|
|
591
|
+
];
|
|
@@ -4,8 +4,8 @@ var _MENUS_CONFIG_MAP, _HEADER_TITLE_MAP;
|
|
|
4
4
|
import * as ELEMENT_TYPE from './element-type';
|
|
5
5
|
import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, SUPERSCRIPT, SUBSCRIPT, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST, CHECK_LIST_ITEM, LINK, HTML, CODE_BLOCK, CODE_LINE, IMAGE, TABLE, TABLE_CELL, TABLE_ROW, FORMULA, COLUMN, TEXT_STYLE, TEXT_STYLE_MORE, BOLD_ITALIC, TEXT_ALIGN, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, CLEAR_FORMAT, COLOR, HIGHLIGHT_COLOR } from './element-type';
|
|
6
6
|
import KEYBOARD from './keyboard';
|
|
7
|
-
import { DEFAULT_COLORS, STANDARD_COLORS,
|
|
8
|
-
import { SPECIAL_FONT_SIZE_NAME, DEFAULT_COMMON_FONT_SIZE, FONT_SIZE } from './font';
|
|
7
|
+
import { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BG_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BG_COLOR } from './color';
|
|
8
|
+
import { SPECIAL_FONT_SIZE_NAME, DEFAULT_COMMON_FONT_SIZE, FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY } from './font';
|
|
9
9
|
|
|
10
10
|
// history
|
|
11
11
|
export var UNDO = 'undo';
|
|
@@ -155,4 +155,4 @@ export var HEADER_TYPE_ARRAY = ['header1', 'header2', 'header3', 'header4', 'hea
|
|
|
155
155
|
export var LIST_TYPE_ARRAY = ['unordered_list', 'ordered_list'];
|
|
156
156
|
export var TRANSPARENT = 'transparent';
|
|
157
157
|
export var CLIPBOARD_FORMAT_KEY = 'x-slate-fragment';
|
|
158
|
-
export { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, SUPERSCRIPT, SUBSCRIPT, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST, CHECK_LIST_ITEM, LINK, HTML, CODE_BLOCK, CODE_LINE, IMAGE, TABLE, TABLE_CELL, TABLE_ROW, FORMULA, COLUMN, TEXT_STYLE, TEXT_STYLE_MORE, BOLD_ITALIC, TEXT_ALIGN, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ELEMENT_TYPE, KEYBOARD, DEFAULT_COLORS, STANDARD_COLORS,
|
|
158
|
+
export { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, SUPERSCRIPT, SUBSCRIPT, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST, CHECK_LIST_ITEM, LINK, HTML, CODE_BLOCK, CODE_LINE, IMAGE, TABLE, TABLE_CELL, TABLE_ROW, FORMULA, COLUMN, TEXT_STYLE, TEXT_STYLE_MORE, BOLD_ITALIC, TEXT_ALIGN, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ELEMENT_TYPE, KEYBOARD, DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, CLEAR_FORMAT, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BG_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BG_COLOR, SPECIAL_FONT_SIZE_NAME, DEFAULT_COMMON_FONT_SIZE, FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import { Editor, Element } from '@seafile/slate';
|
|
3
|
-
import { CODE_BLOCK, DEFAULT_COMMON_FONT_SIZE, IMAGE, FONT_SIZE, SPECIAL_FONT_SIZE_NAME } from '../../constants';
|
|
3
|
+
import { CODE_BLOCK, DEFAULT_COMMON_FONT_SIZE, IMAGE, FONT_SIZE, SPECIAL_FONT_SIZE_NAME, DEFAULT_FONT, GOOGLE_FONT_CLASS, FONT } from '../../constants';
|
|
4
4
|
import { focusEditor } from '../../core';
|
|
5
|
+
import context from '../../../../context';
|
|
6
|
+
import { isMac } from '../../../../utils';
|
|
5
7
|
export var isMenuDisabled = function isMenuDisabled(editor) {
|
|
6
8
|
if (!editor.selection) return true;
|
|
7
9
|
var _Editor$nodes = Editor.nodes(editor, {
|
|
@@ -19,6 +21,8 @@ export var isMenuDisabled = function isMenuDisabled(editor) {
|
|
|
19
21
|
}
|
|
20
22
|
return false;
|
|
21
23
|
};
|
|
24
|
+
|
|
25
|
+
// font size
|
|
22
26
|
export var getFontSize = function getFontSize(editor) {
|
|
23
27
|
var selection = editor.selection;
|
|
24
28
|
var marks = Editor.marks(editor);
|
|
@@ -58,4 +62,72 @@ export var scaleFontSize = function scaleFontSize(editor, type) {
|
|
|
58
62
|
if (fontSizeValue < 1) return;
|
|
59
63
|
}
|
|
60
64
|
setFontSize(editor, fontSizeValue);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// font
|
|
68
|
+
export var getFont = function getFont(editor) {
|
|
69
|
+
var selection = editor.selection;
|
|
70
|
+
var marks = Editor.marks(editor);
|
|
71
|
+
if (marks && marks['font']) return marks['font'];
|
|
72
|
+
if (!selection) return DEFAULT_FONT;
|
|
73
|
+
var _Editor$nodes5 = Editor.nodes(editor, {
|
|
74
|
+
at: Editor.unhangRange(editor, selection),
|
|
75
|
+
match: function match(n) {
|
|
76
|
+
return !Editor.isEditor(n) && !Element.isElement(n) && n['font'];
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
_Editor$nodes6 = _slicedToArray(_Editor$nodes5, 1),
|
|
80
|
+
match = _Editor$nodes6[0];
|
|
81
|
+
if (!match) return DEFAULT_FONT;
|
|
82
|
+
return match[0]['font'];
|
|
83
|
+
};
|
|
84
|
+
export var setFont = function setFont(editor, value) {
|
|
85
|
+
Editor.addMark(editor, 'font', value);
|
|
86
|
+
focusEditor(editor);
|
|
87
|
+
};
|
|
88
|
+
export var hasFontLoaded = function hasFontLoaded() {
|
|
89
|
+
var fontObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
90
|
+
var fontWeight = arguments.length > 1 ? arguments[1] : undefined;
|
|
91
|
+
var name = fontObject.name,
|
|
92
|
+
isSystemOwn = fontObject.isSystemOwn;
|
|
93
|
+
if (isSystemOwn) return true;
|
|
94
|
+
if (!name) return true;
|
|
95
|
+
var nameString = name.split(' ').join('+');
|
|
96
|
+
var fontLinkId = "sdoc-font-link-".concat(nameString, "-").concat(fontWeight);
|
|
97
|
+
return document.getElementById(fontLinkId);
|
|
98
|
+
};
|
|
99
|
+
export var loadFont = function loadFont() {
|
|
100
|
+
var fontObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
101
|
+
var fontWeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
|
|
102
|
+
var name = fontObject.name,
|
|
103
|
+
isSystemOwn = fontObject.isSystemOwn,
|
|
104
|
+
_fontObject$supportFo = fontObject.supportFontWeight,
|
|
105
|
+
supportFontWeight = _fontObject$supportFo === void 0 ? [] : _fontObject$supportFo;
|
|
106
|
+
if (isSystemOwn) return;
|
|
107
|
+
if (!name) return;
|
|
108
|
+
var validFontWeight = supportFontWeight.includes(fontWeight) ? fontWeight : supportFontWeight[0];
|
|
109
|
+
var nameString = name.split(' ').join('+');
|
|
110
|
+
var fontLinkId = "sdoc-font-link-".concat(nameString, "-").concat(validFontWeight);
|
|
111
|
+
if (document.getElementById(fontLinkId)) return;
|
|
112
|
+
var href = "https://fonts.googleapis.com/css?family=".concat(nameString, ":").concat(validFontWeight);
|
|
113
|
+
var fontLink = document.createElement('link');
|
|
114
|
+
fontLink.rel = 'stylesheet';
|
|
115
|
+
fontLink.href = href;
|
|
116
|
+
fontLink.id = fontLinkId;
|
|
117
|
+
fontLink.className = GOOGLE_FONT_CLASS;
|
|
118
|
+
document.body.appendChild(fontLink);
|
|
119
|
+
};
|
|
120
|
+
export var generatorFontFamily = function generatorFontFamily(fontName, fontWeight) {
|
|
121
|
+
var lang = context.getSetting('lang') || 'zh-cn';
|
|
122
|
+
if (fontName === DEFAULT_FONT) {
|
|
123
|
+
return "'Arial', ".concat(lang === 'zh-cn' ? "\u5B8B\u4F53" : 'Arial', ", 'sans-serif'");
|
|
124
|
+
}
|
|
125
|
+
var fontObject = FONT.find(function (item) {
|
|
126
|
+
return item.name === fontName;
|
|
127
|
+
}) || {};
|
|
128
|
+
var usuallyFontFamilyName = fontObject.usuallyFontFamilyName,
|
|
129
|
+
fontFamilyName = fontObject.fontFamilyName;
|
|
130
|
+
loadFont(fontObject, fontWeight);
|
|
131
|
+
var validFontName = fontFamilyName && isMac() ? fontFamilyName['mac'] : fontName;
|
|
132
|
+
return "".concat(validFontName, ", ").concat(lang === 'zh-cn' ? "\u5B8B\u4F53" : 'Arial', ", ").concat(usuallyFontFamilyName || 'sans-serif');
|
|
61
133
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { hasFontLoaded, generatorFontFamily } from '../../helpers';
|
|
5
|
+
import { DEFAULT_FONT } from '../../../../constants';
|
|
6
|
+
var FontItem = function FontItem(_ref) {
|
|
7
|
+
var selectedFont = _ref.selectedFont,
|
|
8
|
+
fontObject = _ref.fontObject,
|
|
9
|
+
setFont = _ref.setFont;
|
|
10
|
+
var _useTranslation = useTranslation(),
|
|
11
|
+
t = _useTranslation.t;
|
|
12
|
+
var fontName = fontObject.name;
|
|
13
|
+
var isSelected = selectedFont === fontName;
|
|
14
|
+
var isFontLoad = hasFontLoaded(fontObject, 400);
|
|
15
|
+
var style = isFontLoad ? {
|
|
16
|
+
fontFamily: generatorFontFamily(fontName, 400)
|
|
17
|
+
} : {};
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: classnames('sdoc-dropdown-menu-item', {
|
|
20
|
+
'position-relative': isSelected
|
|
21
|
+
}),
|
|
22
|
+
onClick: function onClick() {
|
|
23
|
+
return setFont(fontName);
|
|
24
|
+
}
|
|
25
|
+
}, isSelected && /*#__PURE__*/React.createElement("i", {
|
|
26
|
+
className: "sdocfont sdoc-check-mark"
|
|
27
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
28
|
+
style: style
|
|
29
|
+
}, fontName === DEFAULT_FONT ? t('Default_font') : fontName));
|
|
30
|
+
};
|
|
31
|
+
export default FontItem;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.menu-group .menu-group-item.sdoc-menu-with-dropdown.sdoc-font-family-menu {
|
|
2
|
+
width: 70px;
|
|
3
|
+
max-width: 70px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.sdoc-font-family-menu .sdoc-menu-with-dropdown-icon,
|
|
7
|
+
.sdoc-font-family-menu .sdoc-menu-with-dropdown-icon div {
|
|
8
|
+
width: 58px;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
text-overflow: ellipsis;
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sdoc-font-family-menu .sdoc-menu-with-dropdown-icon div {
|
|
15
|
+
padding-left: 5px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* sdoc-font-family-menu-popover */
|
|
19
|
+
.sdoc-font-family-menu-popover .sdoc-dropdown-menu-title-name {
|
|
20
|
+
padding: 8px 10px;
|
|
21
|
+
color: gray;
|
|
22
|
+
cursor: default;
|
|
23
|
+
font-size: 12px;
|
|
24
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
import { isMenuDisabled, getFont, setFont } from '../../helpers';
|
|
8
|
+
import { FONT, RECENT_USED_FONTS_KEY, DEFAULT_FONT } from '../../../../constants';
|
|
9
|
+
import Tooltip from '../../../../commons/tooltip';
|
|
10
|
+
import LocalStorage from '../../../../../../utils/local-storage-utils';
|
|
11
|
+
import context from '../../../../../../context';
|
|
12
|
+
import FontItem from './font-item';
|
|
13
|
+
import ObjectUtils from '../../../../../utils/object-utils';
|
|
14
|
+
import './index.css';
|
|
15
|
+
var FontFamily = function FontFamily(_ref) {
|
|
16
|
+
var editor = _ref.editor,
|
|
17
|
+
isRichEditor = _ref.isRichEditor,
|
|
18
|
+
className = _ref.className;
|
|
19
|
+
var _useState = useState(LocalStorage.getItem(RECENT_USED_FONTS_KEY, [])),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
recentUsedFonts = _useState2[0],
|
|
22
|
+
setRecentUsedFonts = _useState2[1];
|
|
23
|
+
var _useState3 = useState(false),
|
|
24
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
25
|
+
isShowMenu = _useState4[0],
|
|
26
|
+
setMenuShow = _useState4[1];
|
|
27
|
+
var _useState5 = useState(FONT),
|
|
28
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
29
|
+
fontList = _useState6[0],
|
|
30
|
+
setFontList = _useState6[1];
|
|
31
|
+
var _useTranslation = useTranslation(),
|
|
32
|
+
t = _useTranslation.t;
|
|
33
|
+
var popoverRef = useRef(null);
|
|
34
|
+
var disabled = isMenuDisabled(editor);
|
|
35
|
+
var fontSizeButtonId = 'sdoc-button-font';
|
|
36
|
+
var selectedFont = getFont(editor);
|
|
37
|
+
var lang = context.getSetting('lang');
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (lang === 'zh-cn') {
|
|
40
|
+
var chineseFonts = FONT.filter(function (item) {
|
|
41
|
+
return ObjectUtils.hasProperty(item, 'langOrder');
|
|
42
|
+
});
|
|
43
|
+
chineseFonts.sort(function (a, b) {
|
|
44
|
+
return b['langOrder'][lang] - a['langOrder'][lang];
|
|
45
|
+
});
|
|
46
|
+
var others = FONT.filter(function (item) {
|
|
47
|
+
return !ObjectUtils.hasProperty(item, 'langOrder');
|
|
48
|
+
});
|
|
49
|
+
setFontList([].concat(_toConsumableArray(chineseFonts), _toConsumableArray(others)));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
}, []);
|
|
54
|
+
var validClassName = classnames(className, 'sdoc-menu-with-dropdown sdoc-font-family-menu', {
|
|
55
|
+
'menu-show': isShowMenu,
|
|
56
|
+
'disabled': disabled,
|
|
57
|
+
'rich-icon-btn d-flex': isRichEditor,
|
|
58
|
+
'rich-icon-btn-disabled': isRichEditor && disabled,
|
|
59
|
+
'rich-icon-btn-hover': isRichEditor && !disabled,
|
|
60
|
+
'btn btn-icon btn-secondary btn-active d-flex': !isRichEditor
|
|
61
|
+
});
|
|
62
|
+
var fontRef = useRef(null);
|
|
63
|
+
var toggle = useCallback(function (event) {
|
|
64
|
+
popoverRef.current.toggle();
|
|
65
|
+
setMenuShow(!isShowMenu);
|
|
66
|
+
|
|
67
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
+
}, [isShowMenu]);
|
|
69
|
+
var caretIconClass = "sdoc-menu-with-dropdown-triangle-icon sdocfont sdoc-".concat(isShowMenu ? 'caret-up' : 'drop-down');
|
|
70
|
+
var _ref2 = fontRef.current ? fontRef.current.getBoundingClientRect() : {
|
|
71
|
+
bottom: 92.5
|
|
72
|
+
},
|
|
73
|
+
bottom = _ref2.bottom;
|
|
74
|
+
var updateFont = useCallback(function (fontName) {
|
|
75
|
+
toggle();
|
|
76
|
+
setFont(editor, fontName);
|
|
77
|
+
if (recentUsedFonts[0] !== fontName) {
|
|
78
|
+
var fontNameIndex = recentUsedFonts.findIndex(function (item) {
|
|
79
|
+
return item === fontName;
|
|
80
|
+
});
|
|
81
|
+
var newRecentUsedFonts;
|
|
82
|
+
if (fontNameIndex === -1) {
|
|
83
|
+
newRecentUsedFonts = recentUsedFonts.slice(0, 9);
|
|
84
|
+
} else {
|
|
85
|
+
newRecentUsedFonts = recentUsedFonts.slice(0);
|
|
86
|
+
newRecentUsedFonts.splice(fontNameIndex, 1);
|
|
87
|
+
}
|
|
88
|
+
newRecentUsedFonts.unshift(fontName);
|
|
89
|
+
LocalStorage.setItem(RECENT_USED_FONTS_KEY, newRecentUsedFonts);
|
|
90
|
+
setRecentUsedFonts(newRecentUsedFonts);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
}, [selectedFont, editor, isShowMenu, recentUsedFonts]);
|
|
95
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
className: validClassName,
|
|
98
|
+
id: fontSizeButtonId,
|
|
99
|
+
disabled: disabled,
|
|
100
|
+
ref: fontRef
|
|
101
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
className: "sdoc-menu-with-dropdown-icon"
|
|
103
|
+
}, /*#__PURE__*/React.createElement("div", null, selectedFont === DEFAULT_FONT ? t('Default_font') : selectedFont)), !disabled && /*#__PURE__*/React.createElement("div", {
|
|
104
|
+
className: "sdoc-menu-with-dropdown-triangle"
|
|
105
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
106
|
+
className: caretIconClass
|
|
107
|
+
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
108
|
+
target: fontSizeButtonId
|
|
109
|
+
}, t('Font')), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
110
|
+
target: fontSizeButtonId,
|
|
111
|
+
className: "sdoc-menu-popover sdoc-dropdown-menu sdoc-font-size-menu-popover sdoc-font-family-menu-popover",
|
|
112
|
+
trigger: "legacy",
|
|
113
|
+
placement: "bottom-start",
|
|
114
|
+
hideArrow: true,
|
|
115
|
+
toggle: toggle,
|
|
116
|
+
fade: false,
|
|
117
|
+
ref: popoverRef
|
|
118
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
119
|
+
className: "sdoc-font-size-menu-container",
|
|
120
|
+
style: {
|
|
121
|
+
maxHeight: window.innerHeight - bottom - 100
|
|
122
|
+
}
|
|
123
|
+
}, Array.isArray(recentUsedFonts) && recentUsedFonts.length > 0 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
124
|
+
className: "sdoc-dropdown-menu-title-name"
|
|
125
|
+
}, t('Recently_used')), recentUsedFonts.map(function (item, index) {
|
|
126
|
+
var fontObject = FONT.find(function (font) {
|
|
127
|
+
return font.name === item;
|
|
128
|
+
});
|
|
129
|
+
return /*#__PURE__*/React.createElement(FontItem, {
|
|
130
|
+
key: "".concat(index, "-recently-used"),
|
|
131
|
+
fontObject: fontObject,
|
|
132
|
+
selectedFont: selectedFont,
|
|
133
|
+
setFont: updateFont
|
|
134
|
+
});
|
|
135
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
136
|
+
className: "sdoc-dropdown-menu-divider"
|
|
137
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
className: "sdoc-dropdown-menu-title-name"
|
|
139
|
+
}, t('All_fonts')), fontList.map(function (item, index) {
|
|
140
|
+
if (item.type === 'divide') {
|
|
141
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
142
|
+
className: "sdoc-dropdown-menu-divider"
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/React.createElement(FontItem, {
|
|
146
|
+
key: "".concat(index, "-all-font"),
|
|
147
|
+
fontObject: item,
|
|
148
|
+
selectedFont: selectedFont,
|
|
149
|
+
setFont: updateFont
|
|
150
|
+
});
|
|
151
|
+
}))));
|
|
152
|
+
};
|
|
153
|
+
FontFamily.defaultProps = {
|
|
154
|
+
isRichEditor: true,
|
|
155
|
+
className: 'menu-group-item'
|
|
156
|
+
};
|
|
157
|
+
export default FontFamily;
|
|
@@ -2,10 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import React, { useState, useRef, useCallback } from 'react';
|
|
3
3
|
import { UncontrolledPopover } from 'reactstrap';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { Editor } from '@seafile/slate';
|
|
6
5
|
import classnames from 'classnames';
|
|
7
|
-
import {
|
|
8
|
-
import { isMenuDisabled, getFontSize } from '../../helpers';
|
|
6
|
+
import { isMenuDisabled, getFontSize, setFontSize } from '../../helpers';
|
|
9
7
|
import { DEFAULT_COMMON_FONT_SIZE, FONT_SIZE, SPECIAL_FONT_SIZE_NAME } from '../../../../constants';
|
|
10
8
|
import context from '../../../../../../context';
|
|
11
9
|
import { eventStopPropagation } from '../../../../../utils/mouse-event';
|
|
@@ -44,11 +42,10 @@ var FontSize = function FontSize(_ref) {
|
|
|
44
42
|
|
|
45
43
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
44
|
}, [isShowMenu]);
|
|
47
|
-
var
|
|
45
|
+
var updateFontSize = useCallback(function (item) {
|
|
48
46
|
var fontSize = SPECIAL_FONT_SIZE_NAME.includes(item.name) ? item.name : item.value;
|
|
49
|
-
Editor.addMark(editor, 'font-size', fontSize);
|
|
50
47
|
toggle();
|
|
51
|
-
|
|
48
|
+
setFontSize(editor, fontSize);
|
|
52
49
|
|
|
53
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
51
|
}, [editor, selectedFontSize, isShowMenu]);
|
|
@@ -134,7 +131,7 @@ var FontSize = function FontSize(_ref) {
|
|
|
134
131
|
'position-relative': isSelected
|
|
135
132
|
}),
|
|
136
133
|
onClick: function onClick() {
|
|
137
|
-
return
|
|
134
|
+
return updateFontSize(item);
|
|
138
135
|
}
|
|
139
136
|
}, isSelected && /*#__PURE__*/React.createElement("i", {
|
|
140
137
|
className: "sdocfont sdoc-check-mark"
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import FontFamily from './font-family';
|
|
2
3
|
import FontSize from './font-size';
|
|
3
4
|
var Font = function Font(_ref) {
|
|
4
5
|
var editor = _ref.editor;
|
|
5
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
6
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FontFamily, {
|
|
7
|
+
editor: editor
|
|
8
|
+
}), /*#__PURE__*/React.createElement(FontSize, {
|
|
6
9
|
editor: editor
|
|
7
10
|
}));
|
|
8
11
|
};
|
|
@@ -2,7 +2,8 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
2
2
|
var _excluded = ["text"];
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Caret from './caret';
|
|
5
|
-
import { SPECIAL_FONT_SIZE_NAME, FONT_SIZE } from '../../constants';
|
|
5
|
+
import { SPECIAL_FONT_SIZE_NAME, FONT_SIZE, DEFAULT_FONT } from '../../constants';
|
|
6
|
+
import { generatorFontFamily } from '../font/helpers';
|
|
6
7
|
var renderText = function renderText(props, editor) {
|
|
7
8
|
var attributes = props.attributes,
|
|
8
9
|
children = props.children,
|
|
@@ -27,17 +28,30 @@ var renderText = function renderText(props, editor) {
|
|
|
27
28
|
}
|
|
28
29
|
if (leaf['font-size']) {
|
|
29
30
|
var fontSize = leaf['font-size'];
|
|
31
|
+
var fontSizeValue = fontSize;
|
|
30
32
|
if (SPECIAL_FONT_SIZE_NAME.includes(fontSize)) {
|
|
31
33
|
var fontSizeItem = FONT_SIZE.find(function (item) {
|
|
32
34
|
return item.name === fontSize;
|
|
33
35
|
});
|
|
34
36
|
if (fontSizeItem) {
|
|
35
|
-
|
|
37
|
+
fontSizeValue = fontSizeItem.value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (typeof fontSizeValue === 'number') {
|
|
41
|
+
if (fontSizeValue < 12) {
|
|
42
|
+
style['fontSize'] = '12px';
|
|
43
|
+
style['display'] = 'inline-block';
|
|
44
|
+
style['transformOrigin'] = 'left top';
|
|
45
|
+
style['transform'] = "scale(".concat(fontSizeValue / 12, ")");
|
|
46
|
+
style['transition'] = 'all .1s';
|
|
47
|
+
} else {
|
|
48
|
+
style['fontSize'] = "".concat(fontSizeValue, "px");
|
|
36
49
|
}
|
|
37
|
-
} else {
|
|
38
|
-
style['fontSize'] = "".concat(fontSize, "px");
|
|
39
50
|
}
|
|
40
51
|
}
|
|
52
|
+
var font = leaf['font'] || DEFAULT_FONT;
|
|
53
|
+
var fontWeight = leaf.BOLD ? 600 : 400;
|
|
54
|
+
style['fontFamily'] = generatorFontFamily(font, fontWeight);
|
|
41
55
|
if (leaf.BOLD) {
|
|
42
56
|
markedChildren = /*#__PURE__*/React.createElement("strong", null, markedChildren);
|
|
43
57
|
}
|
package/dist/utils/index.js
CHANGED
|
@@ -40,4 +40,8 @@ export var getErrorMsg = function getErrorMsg(error) {
|
|
|
40
40
|
}
|
|
41
41
|
return errorMsg;
|
|
42
42
|
};
|
|
43
|
+
export var isMac = function isMac() {
|
|
44
|
+
var platform = navigator.platform;
|
|
45
|
+
return platform === 'Mac68K' || platform === 'MacPPC' || platform === 'Macintosh' || platform === 'MacIntel';
|
|
46
|
+
};
|
|
43
47
|
export { DateUtils, LocalStorage };
|
package/package.json
CHANGED
|
@@ -333,5 +333,8 @@
|
|
|
333
333
|
"Repair": "Repair",
|
|
334
334
|
"Font_size": "Font size",
|
|
335
335
|
"Increase_font_size": "Increase font size",
|
|
336
|
-
"Reduce_font_size": "Reduce font size"
|
|
336
|
+
"Reduce_font_size": "Reduce font size",
|
|
337
|
+
"Font": "Font",
|
|
338
|
+
"All_fonts": "All fonts",
|
|
339
|
+
"Default_font": "Default font"
|
|
337
340
|
}
|