@seafile/sdoc-editor 0.1.158 → 0.1.159-beta9

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.
@@ -1,3 +1,4 @@
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
1
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
3
  import React, { useEffect, useMemo, useState, forwardRef, useImperativeHandle } from 'react';
3
4
  import { Editor } from '@seafile/slate';
@@ -11,6 +12,8 @@ import context from '../context';
11
12
  import { EditorContainer, EditorContent } from './layout';
12
13
  import SlateEditor from './slate-editor';
13
14
  import InsertElementDialog from './extension/commons/insert-element-dialog';
15
+ import { REVISION_FIRST_LOAD_KEY } from '../constants';
16
+ import toaster from '../components/toast';
14
17
  var SDocEditor = forwardRef(function (_ref, ref) {
15
18
  var document = _ref.document,
16
19
  config = _ref.config;
@@ -85,6 +88,30 @@ var SDocEditor = forwardRef(function (_ref, ref) {
85
88
  var originFilename = context.getSetting('originFilename');
86
89
  if (isSdocRevision) {
87
90
  window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
91
+ var searchParams = window.location.search || window.location.hash;
92
+ if (searchParams) {
93
+ var searchParamsIndex = searchParams.indexOf('?');
94
+ var validSearchParams = new URLSearchParams(searchParams.slice(searchParamsIndex + 1));
95
+ var _iterator = _createForOfIteratorHelper(validSearchParams),
96
+ _step;
97
+ try {
98
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
99
+ var query = _step.value;
100
+ var key = query[0];
101
+ var value = query[1];
102
+ if (key === REVISION_FIRST_LOAD_KEY && value === '1') {
103
+ var revisionId = context.getSetting('revisionId');
104
+ toaster.success(t('Revision_created', {
105
+ id: revisionId
106
+ }));
107
+ }
108
+ }
109
+ } catch (err) {
110
+ _iterator.e(err);
111
+ } finally {
112
+ _iterator.f();
113
+ }
114
+ }
88
115
  }
89
116
 
90
117
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -132,9 +132,7 @@ export var loadFont = function loadFont() {
132
132
  fontLink.className = GOOGLE_FONT_CLASS;
133
133
  document.body.appendChild(fontLink);
134
134
  };
135
- export var generatorFontFamily = function generatorFontFamily(fontName, fontWeight, leaf) {
136
- var isCodeBlock = leaf && Object.keys(leaf).includes('token');
137
- if (isCodeBlock) return '';
135
+ export var generatorFontFamily = function generatorFontFamily(fontName, fontWeight) {
138
136
  var lang = context.getSetting('lang') || 'zh-cn';
139
137
  if (fontName === DEFAULT_FONT) {
140
138
  return "'Arial', ".concat(lang === 'zh-cn' ? "\u5B8B\u4F53" : 'Arial', ", 'sans-serif'");
@@ -32,9 +32,10 @@ var renderText = function renderText(props, editor) {
32
32
  style['fontSize'] = "".concat(fontSize, "pt");
33
33
  }
34
34
  }
35
- var font = leaf[TEXT_STYLE_MAP.FONT] || DEFAULT_FONT;
36
- var fontWeight = leaf[TEXT_STYLE_MAP.BOLD] ? 600 : 400;
37
- style['fontFamily'] = generatorFontFamily(font, fontWeight, leaf);
35
+ if (leaf[TEXT_STYLE_MAP.FONT]) {
36
+ var fontWeight = leaf[TEXT_STYLE_MAP.BOLD] ? 600 : 400;
37
+ style['fontFamily'] = generatorFontFamily(leaf[TEXT_STYLE_MAP.FONT], fontWeight);
38
+ }
38
39
  if (leaf[TEXT_STYLE_MAP.BOLD]) {
39
40
  markedChildren = /*#__PURE__*/React.createElement("strong", null, markedChildren);
40
41
  }
@@ -4,6 +4,7 @@ import { withTranslation } from 'react-i18next';
4
4
  import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
5
5
  import context from '../../../../context';
6
6
  import toaster from '../../../toast';
7
+ import { REVISION_FIRST_LOAD_KEY } from '../../../../constants';
7
8
  import './index.css';
8
9
  var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
9
10
  var t = _ref.t;
@@ -18,7 +19,7 @@ var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
18
19
  }, []);
19
20
  var startRevise = useCallback(function () {
20
21
  context.startRevise().then(function (res) {
21
- window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/");
22
+ window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/?").concat(REVISION_FIRST_LOAD_KEY, "=1");
22
23
  }).catch(function (error) {
23
24
  toaster.danger(t('Error'));
24
25
  });
@@ -1,3 +1,4 @@
1
+ export var REVISION_FIRST_LOAD_KEY = 'first-load';
1
2
  export var EXTERNAL_EVENT = {
2
3
  INTERNAL_LINK_CLICK: 'internal_link_click',
3
4
  TOGGLE_STAR: 'toggle_star',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.158",
3
+ "version": "0.1.159beta9",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -364,5 +364,6 @@
364
364
  "Title": "Title",
365
365
  "Subtitle": "Subtitle",
366
366
  "Link_sdoc": "Link sdoc",
367
- "Link_file": "Link file"
367
+ "Link_file": "Link file",
368
+ "Revision_created": "Revision {{id}} created"
368
369
  }