@seafile/sdoc-editor 1.0.191 → 1.0.192

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.
@@ -86,8 +86,13 @@ const SdocFileLink = _ref => {
86
86
  }, [isShowInsertHoverMenu]);
87
87
  const onClickFile = (0, _react.useCallback)(e => {
88
88
  if (readOnly) {
89
- window.open((0, _helpers.getUrl)(element.doc_uuid));
90
- return;
89
+ if (element.type === _elementType.WIKI_LINK) {
90
+ window.open((0, _helpers2.getWikiUrl)(element.wiki_repo_id, element.page_id, readOnly));
91
+ return;
92
+ } else {
93
+ window.open((0, _helpers.getUrl)(element.doc_uuid));
94
+ return;
95
+ }
91
96
  }
92
97
  if (isShowInsertHoverMenu) {
93
98
  e.stopPropagation();
@@ -126,8 +131,8 @@ const SdocFileLink = _ref => {
126
131
  style['backgroundColor'] = style.computed_background_color;
127
132
  }
128
133
  const url = (0, _react.useMemo)(() => {
129
- return element.type === _elementType.WIKI_LINK ? (0, _helpers2.getWikiUrl)(element.wiki_repo_id, element.page_id) : (0, _helpers.getUrl)(element.doc_uuid);
130
- }, [element.doc_uuid, element.page_id, element.type, element.wiki_repo_id]);
134
+ return element.type === _elementType.WIKI_LINK ? (0, _helpers2.getWikiUrl)(element.wiki_repo_id, element.page_id, readOnly) : (0, _helpers.getUrl)(element.doc_uuid);
135
+ }, [element.doc_uuid, element.page_id, element.type, element.wiki_repo_id, readOnly]);
131
136
  return /*#__PURE__*/_react.default.createElement("span", Object.assign({}, attributes, {
132
137
  "data-id": element.id,
133
138
  contentEditable: false,
@@ -64,7 +64,13 @@ const generateWikiFileNode = function (wikiRepoId, pageId) {
64
64
  return wikiPageLinkNode;
65
65
  };
66
66
  exports.generateWikiFileNode = generateWikiFileNode;
67
- const getWikiUrl = (wikiRepoId, pageId) => {
67
+ const getWikiUrl = (wikiRepoId, pageId, readOnly) => {
68
+ if (readOnly) {
69
+ const siteRoot = _context.default.getSetting('siteRoot');
70
+ const publishUrl = _context.default.getSetting('publishUrl');
71
+ const DEFAULT_URL = 'wiki/publish';
72
+ return `${siteRoot}${DEFAULT_URL}/${publishUrl}/${pageId}/`;
73
+ }
68
74
  const siteRoot = _context.default.getSetting('siteRoot');
69
75
  return `${siteRoot}wikis/${wikiRepoId}/${pageId}/`;
70
76
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.191",
3
+ "version": "1.0.192",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",