@seafile/sdoc-editor 0.1.120 → 0.1.122
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/extension/commons/tooltip/index.css +12 -1
- package/dist/basic-sdk/extension/plugins/font/helpers.js +4 -3
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +40 -28
- package/dist/basic-sdk/extension/plugins/header/menu/style.css +32 -0
- package/dist/basic-sdk/extension/plugins/header/plugin.js +9 -0
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +1 -1
- package/dist/basic-sdk/utils/event-handler.js +11 -1
- package/dist/components/tip-message/index.js +5 -1
- package/dist/components/tip-message/style.css +8 -2
- package/package.json +1 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +10 -6
|
@@ -4,7 +4,18 @@
|
|
|
4
4
|
background-color: #303133;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.bs-tooltip-bottom.sdoc-tooltip .arrow::before,
|
|
8
7
|
.sdoc-tooltip.bs-tooltip-auto[x-placement^="bottom"] .arrow::before {
|
|
9
8
|
border-bottom-color: #303133;
|
|
10
9
|
}
|
|
10
|
+
|
|
11
|
+
.sdoc-tooltip.bs-tooltip-auto[x-placement^="top"] .arrow::before {
|
|
12
|
+
border-top-color: #303133;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sdoc-tooltip.bs-tooltip-auto[x-placement^="right"] .arrow::before {
|
|
16
|
+
border-right-color: #303133;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.sdoc-tooltip.bs-tooltip-auto[x-placement^="left"] .arrow::before {
|
|
20
|
+
border-left-color: #303133;
|
|
21
|
+
}
|
|
@@ -130,10 +130,11 @@ export var loadFont = function loadFont() {
|
|
|
130
130
|
fontLink.className = GOOGLE_FONT_CLASS;
|
|
131
131
|
document.body.appendChild(fontLink);
|
|
132
132
|
};
|
|
133
|
-
export var generatorFontFamily = function generatorFontFamily(fontName, fontWeight) {
|
|
133
|
+
export var generatorFontFamily = function generatorFontFamily(fontName, fontWeight, leaf) {
|
|
134
|
+
var isCodeBlock = leaf && Object.keys(leaf).includes('token');
|
|
134
135
|
var lang = context.getSetting('lang') || 'zh-cn';
|
|
135
136
|
if (fontName === DEFAULT_FONT) {
|
|
136
|
-
return "'Arial', ".concat(lang === 'zh-cn' ? "\u5B8B\u4F53" : 'Arial', ", 'sans-serif'");
|
|
137
|
+
return "".concat(isCodeBlock ? 'monospace' : 'Arial', ", ").concat(lang === 'zh-cn' ? "\u5B8B\u4F53" : 'Arial', ", 'sans-serif'");
|
|
137
138
|
}
|
|
138
139
|
var fontObject = FONT.find(function (item) {
|
|
139
140
|
return item.name === fontName;
|
|
@@ -142,5 +143,5 @@ export var generatorFontFamily = function generatorFontFamily(fontName, fontWeig
|
|
|
142
143
|
fontFamilyName = fontObject.fontFamilyName;
|
|
143
144
|
loadFont(fontObject, fontWeight);
|
|
144
145
|
var validFontName = fontFamilyName && isMac() ? fontFamilyName['mac'] : fontName;
|
|
145
|
-
return "".concat(validFontName, ", ").concat(lang === 'zh-cn' ? "\u5B8B\u4F53" : 'Arial', ", ").concat(usuallyFontFamilyName || 'sans-serif');
|
|
146
|
+
return "".concat(isCodeBlock ? 'monospace' : validFontName, ", ").concat(lang === 'zh-cn' ? "\u5B8B\u4F53" : 'Arial', ", ").concat(usuallyFontFamilyName || 'sans-serif');
|
|
146
147
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
import React from 'react';
|
|
6
|
+
import React, { Fragment } from 'react';
|
|
6
7
|
import { withTranslation } from 'react-i18next';
|
|
7
8
|
import classnames from 'classnames';
|
|
8
9
|
import { getHeaderType, isMenuDisabled, setHeaderType } from '../helpers';
|
|
9
|
-
import {
|
|
10
|
+
import { HEADERS, HEADER_TITLE_MAP, PARAGRAPH } from '../../../constants';
|
|
11
|
+
import Tooltip from '../../../commons/tooltip';
|
|
10
12
|
import './style.css';
|
|
11
13
|
var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
12
14
|
_inherits(HeaderMenu, _React$Component);
|
|
@@ -78,6 +80,11 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
78
80
|
_this.setMenuRef = function (ref) {
|
|
79
81
|
_this.menu = ref;
|
|
80
82
|
};
|
|
83
|
+
_this.getToolTip = function (index) {
|
|
84
|
+
//chrome in Mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
|
|
85
|
+
var isMac = window.navigator.userAgent.indexOf('Macintosh') != -1;
|
|
86
|
+
return isMac ? "\u2318 +\u2325 +".concat(index) : "ctrl+alt+".concat(index);
|
|
87
|
+
};
|
|
81
88
|
_this.state = {
|
|
82
89
|
isShowHeaderPopover: false
|
|
83
90
|
};
|
|
@@ -86,11 +93,13 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
86
93
|
_createClass(HeaderMenu, [{
|
|
87
94
|
key: "render",
|
|
88
95
|
value: function render() {
|
|
96
|
+
var _this2 = this;
|
|
89
97
|
var t = this.props.t;
|
|
90
98
|
var isShowHeaderPopover = this.state.isShowHeaderPopover;
|
|
91
99
|
var headerIconClass = "sdocfont sdoc-".concat(isShowHeaderPopover ? 'caret-up' : 'drop-down');
|
|
92
|
-
var
|
|
100
|
+
var currentType = this.getValue();
|
|
93
101
|
var disabled = this.isDisabled();
|
|
102
|
+
var itemList = [PARAGRAPH, 'divider'].concat(_toConsumableArray(HEADERS));
|
|
94
103
|
return /*#__PURE__*/React.createElement("div", {
|
|
95
104
|
className: "header-menu"
|
|
96
105
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -100,35 +109,38 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
100
109
|
onClick: disabled ? function () {} : this.onToggleClick
|
|
101
110
|
}, /*#__PURE__*/React.createElement("span", {
|
|
102
111
|
className: "active"
|
|
103
|
-
}, t(HEADER_TITLE_MAP[
|
|
112
|
+
}, t(HEADER_TITLE_MAP[currentType])), !disabled && /*#__PURE__*/React.createElement("span", {
|
|
104
113
|
className: headerIconClass
|
|
105
114
|
})), isShowHeaderPopover && /*#__PURE__*/React.createElement("div", {
|
|
106
115
|
ref: this.setMenuRef,
|
|
107
116
|
className: "header-popover sdoc-dropdown-menu"
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
117
|
+
}, itemList.map(function (item, index) {
|
|
118
|
+
if (item == 'divider') {
|
|
119
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
120
|
+
key: index,
|
|
121
|
+
className: "sdoc-dropdown-menu-divider"
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
var isSelected = currentType == item;
|
|
125
|
+
var titleIndex = index == 0 ? 0 : index - 1;
|
|
126
|
+
var id = "".concat(item, "-").concat(titleIndex);
|
|
127
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
128
|
+
key: index
|
|
129
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
id: id,
|
|
131
|
+
className: classnames('sdoc-dropdown-menu-item', {
|
|
132
|
+
'position-relative': isSelected
|
|
133
|
+
}),
|
|
134
|
+
onClick: _this2.onMouseDown(item)
|
|
135
|
+
}, isSelected && /*#__PURE__*/React.createElement("i", {
|
|
136
|
+
className: "sdocfont sdoc-check-mark"
|
|
137
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
138
|
+
className: item
|
|
139
|
+
}, t(HEADER_TITLE_MAP[item]))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
140
|
+
target: id,
|
|
141
|
+
placement: "right"
|
|
142
|
+
}, _this2.getToolTip(titleIndex)));
|
|
143
|
+
})));
|
|
132
144
|
}
|
|
133
145
|
}]);
|
|
134
146
|
return HeaderMenu;
|
|
@@ -62,3 +62,35 @@
|
|
|
62
62
|
.header-menu .header-popover .sdoc-dropdown-menu-item {
|
|
63
63
|
font-size: 14px;
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
.header-menu .header-popover .sdoc-dropdown-menu-item .sdoc-check-mark {
|
|
67
|
+
position: absolute;
|
|
68
|
+
left: 8px;
|
|
69
|
+
transform: scale(.8);
|
|
70
|
+
color: #798d99;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.header-menu .header-popover .header1 {
|
|
74
|
+
font-size: 18px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.header-menu .header-popover .header2 {
|
|
78
|
+
font-size: 16px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.header-menu .header-popover .header3 {
|
|
82
|
+
font-size: 14px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.header-menu .header-popover .header4 {
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.header-menu .header-popover .header5 {
|
|
90
|
+
font-size: 11px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.header-menu .header-popover .header6 {
|
|
94
|
+
font-size: 11px;
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import { Editor, Element, Transforms, Node } from '@seafile/slate';
|
|
3
3
|
import { PARAGRAPH, HEADER_TYPE_ARRAY, LIST_TYPE_ARRAY } from '../../constants';
|
|
4
4
|
import { generateEmptyElement, getSelectedNodeByTypes } from '../../core';
|
|
5
|
+
import { isMenuDisabled, setHeaderType } from './helpers';
|
|
5
6
|
var isSelectionAtLineEnd = function isSelectionAtLineEnd(editor, path) {
|
|
6
7
|
var selection = editor.selection;
|
|
7
8
|
if (!selection) return false;
|
|
@@ -68,6 +69,14 @@ var withHeader = function withHeader(editor) {
|
|
|
68
69
|
}
|
|
69
70
|
return insertFragment(data);
|
|
70
71
|
};
|
|
72
|
+
|
|
73
|
+
// for hotkey
|
|
74
|
+
newEditor.setParagraphHeadingType = function (type) {
|
|
75
|
+
if (isMenuDisabled(newEditor)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
setHeaderType(newEditor, type);
|
|
79
|
+
};
|
|
71
80
|
return newEditor;
|
|
72
81
|
};
|
|
73
82
|
export default withHeader;
|
|
@@ -51,7 +51,7 @@ var renderText = function renderText(props, editor) {
|
|
|
51
51
|
}
|
|
52
52
|
var font = leaf['font'] || DEFAULT_FONT;
|
|
53
53
|
var fontWeight = leaf.BOLD ? 600 : 400;
|
|
54
|
-
style['fontFamily'] = generatorFontFamily(font, fontWeight);
|
|
54
|
+
style['fontFamily'] = generatorFontFamily(font, fontWeight, leaf);
|
|
55
55
|
if (leaf.BOLD) {
|
|
56
56
|
markedChildren = /*#__PURE__*/React.createElement("strong", null, markedChildren);
|
|
57
57
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
4
|
import isHotkey from 'is-hotkey';
|
|
4
5
|
import EventBus from '../utils/event-bus';
|
|
5
6
|
import { getSelectedNodeByType } from '../extension/core/queries/';
|
|
6
|
-
import { ELEMENT_TYPE } from '../extension/constants';
|
|
7
|
+
import { ELEMENT_TYPE, PARAGRAPH, HEADERS } from '../extension/constants';
|
|
7
8
|
import { INTERNAL_EVENT } from '../constants';
|
|
8
9
|
var EventProxy = /*#__PURE__*/_createClass(function EventProxy(_editor) {
|
|
9
10
|
var _this = this;
|
|
@@ -11,6 +12,15 @@ var EventProxy = /*#__PURE__*/_createClass(function EventProxy(_editor) {
|
|
|
11
12
|
this.onKeyDown = function (event) {
|
|
12
13
|
var editor = _this.editor;
|
|
13
14
|
|
|
15
|
+
// paragrah, headings
|
|
16
|
+
var paragraphHeadingList = [PARAGRAPH].concat(_toConsumableArray(HEADERS));
|
|
17
|
+
paragraphHeadingList.forEach(function (item, index) {
|
|
18
|
+
if (isHotkey("cmd+opt+".concat(index), event) || isHotkey("ctrl+alt+".concat(index), event)) {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
editor.setParagraphHeadingType(item);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
14
24
|
// bold
|
|
15
25
|
if (isHotkey('mod+b', event)) {
|
|
16
26
|
event.preventDefault();
|
|
@@ -118,7 +118,11 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
118
118
|
if (lastSavedAt) {
|
|
119
119
|
return /*#__PURE__*/React.createElement("span", {
|
|
120
120
|
className: "tip-message"
|
|
121
|
-
}, /*#__PURE__*/React.createElement("span",
|
|
121
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
122
|
+
className: "sdocfont sdoc-save-tip mr-2"
|
|
123
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
124
|
+
className: "save-time"
|
|
125
|
+
}, dayjs(lastSavedAt).format('HH:mm')));
|
|
122
126
|
}
|
|
123
127
|
return null;
|
|
124
128
|
};
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
opacity: 0.75;
|
|
5
5
|
color: #999;
|
|
6
6
|
width: max-content;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
height: 27px;
|
|
8
|
+
line-height: 27px;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sdoc-editor-page-wrapper .tip-message .sdocfont {
|
|
13
|
+
padding-top: 1px;
|
|
14
|
+
font-size: 14px;
|
|
9
15
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="sdoc-save-tip" unicode="" d="M528 800c153.6 0 272-112 284.8-252.8 121.6-9.6 208-137.6 208-291.2 0-160-86.4-284.8-201.6-288H208c-96 0-208 124.8-208 284.8s89.6 294.4 227.2 288c9.6 0 16 0 22.4-3.2C291.2 694.4 374.4 800 528 800z m3.2-96c-99.2 0-179.2-73.6-208-256-48 3.2-76.8 3.2-96 0-73.6-9.6-131.2-86.4-131.2-185.6S166.4 64 227.2 64h582.4c54.4 0 118.4 96 118.4 198.4 0 89.6-35.2 166.4-99.2 185.6-28.8 9.6-67.2 12.8-92.8 6.4-6.4 169.6-99.2 249.6-204.8 249.6z m163.2-252.8l38.4-41.6c6.4-6.4 6.4-16 0-22.4l-256-249.6c-12.8-12.8-32-16-44.8-3.2l-147.2 140.8c-6.4 6.4-6.4 12.8-3.2 19.2l3.2 3.2 38.4 38.4c6.4 6.4 16 6.4 22.4 0l108.8-105.6L672 448c6.4 9.6 16 9.6 22.4 3.2z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
17
19
|
<glyph glyph-name="sdoc-file" unicode="" d="M460.8 723.2H112c-16 0-35.2-12.8-35.2-35.2v-601.6c0-19.2 16-35.2 35.2-35.2h803.2c16 0 35.2 19.2 35.2 35.2V576c0 19.2-16 35.2-35.2 35.2H588.8c-12.8 0-16 6.4-22.4 12.8l-105.6 99.2z m137.6-38.4h313.6c57.6 0 112-48 112-115.2v-489.6c0-60.8-48-115.2-112-115.2h-800C51.2-32 0 16 0 83.2V684.8C0 745.6 48 800 112 800h361.6c12.8 0 16-6.4 22.4-12.8l102.4-102.4z" horiz-adv-x="1024" />
|
|
18
20
|
|
|
19
21
|
<glyph glyph-name="sdoc-header6" unicode="" d="M96 896v-400h448V896h96v-960h-96V400H96V-64H0V896h96zM787.2 115.2c12.8 16 28.8 28.8 44.8 35.2s35.2 12.8 54.4 12.8c19.2 0 38.4-3.2 54.4-9.6 16-6.4 32-16 41.6-28.8 16-16 25.6-28.8 32-48s9.6-35.2 9.6-54.4c0-28.8-6.4-54.4-19.2-76.8s-32-41.6-54.4-54.4c-25.6-12.8-51.2-19.2-80-19.2-35.2 0-64 9.6-89.6 25.6S736-64 723.2-32s-19.2 70.4-19.2 118.4c0 38.4 3.2 70.4 12.8 102.4s19.2 51.2 32 73.6 32 35.2 54.4 44.8 44.8 12.8 73.6 12.8c25.6 0 48-6.4 70.4-16s32-22.4 44.8-35.2c9.6-16 16-28.8 16-41.6 0-9.6-3.2-16-9.6-22.4s-16-12.8-25.6-12.8c-9.6 0-16 3.2-25.6 9.6-6.4 6.4-12.8 12.8-16 22.4-3.2 9.6-12.8 19.2-22.4 28.8-9.6 6.4-22.4 9.6-35.2 9.6-9.6 0-22.4-3.2-32-9.6-9.6-6.4-19.2-12.8-25.6-22.4-16-22.4-25.6-60.8-28.8-115.2z m83.2-185.6c19.2 0 38.4 9.6 51.2 25.6s19.2 38.4 19.2 64c0 19.2-3.2 35.2-9.6 48-3.2 12.8-12.8 22.4-25.6 28.8-9.6 6.4-22.4 9.6-35.2 9.6-12.8 0-25.6-3.2-35.2-9.6-12.8-6.4-22.4-16-28.8-28.8-6.4-9.6-9.6-25.6-9.6-41.6 0-25.6 6.4-48 22.4-67.2 12.8-19.2 28.8-28.8 51.2-28.8z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "sdocfont"; /* Project id 4097705 */
|
|
3
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
4
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./sdoc-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./sdoc-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./sdoc-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./sdoc-editor-font/iconfont.svg?t=
|
|
3
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1692612471690'); /* IE9 */
|
|
4
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1692612471690#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./sdoc-editor-font/iconfont.woff2?t=1692612471690') format('woff2'),
|
|
6
|
+
url('./sdoc-editor-font/iconfont.woff?t=1692612471690') format('woff'),
|
|
7
|
+
url('./sdoc-editor-font/iconfont.ttf?t=1692612471690') format('truetype'),
|
|
8
|
+
url('./sdoc-editor-font/iconfont.svg?t=1692612471690#sdocfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.sdoc-save-tip:before {
|
|
20
|
+
content: "\e650";
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
.sdoc-file:before {
|
|
20
24
|
content: "\e60f";
|
|
21
25
|
}
|