@seafile/sdoc-editor 0.1.45 → 0.1.46
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/assets/css/simple-editor.css +2 -2
- package/dist/basic-sdk/editor.js +1 -4
- package/dist/basic-sdk/extension/constants/element-type.js +2 -0
- package/dist/basic-sdk/extension/constants/index.js +12 -2
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.css +2 -1
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +19 -23
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +18 -9
- package/dist/basic-sdk/socket/helpers.js +4 -10
- package/dist/basic-sdk/socket/socket-client.js +2 -4
- package/dist/basic-sdk/socket/socket-manager.js +2 -3
- package/dist/basic-sdk/socket/with-socket-io.js +3 -7
- package/package.json +1 -2
- package/public/locales/en/sdoc-editor.json +2 -0
- package/dist/basic-sdk/cursor/decorate.js +0 -35
- package/dist/basic-sdk/cursor/helper.js +0 -40
- package/dist/basic-sdk/extension/plugins/text-style/caret.js +0 -47
package/dist/basic-sdk/editor.js
CHANGED
|
@@ -13,7 +13,6 @@ import withNodeId from './node-id';
|
|
|
13
13
|
import SDocOutline from './outline';
|
|
14
14
|
import EventProxy from './utils/event-handler';
|
|
15
15
|
import { focusEditor } from './extension/core';
|
|
16
|
-
import { getDecorate } from './cursor/decorate';
|
|
17
16
|
import './assets/css/layout.css';
|
|
18
17
|
import './assets/css/sdoc-editor-plugins.css';
|
|
19
18
|
var SDocEditor = /*#__PURE__*/function (_React$Component) {
|
|
@@ -85,7 +84,6 @@ var SDocEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
85
84
|
var slateValue = this.state.slateValue;
|
|
86
85
|
var config = this.props.config;
|
|
87
86
|
var docUuid = config.docUuid;
|
|
88
|
-
var decorate = getDecorate(editor);
|
|
89
87
|
return /*#__PURE__*/React.createElement("div", {
|
|
90
88
|
className: "sdoc-editor-container"
|
|
91
89
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
@@ -111,8 +109,7 @@ var SDocEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
111
109
|
return _renderLeaf(props, _this2.editor);
|
|
112
110
|
},
|
|
113
111
|
onKeyDown: this.eventProxy.onKeyDown,
|
|
114
|
-
onDOMBeforeInput: this.onDOMBeforeInput
|
|
115
|
-
decorate: decorate
|
|
112
|
+
onDOMBeforeInput: this.onDOMBeforeInput
|
|
116
113
|
}))))));
|
|
117
114
|
}
|
|
118
115
|
}]);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export var BLOCKQUOTE = 'blockquote';
|
|
2
2
|
export var BOLD = 'bold';
|
|
3
3
|
export var ITALIC = 'italic';
|
|
4
|
+
export var UNDERLINE = 'underline';
|
|
5
|
+
export var STRIKETHROUGH = 'strikethrough';
|
|
4
6
|
export var HEADER = 'header';
|
|
5
7
|
export var HEADER1 = 'header1';
|
|
6
8
|
export var HEADER2 = 'header2';
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
var _MENUS_CONFIG_MAP, _HEADER_TITLE_MAP;
|
|
3
3
|
// extension plugin
|
|
4
4
|
import * as ELEMENT_TYPE from './element-type';
|
|
5
|
-
import { BLOCKQUOTE,
|
|
5
|
+
import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, 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, BOLD_ITALIC } from './element-type';
|
|
6
6
|
import KEYBOARD from './keyboard';
|
|
7
7
|
|
|
8
8
|
// history
|
|
@@ -59,6 +59,16 @@ export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CO
|
|
|
59
59
|
iconClass: 'sdocfont sdoc-bold',
|
|
60
60
|
text: 'bold',
|
|
61
61
|
type: 'BOLD'
|
|
62
|
+
}, {
|
|
63
|
+
id: UNDERLINE,
|
|
64
|
+
iconClass: 'sdocfont sdoc-underline',
|
|
65
|
+
text: 'underline',
|
|
66
|
+
type: 'UNDERLINE'
|
|
67
|
+
}, {
|
|
68
|
+
id: STRIKETHROUGH,
|
|
69
|
+
iconClass: 'sdocfont sdoc-strikethrough',
|
|
70
|
+
text: 'strikethrough',
|
|
71
|
+
type: 'STRIKETHROUGH'
|
|
62
72
|
}]), _defineProperty(_MENUS_CONFIG_MAP, UNDO, {
|
|
63
73
|
id: UNDO,
|
|
64
74
|
iconClass: 'sdocfont sdoc-revoke',
|
|
@@ -90,4 +100,4 @@ export var TABLE_ELEMENT_POSITION = {
|
|
|
90
100
|
AFTER: 'after',
|
|
91
101
|
BEFORE: 'before'
|
|
92
102
|
};
|
|
93
|
-
export { BLOCKQUOTE,
|
|
103
|
+
export { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, 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, BOLD_ITALIC, ELEMENT_TYPE, KEYBOARD };
|
|
@@ -11,10 +11,13 @@ import { getValue, isMenuDisabled, addMark, removeMark } from '../helpers';
|
|
|
11
11
|
var TextStyleMenuList = /*#__PURE__*/function (_React$Component) {
|
|
12
12
|
_inherits(TextStyleMenuList, _React$Component);
|
|
13
13
|
var _super = _createSuper(TextStyleMenuList);
|
|
14
|
-
function TextStyleMenuList(
|
|
14
|
+
function TextStyleMenuList() {
|
|
15
15
|
var _this;
|
|
16
16
|
_classCallCheck(this, TextStyleMenuList);
|
|
17
|
-
|
|
17
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
args[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
18
21
|
_this.isActive = function (editor, type) {
|
|
19
22
|
var isMark = getValue(editor, type);
|
|
20
23
|
return !!isMark;
|
|
@@ -36,43 +39,36 @@ var TextStyleMenuList = /*#__PURE__*/function (_React$Component) {
|
|
|
36
39
|
}
|
|
37
40
|
focusEditor(editor);
|
|
38
41
|
};
|
|
39
|
-
_this.state = {
|
|
40
|
-
isShowLinkDialog: false
|
|
41
|
-
};
|
|
42
42
|
return _this;
|
|
43
43
|
}
|
|
44
44
|
_createClass(TextStyleMenuList, [{
|
|
45
45
|
key: "getTextStyleMenuList",
|
|
46
46
|
value: function getTextStyleMenuList() {
|
|
47
|
+
var _this2 = this;
|
|
47
48
|
var _this$props = this.props,
|
|
48
49
|
isRichEditor = _this$props.isRichEditor,
|
|
49
50
|
className = _this$props.className,
|
|
50
51
|
editor = _this$props.editor;
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
onMouseDown: this.onMouseDown
|
|
63
|
-
}];
|
|
64
|
-
return textStyleMenuList;
|
|
52
|
+
var list = MENUS_CONFIG_MAP[TEXT_STYLE].map(function (item) {
|
|
53
|
+
var itemProps = {
|
|
54
|
+
isRichEditor: isRichEditor,
|
|
55
|
+
className: className,
|
|
56
|
+
disabled: _this2.isDisabled(),
|
|
57
|
+
isActive: _this2.isActive(editor, item.type),
|
|
58
|
+
onMouseDown: _this2.onMouseDown
|
|
59
|
+
};
|
|
60
|
+
return _objectSpread(_objectSpread({}, itemProps), item);
|
|
61
|
+
});
|
|
62
|
+
return list;
|
|
65
63
|
}
|
|
66
64
|
}, {
|
|
67
65
|
key: "render",
|
|
68
66
|
value: function render() {
|
|
69
67
|
var textStyleMenuList = this.getTextStyleMenuList();
|
|
70
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, textStyleMenuList.map(function (
|
|
71
|
-
var menuItemConfig = MENUS_CONFIG_MAP[TEXT_STYLE][index];
|
|
72
|
-
var menuItemProps = _objectSpread(_objectSpread({}, menuItem), menuItemConfig);
|
|
68
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, textStyleMenuList.map(function (itemProps, index) {
|
|
73
69
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({
|
|
74
70
|
key: index
|
|
75
|
-
},
|
|
71
|
+
}, itemProps));
|
|
76
72
|
}));
|
|
77
73
|
}
|
|
78
74
|
}]);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Caret from './caret';
|
|
3
2
|
var renderText = function renderText(props, editor) {
|
|
4
3
|
var attributes = props.attributes,
|
|
5
4
|
children = props.children,
|
|
@@ -8,12 +7,26 @@ var renderText = function renderText(props, editor) {
|
|
|
8
7
|
if (leaf.BOLD) {
|
|
9
8
|
markedChildren = /*#__PURE__*/React.createElement("strong", null, markedChildren);
|
|
10
9
|
}
|
|
11
|
-
if (leaf.CODE) {
|
|
12
|
-
markedChildren = /*#__PURE__*/React.createElement("code", null, markedChildren);
|
|
13
|
-
}
|
|
14
10
|
if (leaf.ITALIC) {
|
|
15
11
|
markedChildren = /*#__PURE__*/React.createElement("i", null, markedChildren);
|
|
16
12
|
}
|
|
13
|
+
if (leaf.UNDERLINE) {
|
|
14
|
+
markedChildren = /*#__PURE__*/React.createElement("span", {
|
|
15
|
+
style: {
|
|
16
|
+
textDecoration: 'underline'
|
|
17
|
+
}
|
|
18
|
+
}, markedChildren);
|
|
19
|
+
}
|
|
20
|
+
if (leaf.STRIKETHROUGH) {
|
|
21
|
+
markedChildren = /*#__PURE__*/React.createElement("span", {
|
|
22
|
+
style: {
|
|
23
|
+
textDecoration: 'line-through'
|
|
24
|
+
}
|
|
25
|
+
}, markedChildren);
|
|
26
|
+
}
|
|
27
|
+
if (leaf.CODE) {
|
|
28
|
+
markedChildren = /*#__PURE__*/React.createElement("code", null, markedChildren);
|
|
29
|
+
}
|
|
17
30
|
if (leaf.DELETE) {
|
|
18
31
|
markedChildren = /*#__PURE__*/React.createElement("del", null, markedChildren);
|
|
19
32
|
}
|
|
@@ -27,10 +40,6 @@ var renderText = function renderText(props, editor) {
|
|
|
27
40
|
}
|
|
28
41
|
return /*#__PURE__*/React.createElement("span", Object.assign({
|
|
29
42
|
"data-id": leaf.id
|
|
30
|
-
}, attributes,
|
|
31
|
-
style: {
|
|
32
|
-
position: 'relative'
|
|
33
|
-
}
|
|
34
|
-
}), leaf.isCaret ? /*#__PURE__*/React.createElement(Caret, leaf) : null, markedChildren);
|
|
43
|
+
}, attributes), markedChildren);
|
|
35
44
|
};
|
|
36
45
|
export default renderText;
|
|
@@ -3,7 +3,6 @@ import deepCopy from 'deep-copy';
|
|
|
3
3
|
import { Editor, Operation } from '@seafile/slate';
|
|
4
4
|
import { getNode } from '../extension/core';
|
|
5
5
|
import * as OPERATION from '../node-id/constants';
|
|
6
|
-
import { setCursor } from '../cursor/helper';
|
|
7
6
|
export var getNodePathById = function getNodePathById(rootNode, nodeId) {
|
|
8
7
|
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
9
8
|
if (rootNode.id === nodeId) return path;
|
|
@@ -251,16 +250,11 @@ export var reExecRevertOperationList = function reExecRevertOperationList(editor
|
|
|
251
250
|
_loop2();
|
|
252
251
|
}
|
|
253
252
|
};
|
|
254
|
-
export var syncRemoteOperations = function syncRemoteOperations(editor, remoteOperations
|
|
253
|
+
export var syncRemoteOperations = function syncRemoteOperations(editor, remoteOperations) {
|
|
255
254
|
if (remoteOperations.length === 0) return;
|
|
256
255
|
Editor.withoutNormalizing(editor, function () {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
editor.apply(op);
|
|
263
|
-
}
|
|
264
|
-
setCursor(user.username, editor, remoteOperations);
|
|
256
|
+
remoteOperations.forEach(function (item) {
|
|
257
|
+
editor.apply(item);
|
|
258
|
+
});
|
|
265
259
|
});
|
|
266
260
|
};
|
|
@@ -11,12 +11,10 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
|
|
|
11
11
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
12
|
var _this$config = _this.config,
|
|
13
13
|
docUuid = _this$config.docUuid,
|
|
14
|
-
user = _this$config.user
|
|
15
|
-
cursorData = _this$config.cursorData;
|
|
14
|
+
user = _this$config.user;
|
|
16
15
|
return _objectSpread({
|
|
17
16
|
doc_uuid: docUuid,
|
|
18
|
-
user: user
|
|
19
|
-
cursor_data: cursorData
|
|
17
|
+
user: user
|
|
20
18
|
}, params);
|
|
21
19
|
};
|
|
22
20
|
this.onConnected = function () {
|
|
@@ -83,11 +83,10 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, doc
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// 2. execute operations
|
|
86
|
-
var operations = params.operations
|
|
87
|
-
user = params.user;
|
|
86
|
+
var operations = params.operations;
|
|
88
87
|
// 2.1 Update content & version
|
|
89
88
|
debug('execute remote operations: %O', operations);
|
|
90
|
-
syncRemoteOperations(_this.editor, operations
|
|
89
|
+
syncRemoteOperations(_this.editor, operations);
|
|
91
90
|
|
|
92
91
|
// 2.2 Update document
|
|
93
92
|
_this.document.version = serverVersion;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
var _this = this;
|
|
2
|
-
import { generateCursorData, setCursor } from '../cursor/helper';
|
|
3
2
|
import SocketManager from './socket-manager';
|
|
4
3
|
var withSocketIO = function withSocketIO(editor, options) {
|
|
5
4
|
var onChange = editor.onChange;
|
|
6
5
|
var newEditor = editor;
|
|
7
|
-
var cursorData = generateCursorData(options.config);
|
|
8
6
|
var socketManager = null;
|
|
9
7
|
newEditor.openConnection = function () {
|
|
10
8
|
var document = options.document,
|
|
11
9
|
config = options.config;
|
|
12
|
-
config['cursorData'] = cursorData;
|
|
13
10
|
socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
14
11
|
};
|
|
15
12
|
newEditor.closeConnection = function () {
|
|
@@ -17,13 +14,12 @@ var withSocketIO = function withSocketIO(editor, options) {
|
|
|
17
14
|
};
|
|
18
15
|
newEditor.onChange = function () {
|
|
19
16
|
var operations = newEditor.operations;
|
|
20
|
-
|
|
17
|
+
operations = operations.filter(function (item) {
|
|
18
|
+
return item.type !== 'set_selection';
|
|
19
|
+
});
|
|
21
20
|
if (!newEditor.isRemote && operations.length > 0) {
|
|
22
21
|
var _socketManager = SocketManager.getInstance();
|
|
23
22
|
_socketManager.addOperations && _socketManager.addOperations(operations);
|
|
24
|
-
var config = options.config;
|
|
25
|
-
var clientId = config.user.username;
|
|
26
|
-
setCursor(clientId, editor, operations, cursorData);
|
|
27
23
|
}
|
|
28
24
|
onChange();
|
|
29
25
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a sdoc editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"deep-copy": "1.4.2",
|
|
15
15
|
"is-hotkey": "0.2.0",
|
|
16
16
|
"is-url": "^1.2.4",
|
|
17
|
-
"randomcolor": "0.6.2",
|
|
18
17
|
"react-cookies": "0.1.1",
|
|
19
18
|
"reactstrap": "8.9.0",
|
|
20
19
|
"slugid": "3.2.0",
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import { Text, Path, Range } from '@seafile/slate';
|
|
4
|
-
export var getDecorate = function getDecorate(editor) {
|
|
5
|
-
return function (nodeEntry) {
|
|
6
|
-
var ranges = [];
|
|
7
|
-
var _nodeEntry = _slicedToArray(nodeEntry, 2),
|
|
8
|
-
node = _nodeEntry[0],
|
|
9
|
-
path = _nodeEntry[1];
|
|
10
|
-
var cursors = Object.values(editor.cursors || {});
|
|
11
|
-
if (Text.isText(node) && (cursors === null || cursors === void 0 ? void 0 : cursors.length)) {
|
|
12
|
-
cursors.forEach(function (cursor) {
|
|
13
|
-
if (Range.includes(cursor, path)) {
|
|
14
|
-
var focus = cursor.focus,
|
|
15
|
-
anchor = cursor.anchor,
|
|
16
|
-
isForward = cursor.isForward;
|
|
17
|
-
var isFocusNode = Path.equals(focus.path, path);
|
|
18
|
-
var isAnchorNode = Path.equals(anchor.path, path);
|
|
19
|
-
ranges.push(_objectSpread(_objectSpread({}, cursor), {}, {
|
|
20
|
-
isCaret: isFocusNode,
|
|
21
|
-
anchor: {
|
|
22
|
-
path: path,
|
|
23
|
-
offset: isAnchorNode ? anchor.offset : isForward ? 0 : node.text.length
|
|
24
|
-
},
|
|
25
|
-
focus: {
|
|
26
|
-
path: path,
|
|
27
|
-
offset: isFocusNode ? focus.offset : isForward ? node.text.length : 0
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return ranges;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { Range } from '@seafile/slate';
|
|
3
|
-
import randomColor from 'randomcolor';
|
|
4
|
-
|
|
5
|
-
// selection: { anchor, focus }
|
|
6
|
-
// cursor: { anchor, focus }
|
|
7
|
-
|
|
8
|
-
export var setCursor = function setCursor(id, editor, operations, cursorData) {
|
|
9
|
-
var cursorOps = operations.filter(function (operation) {
|
|
10
|
-
return operation.type === 'set_selection';
|
|
11
|
-
});
|
|
12
|
-
if (!editor.cursors) editor.cursors = {};
|
|
13
|
-
var oldCursor = editor.cursors[id] ? editor.cursors[id] : {};
|
|
14
|
-
var lastCursorOp = cursorOps[cursorOps.length - 1];
|
|
15
|
-
var selection = editor.selection;
|
|
16
|
-
if (selection) {
|
|
17
|
-
var newCursor = lastCursorOp && lastCursorOp.newProperties || {};
|
|
18
|
-
var newCursorData = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldCursor), newCursor), selection), _objectSpread(_objectSpread({}, cursorData), {}, {
|
|
19
|
-
isForward: Range.isForward(selection)
|
|
20
|
-
}));
|
|
21
|
-
editor.cursors[id] = newCursorData;
|
|
22
|
-
} else {
|
|
23
|
-
delete editor.cursors[id];
|
|
24
|
-
}
|
|
25
|
-
return editor;
|
|
26
|
-
};
|
|
27
|
-
export var generateCursorData = function generateCursorData(config) {
|
|
28
|
-
var user = config.user;
|
|
29
|
-
var options = {
|
|
30
|
-
luminosity: 'dark',
|
|
31
|
-
format: 'rgba',
|
|
32
|
-
alpha: 1
|
|
33
|
-
};
|
|
34
|
-
var color = randomColor(options);
|
|
35
|
-
return {
|
|
36
|
-
name: user.name,
|
|
37
|
-
color: color,
|
|
38
|
-
alphaColor: color.slice(0, -2) + '0.2)'
|
|
39
|
-
};
|
|
40
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
var cursorStyleBase = {
|
|
4
|
-
position: 'absolute',
|
|
5
|
-
top: -2,
|
|
6
|
-
pointerEvents: 'none',
|
|
7
|
-
userSelect: 'none',
|
|
8
|
-
transform: 'translateY(-100%)',
|
|
9
|
-
fontSize: 10,
|
|
10
|
-
color: 'white',
|
|
11
|
-
background: 'palevioletred',
|
|
12
|
-
whiteSpace: 'nowrap'
|
|
13
|
-
};
|
|
14
|
-
var caretStyleBase = {
|
|
15
|
-
position: 'absolute',
|
|
16
|
-
pointerEvents: 'none',
|
|
17
|
-
userSelect: 'none',
|
|
18
|
-
height: '1.2em',
|
|
19
|
-
width: 2,
|
|
20
|
-
background: 'palevioletred'
|
|
21
|
-
};
|
|
22
|
-
var Caret = function Caret(_ref) {
|
|
23
|
-
var color = _ref.color,
|
|
24
|
-
isForward = _ref.isForward,
|
|
25
|
-
name = _ref.name;
|
|
26
|
-
var cursorStyles = _objectSpread(_objectSpread({}, cursorStyleBase), {}, {
|
|
27
|
-
background: color,
|
|
28
|
-
left: isForward ? '100%' : '0%'
|
|
29
|
-
});
|
|
30
|
-
var caretStyles = _objectSpread(_objectSpread({}, caretStyleBase), {}, {
|
|
31
|
-
background: color,
|
|
32
|
-
left: isForward ? '100%' : '0%'
|
|
33
|
-
});
|
|
34
|
-
caretStyles[isForward ? 'bottom' : 'top'] = 0;
|
|
35
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
36
|
-
contentEditable: false,
|
|
37
|
-
style: caretStyles
|
|
38
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
39
|
-
style: {
|
|
40
|
-
position: 'relative'
|
|
41
|
-
}
|
|
42
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
43
|
-
contentEditable: false,
|
|
44
|
-
style: cursorStyles
|
|
45
|
-
}, name))));
|
|
46
|
-
};
|
|
47
|
-
export default Caret;
|