@seafile/sdoc-editor 0.1.134 → 0.1.136

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.
Files changed (31) hide show
  1. package/dist/basic-sdk/assets/css/default.css +6 -4
  2. package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +20 -2
  3. package/dist/basic-sdk/extension/constants/element-type.js +2 -0
  4. package/dist/basic-sdk/extension/constants/font.js +4 -77
  5. package/dist/basic-sdk/extension/constants/index.js +5 -6
  6. package/dist/basic-sdk/extension/constants/keyboard.js +34 -2
  7. package/dist/basic-sdk/extension/plugins/code-block/plugin.js +1 -2
  8. package/dist/basic-sdk/extension/plugins/font/helpers.js +11 -13
  9. package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +3 -16
  10. package/dist/basic-sdk/extension/plugins/header/helpers.js +8 -2
  11. package/dist/basic-sdk/extension/plugins/header/index.js +2 -2
  12. package/dist/basic-sdk/extension/plugins/header/menu/index.js +12 -13
  13. package/dist/basic-sdk/extension/plugins/header/menu/style.css +4 -25
  14. package/dist/basic-sdk/extension/plugins/header/plugin.js +29 -9
  15. package/dist/basic-sdk/extension/plugins/header/render-elem.js +44 -8
  16. package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +1 -1
  17. package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +0 -12
  18. package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +3 -20
  19. package/dist/basic-sdk/extension/render/render-element.js +16 -3
  20. package/dist/basic-sdk/outline/index.js +1 -1
  21. package/dist/basic-sdk/outline/outline-item.js +7 -1
  22. package/dist/basic-sdk/utils/event-handler.js +5 -11
  23. package/package.json +1 -1
  24. package/public/locales/cs/sdoc-editor.json +3 -1
  25. package/public/locales/de/sdoc-editor.json +3 -1
  26. package/public/locales/en/sdoc-editor.json +3 -1
  27. package/public/locales/es/sdoc-editor.json +3 -1
  28. package/public/locales/fr/sdoc-editor.json +3 -1
  29. package/public/locales/it/sdoc-editor.json +3 -1
  30. package/public/locales/ru/sdoc-editor.json +148 -146
  31. package/public/locales/zh_CN/sdoc-editor.json +3 -1
@@ -2,23 +2,60 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React from 'react';
3
3
  import { Node } from '@seafile/slate';
4
4
  import { Placeholder } from '../../core';
