tycho-components 0.18.9 → 0.18.10

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.
@@ -28,6 +28,7 @@ declare const ToolsUtils: {
28
28
  redirectPage: ({ corpus, uid, hasParameter, tool, ctxPath, sameWindow, }: RedirectPageParams) => void;
29
29
  getIcon: (defaultTool?: PlatformTools) => string;
30
30
  openDocument: ({ page, corpus, hasParameter, defaultTool, ctxPath, }: OpenDocumentParams) => void;
31
+ getDocumentUrl: ({ page, corpus, hasParameter, defaultTool, ctxPath, }: OpenDocumentParams) => string | undefined;
31
32
  getTitle: (defaultTool?: PlatformTools) => string;
32
33
  };
33
34
  export default ToolsUtils;
@@ -67,6 +67,26 @@ const openEdictor = (uid, ctxPath, sameWindow) => {
67
67
  const openDesign = (uid, ctxPath, sameWindow) => {
68
68
  navigateTo(`/editor/box/${uid}`, ctxPath, sameWindow);
69
69
  };
70
+ const getDocumentUrl = ({ page, corpus, hasParameter, defaultTool, ctxPath, }) => {
71
+ if (!corpus)
72
+ return undefined;
73
+ if (defaultTool) {
74
+ return withCtxPath(`${EDITION_TOOLS.find((t) => t.name === defaultTool)?.path}/${page}`, ctxPath);
75
+ }
76
+ if (hasParameter(corpus, 'useEdictor')) {
77
+ return withCtxPath(`/editor/${page}`, ctxPath);
78
+ }
79
+ else if (hasParameter(corpus, 'useTranslations')) {
80
+ return withCtxPath(`/translation/${page}`, ctxPath);
81
+ }
82
+ else if (hasParameter(corpus, 'useDesigner')) {
83
+ return withCtxPath(`/editor/box/${page}`, ctxPath);
84
+ }
85
+ else if (hasParameter(corpus, 'useTranscriber')) {
86
+ return withCtxPath(`/transcriber/${page}`, ctxPath);
87
+ }
88
+ return undefined;
89
+ };
70
90
  const redirectPage = ({ corpus, uid, hasParameter, tool, ctxPath, sameWindow, }) => {
71
91
  if (tool) {
72
92
  navigateTo(`${EDITION_TOOLS.find((t) => t.name === tool)?.path}/${uid}`, ctxPath, sameWindow);
@@ -86,20 +106,22 @@ const redirectPage = ({ corpus, uid, hasParameter, tool, ctxPath, sameWindow, })
86
106
  }
87
107
  };
88
108
  const openDocument = ({ page, corpus, hasParameter, defaultTool, ctxPath, }) => {
89
- if (!corpus)
90
- return;
91
- redirectPage({
109
+ const documentUrl = getDocumentUrl({
110
+ page,
92
111
  corpus,
93
- uid: page,
94
112
  hasParameter,
95
- tool: defaultTool,
113
+ defaultTool,
96
114
  ctxPath,
97
115
  });
116
+ if (!documentUrl)
117
+ return;
118
+ window.open(documentUrl);
98
119
  };
99
120
  const ToolsUtils = {
100
121
  redirectPage,
101
122
  getIcon,
102
123
  openDocument,
124
+ getDocumentUrl,
103
125
  getTitle,
104
126
  };
105
127
  export default ToolsUtils;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.18.9",
4
+ "version": "0.18.10",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {