@nocobase/client-v2 2.2.0-alpha.4 → 2.2.0-alpha.5

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 (52) hide show
  1. package/es/BaseApplication.d.ts +2 -0
  2. package/es/RouterManager.d.ts +15 -0
  3. package/es/entry-actions/EntryActionManager.d.ts +24 -0
  4. package/es/entry-actions/index.d.ts +9 -0
  5. package/es/flow/admin-shell/BaseLayoutModel.d.ts +6 -0
  6. package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +7 -0
  7. package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +2 -1
  8. package/es/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.d.ts +24 -0
  9. package/es/flow/admin-shell/admin-layout/index.d.ts +1 -0
  10. package/es/flow/admin-shell/admin-layout/useApplications.d.ts +7 -2
  11. package/es/flow/models/base/ActionModelCore.d.ts +2 -0
  12. package/es/flow/routeTransientInputArgs.d.ts +14 -0
  13. package/es/index.d.ts +4 -0
  14. package/es/index.mjs +178 -124
  15. package/es/utils/markdownSanitize.d.ts +11 -0
  16. package/lib/index.js +164 -110
  17. package/package.json +7 -7
  18. package/src/BaseApplication.tsx +2 -0
  19. package/src/RouterManager.tsx +142 -1
  20. package/src/__tests__/RouterManager.test.ts +125 -0
  21. package/src/entry-actions/EntryActionManager.ts +76 -0
  22. package/src/entry-actions/index.ts +10 -0
  23. package/src/flow/FlowPage.tsx +29 -2
  24. package/src/flow/__tests__/FlowPage.test.tsx +152 -25
  25. package/src/flow/__tests__/FlowRoute.test.tsx +547 -2
  26. package/src/flow/actions/__tests__/dataScopeFilter.test.ts +62 -0
  27. package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +80 -20
  28. package/src/flow/actions/dataScopeFilter.ts +10 -1
  29. package/src/flow/actions/openView.tsx +21 -1
  30. package/src/flow/admin-shell/BaseLayoutModel.tsx +111 -0
  31. package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +184 -42
  32. package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +1016 -119
  33. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +41 -4
  34. package/src/flow/admin-shell/admin-layout/AppListRender.tsx +13 -2
  35. package/src/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.tsx +289 -0
  36. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +359 -2
  37. package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +48 -0
  38. package/src/flow/admin-shell/admin-layout/index.ts +1 -0
  39. package/src/flow/admin-shell/admin-layout/useApplications.tsx +81 -12
  40. package/src/flow/common/Markdown/Display.tsx +14 -3
  41. package/src/flow/common/Markdown/Edit.tsx +19 -7
  42. package/src/flow/components/FlowRoute.tsx +128 -16
  43. package/src/flow/internal/components/Markdown/util.ts +2 -1
  44. package/src/flow/models/base/ActionModel.tsx +10 -8
  45. package/src/flow/models/base/ActionModelCore.tsx +5 -0
  46. package/src/flow/models/fields/TextareaFieldModel.tsx +42 -19
  47. package/src/flow/models/fields/__tests__/TextareaFieldModel.test.tsx +32 -1
  48. package/src/flow/models/topbar/TopbarActionModel.tsx +78 -3
  49. package/src/flow/routeTransientInputArgs.ts +27 -0
  50. package/src/index.ts +4 -0
  51. package/src/nocobase-buildin-plugin/index.tsx +7 -1
  52. package/src/utils/markdownSanitize.ts +88 -0
package/src/index.ts CHANGED
@@ -40,7 +40,10 @@ export * from './collection-manager/filter-operators';
40
40
  export * from './collection-manager/interfaces';
41
41
  export * from './collection-manager/template-fields';
42
42
  export * from './data-source';
43
+ export * from './entry-actions';
43
44
  export * from './flow';