5
- var renderHeader = function renderHeader(props, editor) {
5
+ import { SDOC_FONT_SIZE } from '../../constants';
6
+ export var renderTitle = function renderTitle(props, editor) {
7
+ var element = props.element,
8
+ attributes = props.attributes,
9
+ children = props.children;
10
+ var style = {
11
+ fontSize: "".concat(SDOC_FONT_SIZE[element.type], "pt"),
12
+ textAlign: element.align
13
+ };
14
+ return /*#__PURE__*/React.createElement("div", Object.assign({
15
+ className: "sdoc-header-title",
16
+ "data-id": element.id,
17
+ "data-root": "true"
18
+ }, attributes, {
19
+ style: _objectSpread({}, style)
20
+ }), children);
21
+ };
22
+ export var renderSubtitle = function renderSubtitle(props, editor) {
23
+ var element = props.element,
24
+ attributes = props.attributes,
25
+ children = props.children;
26
+ var style = {
27
+ color: '#888',
28
+ fontSize: "".concat(SDOC_FONT_SIZE[element.type], "pt"),
29
+ textAlign: element.align
30
+ };
31
+ return /*#__PURE__*/React.createElement("div", Object.assign({
32
+ className: "sdoc-header-subtitle",
33
+ "data-id": element.id,
34
+ "data-root": "true"
35
+ }, attributes, {
36
+ style: _objectSpread({}, style)
37
+ }), children);
38
+ };
39
+ export var renderHeader = function renderHeader(props, editor) {
6
40
  var element = props.element,
7
41
  attributes = props.attributes,
8
42
  children = props.children,
9
43
  isComposing = props.isComposing;
10
44
  var type = element.type;
11
45
  var level = type.split('header')[1];
12
- var Tag = "h".concat(level);
13
- var style = {
14
- textAlign: element.align
15
- };
46
+ var style = _objectSpread({
47
+ textAlign: element.align,
48
+ fontSize: "".concat(SDOC_FONT_SIZE[element.type], "pt")
49
+ }, level === '6' && {
50
+ fontStyle: 'italic'
51
+ });
16
52
  var isShowPlaceHolder = false;
17
53
  var firstChild = editor.children[0];
18
54
  if (firstChild.id === element.id && Node.string(element) === '' && !isComposing) {
19
55
  isShowPlaceHolder = true;
20
56
  }
21
- return /*#__PURE__*/React.createElement(Tag, Object.assign({
57
+ return /*#__PURE__*/React.createElement("div", Object.assign({
58
+ className: "sdoc-header-".concat(level),
22
59
  "data-id": element.id,
23
60
  "data-root": "true"
24
61
  }, attributes, {
@@ -28,5 +65,4 @@ var renderHeader = function renderHeader(props, editor) {
28
65
  }), isShowPlaceHolder && /*#__PURE__*/React.createElement(Placeholder, {
29
66
  title: 'Please_enter_title'
30
67
  }), children);
31
- };
32
- export default renderHeader;
68
+ };
@@ -30,7 +30,7 @@ var TableMenu = /*#__PURE__*/function (_React$Component) {
30
30
  };
31
31
  _this.createTable = function (size) {
32
32
  var editor = _this.props.editor;
33
- insertTable(editor, size, _this.selection);
33
+ insertTable(editor, size, editor.selection);
34
34
  };
35
35
  return _this;
36
36
  }
@@ -6,12 +6,10 @@ import { TEXT_STYLE, TEXT_STYLE_MORE, MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../
6
6
  import { focusEditor } from '../../../core';
7
7
  import { MenuItem, ColorMenu, MoreDropdown } from '../../../commons';
8
8
  import { getFontSize, setFontSize } from '../../font/helpers';
9
- import context from '../../../../../context';
10
9
  import FontSizeScale from '../../font/menu/font-size/font-size-scale';
11
10
  import { getValue, isMenuDisabled, addMark, removeMark } from '../helpers';
12
11
  import { useColorContext } from '../../../../hooks/use-color-context';
13
12
  import { eventStopPropagation } from '../../../../utils/mouse-event';
14
- import { DEFAULT_COMMON_FONT_SIZE, FONT_SIZE, SPECIAL_FONT_SIZE_NAME } from '../../../constants';
15
13
  var TextStyleMenuList = function TextStyleMenuList(_ref) {
16
14
  var editor = _ref.editor,
17
15
  t = _ref.t,
@@ -21,16 +19,6 @@ var TextStyleMenuList = function TextStyleMenuList(_ref) {
21
19
  readonly = _ref.readonly;
22
20
  var selectedFontSize = getFontSize(editor);
23
21
  var selectedFontSizeValue = selectedFontSize;
24
- var lang = (context.getSetting('lang') || '').toLowerCase();
25
- if (SPECIAL_FONT_SIZE_NAME.includes(selectedFontSize)) {
26
- var fontItem = FONT_SIZE.find(function (item) {
27
- return item.name === selectedFontSize;
28
- });
29
- if (lang !== 'zh-cn') {
30
- selectedFontSize = fontItem ? fontItem.value : DEFAULT_COMMON_FONT_SIZE;
31
- }
32
- selectedFontSizeValue = fontItem ? fontItem.value : DEFAULT_COMMON_FONT_SIZE;
33
- }
34
22
  var _useColorContext = useColorContext(),
35
23
  lastUsedFontColor = _useColorContext.lastUsedFontColor,
36
24
  updateLastUsedFontColor = _useColorContext.updateLastUsedFontColor,
@@ -2,7 +2,7 @@ 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, DEFAULT_FONT } from '../../constants';
5
+ import { DEFAULT_FONT } from '../../constants';
6
6
  import { generatorFontFamily } from '../font/helpers';
7
7
  var renderText = function renderText(props, editor) {
8
8
  var attributes = props.attributes,
@@ -28,25 +28,8 @@ var renderText = function renderText(props, editor) {
28
28
  }
29
29
  if (leaf['font-size']) {
30
30
  var fontSize = leaf['font-size'];
31
- var fontSizeValue = fontSize;
32
- if (SPECIAL_FONT_SIZE_NAME.includes(fontSize)) {
33
- var fontSizeItem = FONT_SIZE.find(function (item) {
34
- return item.name === fontSize;
35
- });
36
- if (fontSizeItem) {
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");
49
- }
31
+ if (typeof fontSize === 'number') {
32
+ style['fontSize'] = "".concat(fontSize, "px");
50
33
  }
51
34
  }
52
35
  var font = leaf['font'] || DEFAULT_FONT;
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import React, { useCallback } from 'react';
3
3
  import { useSlateStatic } from '@seafile/slate-react';
4
- import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, LIST_LIC, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, ELEMENT_TYPE, SDOC_LINK } from '../constants';
4
+ import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, LIST_LIC, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, ELEMENT_TYPE, SDOC_LINK, TITLE, SUBTITLE } from '../constants';
5
5
  import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin } from '../plugins';
6
6
  import EventBus from '../../utils/event-bus';
7
7
  import { INTERNAL_EVENT } from '../../constants';
@@ -22,6 +22,19 @@ var CustomElement = function CustomElement(props) {
22
22
  renderParagraph = _ParagraphPlugin$rend[0];
23
23
  return renderParagraph(props);
24
24
  }
25
+ case TITLE:
26
+ {
27
+ var _HeaderPlugin$renderE = _slicedToArray(HeaderPlugin.renderElements, 1),
28
+ renderTitle = _HeaderPlugin$renderE[0];
29
+ return renderTitle(props, editor);
30
+ }
31
+ case SUBTITLE:
32
+ {
33
+ attributes['onMouseEnter'] = onMouseEnter;
34
+ var _HeaderPlugin$renderE2 = _slicedToArray(HeaderPlugin.renderElements, 2),
35
+ renderSubtitle = _HeaderPlugin$renderE2[1];
36
+ return renderSubtitle(props, editor);
37
+ }
25
38
  case HEADER1:
26
39
  case HEADER2:
27
40
  case HEADER3:
@@ -30,8 +43,8 @@ var CustomElement = function CustomElement(props) {
30
43
  case HEADER6:
31
44
  {
32
45
  attributes['onMouseEnter'] = onMouseEnter;
33
- var _HeaderPlugin$renderE = _slicedToArray(HeaderPlugin.renderElements, 1),
34
- renderHeader = _HeaderPlugin$renderE[0];
46
+ var _HeaderPlugin$renderE3 = _slicedToArray(HeaderPlugin.renderElements, 3),
47
+ renderHeader = _HeaderPlugin$renderE3[2];
35
48
  return renderHeader(props, editor);
36
49
  }
37
50
  case LINK:
@@ -36,7 +36,7 @@ var SDocOutline = function SDocOutline(_ref) {
36
36
  }, [isShown]);
37
37
  var list = useMemo(function () {
38
38
  return doc.filter(function (item) {
39
- return ['header2', 'header3'].includes(item.type);
39
+ return ['header1', 'header2', 'header3'].includes(item.type);
40
40
  });
41
41
  }, [doc]);
42
42
  return /*#__PURE__*/React.createElement("div", {
@@ -2,6 +2,7 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import classNames from 'classnames';
5
6
  import React from 'react';
6
7
  var OutlineItem = /*#__PURE__*/function (_React$PureComponent) {
7
8
  _inherits(OutlineItem, _React$PureComponent);
@@ -37,8 +38,13 @@ var OutlineItem = /*#__PURE__*/function (_React$PureComponent) {
37
38
  var item = this.props.item;
38
39
  var type = item.type,
39
40
  children = item.children;
41
+ var outlineItemClass = classNames('sdoc-outline-item', {
42
+ 'pl-5': type === 'header2',
43
+ 'pl-7': type === 'header3',
44
+ 'active': isHighlighted
45
+ });
40
46
  return /*#__PURE__*/React.createElement("li", {
41
- className: "sdoc-outline-item ".concat(type === 'header3' ? 'pl-5' : '', " ").concat(isHighlighted ? 'active' : ''),
47
+ className: outlineItemClass,
42
48
  onClick: this.onItemClick,
43
49
  onMouseOver: this.onMouseOver,
44
50
  onMouseOut: this.onMouseOut
@@ -1,25 +1,19 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
1
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
3
  import isHotkey from 'is-hotkey';
5
4
  import EventBus from '../utils/event-bus';
6
5
  import { getSelectedNodeByType } from '../extension/core/queries/';
7
- import { ELEMENT_TYPE, PARAGRAPH, HEADERS } from '../extension/constants';
6
+ import { ELEMENT_TYPE } from '../extension/constants';
8
7
  import { INTERNAL_EVENT } from '../constants';
9
8
  var EventProxy = /*#__PURE__*/_createClass(function EventProxy(_editor) {
10
9
  var _this = this;
11
10
  _classCallCheck(this, EventProxy);
12
11
  this.onKeyDown = function (event) {
13
12
  var editor = _this.editor;
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
- });
13
+ if (editor.onHotKeyDown) {
14
+ var isHandled = editor.onHotKeyDown(event);
15
+ if (isHandled) return;
16
+ }
23
17
 
24
18
  // bold
25
19
  if (isHotkey('mod+b', event)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.134",
3
+ "version": "0.1.136",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -360,5 +360,7 @@
360
360
  "Last_modification": "Last modification",
361
361
  "Next_modification": "Next modification",
362
362
  "Changes": "Změny",
363
- "No_changes": "No changes"
363
+ "No_changes": "No changes",
364
+ "Title": "Název",
365
+ "SubTitle": "Subtitle"
364
366
  }
@@ -360,5 +360,7 @@
360
360
  "Last_modification": "Last modification",
361
361
  "Next_modification": "Next modification",
362
362
  "Changes": "Änderungen",
363
- "No_changes": "No changes"
363
+ "No_changes": "No changes",
364
+ "Title": "Titel",
365
+ "SubTitle": "Subtitle"
364
366
  }
@@ -360,5 +360,7 @@
360
360
  "Last_modification": "Last modification",
361
361
  "Next_modification": "Next modification",
362
362
  "Changes": "Changes",
363
- "No_changes": "No changes"
363
+ "No_changes": "No changes",
364
+ "Title": "Title",
365
+ "Subtitle": "Subtitle"
364
366
  }
@@ -360,5 +360,7 @@
360
360
  "Last_modification": "Last modification",
361
361
  "Next_modification": "Next modification",
362
362
  "Changes": "Cambios",
363
- "No_changes": "No changes"
363
+ "No_changes": "No changes",
364
+ "Title": "Título",
365
+ "SubTitle": "Subtitle"
364
366
  }
@@ -360,5 +360,7 @@
360
360
  "Last_modification": "Last modification",
361
361
  "Next_modification": "Next modification",
362
362
  "Changes": "Modifications",
363
- "No_changes": "No changes"
363
+ "No_changes": "No changes",
364
+ "Title": "Titre",
365
+ "SubTitle": "Subtitle"
364
366
  }
@@ -360,5 +360,7 @@
360
360
  "Last_modification": "Last modification",
361
361
  "Next_modification": "Next modification",
362
362
  "Changes": "Modifiche",
363
- "No_changes": "No changes"
363
+ "No_changes": "No changes",
364
+ "Title": "Titolo",
365
+ "SubTitle": "Subtitle"
364
366
  }