@seafile/sdoc-editor 3.0.121 → 3.0.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.
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useCursorPosition = exports.updateElementsAttrs = exports.updateCommentedElementsAttrs = exports.getSelectionRange = exports.getSelectedElemIds = exports.getPrimaryElementId = exports.getElementCommentCountTop = exports.getDomById = exports.getCursorPosition = exports.getCommentedTextsByElementId = exports.getAvatarUrl = exports.commentContainerWikiTransfer = void 0;
7
+ exports.useCursorPosition = exports.updateElementsAttrs = exports.updateCommentedElementsAttrs = exports.getWikiHeaderHeight = exports.getSelectionRange = exports.getSelectedElemIds = exports.getPrimaryElementId = exports.getElementCommentCountTop = exports.getDomById = exports.getCursorPosition = exports.getCommentedTextsByElementId = exports.getAvatarUrl = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
10
10
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
@@ -57,23 +57,13 @@ var getAvatarUrl = exports.getAvatarUrl = function getAvatarUrl() {
57
57
  var avatarUrl = "".concat(server, "/media/avatars/default.png");
58
58
  return avatarUrl;
59
59
  };
60
- var commentContainerWikiTransfer = exports.commentContainerWikiTransfer = function commentContainerWikiTransfer(result, value) {
61
- var newResult;
62
- var isWikiTitleIcon = document.querySelector('.wiki-page-icon-wrapper');
63
- var isWikiTitleCover = document.getElementById('wiki-page-cover');
64
- if (isWikiTitleIcon && !isWikiTitleCover) {
65
- // 90 is icon height in wiki
66
- newResult = result - value - 90;
67
- } else if (!isWikiTitleIcon && isWikiTitleCover) {
68
- // 203 is icon height in wiki
69
- newResult = result - value - 203;
70
- } else if (isWikiTitleIcon && isWikiTitleCover) {
71
- // 205 is icon and cover height in wiki
72
- newResult = result - value - 205;
73
- } else {
74
- newResult = result - value;
75
- }
76
- return newResult;
60
+ var getWikiHeaderHeight = exports.getWikiHeaderHeight = function getWikiHeaderHeight() {
61
+ var pageCover = window.document.getElementById('wiki-page-cover');
62
+ var pageCoverHeight = (pageCover === null || pageCover === void 0 ? void 0 : pageCover.offsetHeight) || 0;
63
+ var pageTitle = window.document.getElementById('wiki-page-title');
64
+ var pageTitleHeight = (pageTitle === null || pageTitle === void 0 ? void 0 : pageTitle.offsetHeight) || 0;
65
+ var topNavHeight = 44;
66
+ return pageCoverHeight + pageTitleHeight + topNavHeight;
77
67
  };
78
68
  var getElementCommentCountTop = exports.getElementCommentCountTop = function getElementCommentCountTop(editor, element, scrollTop) {
79
69
  var minY;
@@ -94,7 +84,8 @@ var getElementCommentCountTop = exports.getElementCommentCountTop = function get
94
84
  resultY = minY - 100 + scrollTop; // 100: header height(56) + toolbar height(37)
95
85
  if (editor.editorType === _constants.WIKI_EDITOR) {
96
86
  // 55 is basic top title height in wiki
97
- resultY = commentContainerWikiTransfer(resultY, 55);
87
+ var headerHight = getWikiHeaderHeight();
88
+ resultY = minY - headerHight + scrollTop;
98
89
  }
99
90
  return resultY;
100
91
  };
@@ -58,8 +58,8 @@ var useCommentListPosition = exports.useCommentListPosition = function useCommen
58
58
  var topPara;
59
59
  topPara = rect.bottom - headerHeight + 10 + scrollTop;
60
60
  if (editor.editorType === _constants.WIKI_EDITOR) {
61
- // 55 is basic top title height in wiki
62
- topPara = (0, _helper.commentContainerWikiTransfer)(topPara, 55);
61
+ var wikiHeaderHight = (0, _helper.getWikiHeaderHeight)();
62
+ topPara = rect.bottom - wikiHeaderHight + 10 + scrollTop;
63
63
  }
64
64
  var rightPara = editorArticleRight - rect.left - 300; // 300 is comment container's width
65
65
  return {
@@ -73,8 +73,8 @@ var useCommentListPosition = exports.useCommentListPosition = function useCommen
73
73
  if (selectionPosition && selectionPosition.y !== 0) {
74
74
  selectionPosition.y = selectionPosition.y - headerHeight + scrollTop;
75
75
  if (editor.editorType === _constants.WIKI_EDITOR) {
76
- // 47 is top nav bar height in wiki
77
- selectionPosition.y = (0, _helper.commentContainerWikiTransfer)(selectionPosition.y, 47);
76
+ var _wikiHeaderHight = (0, _helper.getWikiHeaderHeight)();
77
+ selectionPosition.y = selectionPosition.y - _wikiHeaderHight + scrollTop;
78
78
  }
79
79
  }
80
80
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "3.0.121",
3
+ "version": "3.0.122",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "86fe08615af2e429b778e9075e7331b4dad5f77f"
75
+ "gitHead": "8f442dff1b427f5f867707b43cc9c50917d34b6a"
76
76
  }