45
+ export { CodeEditorExtension } from './flow/components/code-editor/extension';
46
+ export type { CodeEditorExtra, CodeEditorExtraRegistry, EditorRef } from './flow/components/code-editor/types';
44
47
  export {
45
48
  DEFAULT_DATA_SOURCE_KEY,
46
49
  IconPicker,
@@ -49,4 +52,5 @@ export {
49
52
  NocoBaseDesktopRouteType,
50
53
  } from './flow-compat';
51
54
  export type { NocoBaseDesktopRoute } from './flow-compat';
55
+ export * from './utils/markdownSanitize';
52
56
  export { default as AntdAppProvider } from './theme/AntdAppProvider';
@@ -15,7 +15,12 @@ import type { Application } from '../Application';
15
15
  import { getCurrentV2RedirectPath, getDefaultV2AdminRedirectPath } from '../authRedirect';
16
16
  import { AppNotFound } from '../components';
17
17
  import { PluginFlowEngine } from '../flow';
18
- import { ADMIN_LAYOUT_MODEL_UID, AdminLayoutMenuItemModel, AdminLayoutModel } from '../flow/admin-shell/admin-layout';
18
+ import {
19
+ ADMIN_LAYOUT_MODEL_UID,
20
+ AdminLayoutMenuItemModel,
21
+ AdminLayoutModel,
22
+ AppSwitcherActionPanelModel,
23
+ } from '../flow/admin-shell/admin-layout';
19
24
  import { useApp } from '../hooks/useApp';
20
25
  import { Plugin } from '../Plugin';
21
26
  import { AdminSettingsLayoutModel } from '../settings-center';
@@ -326,6 +331,7 @@ export class NocoBaseBuildInPlugin extends Plugin<any, Application> {
326
331
  this.app.flowEngine.registerModels({
327
332
  AdminLayoutModel,
328
333
  AdminLayoutMenuItemModel,
334
+ AppSwitcherActionPanelModel,
329
335
  AdminSettingsLayoutModel,
330
336
  });
331
337
  this.app.layoutManager.registerLayout({
@@ -0,0 +1,88 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ export function stripMarkdownIframeTags(markdown: string) {
11
+ if (!markdown) {
12
+ return markdown;
13
+ }
14
+
15
+ let result = '';
16
+ let cursor = 0;
17
+
18
+ while (cursor < markdown.length) {
19
+ const iframeStart = markdown.slice(cursor).search(/<iframe\b/i);
20
+ if (iframeStart === -1) {
21
+ result += markdown.slice(cursor);
22
+ break;
23
+ }
24
+
25
+ const start = cursor + iframeStart;
26
+ result += markdown.slice(cursor, start);
27
+
28
+ const openingEnd = findTagEnd(markdown, start);
29
+ if (openingEnd === -1) {
30
+ break;
31
+ }
32
+
33
+ const openingTag = markdown.slice(start, openingEnd + 1);
34
+ if (/\/\s*>$/.test(openingTag)) {
35
+ cursor = openingEnd + 1;
36
+ continue;
37
+ }
38
+
39
+ const closingStart = markdown.slice(openingEnd + 1).search(/<\/iframe\s*>/i);
40
+ if (closingStart === -1) {
41
+ break;
42
+ }
43
+
44
+ cursor =
45
+ openingEnd + 1 + closingStart + markdown.slice(openingEnd + 1 + closingStart).match(/^<\/iframe\s*>/i)[0].length;
46
+ }
47
+
48
+ return result;
49
+ }
50
+
51
+ export function stripMarkdownIframes(html: string) {
52
+ if (!html || typeof DOMParser === 'undefined') {
53
+ return html;
54
+ }
55
+
56
+ const doc = new DOMParser().parseFromString(html, 'text/html');
57
+ doc.querySelectorAll('iframe').forEach((iframe) => iframe.remove());
58
+ return doc.body.innerHTML;
59
+ }
60
+
61
+ export function removeMarkdownIframes(container?: ParentNode | null) {
62
+ container?.querySelectorAll('iframe').forEach((iframe) => iframe.remove());
63
+ }
64
+
65
+ function findTagEnd(html: string, start: number) {
66
+ let quote: string | undefined;
67
+
68
+ for (let index = start; index < html.length; index += 1) {
69
+ const char = html[index];
70
+ if (quote) {
71
+ if (char === quote) {
72
+ quote = undefined;
73
+ }
74
+ continue;
75
+ }
76
+
77
+ if (char === '"' || char === "'") {
78
+ quote = char;
79
+ continue;
80
+ }
81
+
82
+ if (char === '>') {
83
+ return index;
84
+ }
85
+ }
86
+
87
+ return -1;
88
+ }