cabloy 5.1.144 → 5.1.145

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 (28) hide show
  1. package/.cabloy-version +1 -1
  2. package/.github/workflows/playwright-e2e.yml +2 -2
  3. package/CHANGELOG.md +14 -0
  4. package/cabloy-docs/backend/markdown-guide.md +3 -2
  5. package/cabloy-docs/frontend/markdown-guide.md +1 -1
  6. package/e2e/specs/a-commerce.spec.ts +0 -496
  7. package/e2e/specs/markdown.spec.ts +575 -0
  8. package/package.json +3 -3
  9. package/vona/pnpm-lock.yaml +25 -0
  10. package/vona/src/suite-vendor/a-cabloy/modules/a-markdown/package.json +2 -1
  11. package/vona/src/suite-vendor/a-cabloy/modules/a-markdown/src/bean/bean.markdown.ts +47 -2
  12. package/vona/src/suite-vendor/a-cabloy/package.json +2 -2
  13. package/zova/packages-utils/zova-jsx/package.json +2 -2
  14. package/zova/packages-zova/zova/package.json +3 -3
  15. package/zova/packages-zova/zova-core/package.json +1 -1
  16. package/zova/packages-zova/zova-core/src/core/component/locale.ts +2 -0
  17. package/zova/src/suite/a-home/modules/home-base/src/.metadata/index.ts +2 -17
  18. package/zova/src/suite/a-home/modules/home-base/src/service/routerGuards.ts +0 -6
  19. package/zova/src/suite/a-home/modules/home-layoutadmin/src/component/layoutAdmin/controller.tsx +1 -4
  20. package/zova/src/suite/a-home/modules/home-layoutadmin/src/component/layoutAdmin/render.locale.tsx +1 -1
  21. package/zova/src/suite/a-home/modules/home-layoutweb/src/component/layoutWeb/controller.tsx +1 -4
  22. package/zova/src/suite/a-home/modules/home-layoutweb/src/component/layoutWeb/render.locale.tsx +1 -1
  23. package/zova/src/suite-vendor/a-zova/modules/a-ssr/package.json +1 -1
  24. package/zova/src/suite-vendor/a-zova/modules/a-ssr/src/monkey.ts +1 -0
  25. package/zova/src/suite-vendor/a-zova/modules/a-zova/package.json +2 -2
  26. package/zova/src/suite-vendor/a-zova/package.json +3 -3
  27. package/zova/src/suite/a-home/modules/home-base/src/service/locale.ts +0 -11
  28. /package/e2e/specs/{account.spec.ts → home-user-account.spec.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vona-module-a-markdown",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "Vona Module"
@@ -40,6 +40,7 @@
40
40
  "@tiptap/markdown": "^3.30.0",
41
41
  "@tiptap/starter-kit": "^3.30.0",
42
42
  "@tiptap/static-renderer": "^3.30.0",
43
+ "lowlight": "^3.3.0",
43
44
  "sanitize-html": "^2.17.6"
44
45
  },
45
46
  "devDependencies": {
@@ -7,11 +7,14 @@ import { TableKit } from '@tiptap/extension-table';
7
7
  import Youtube from '@tiptap/extension-youtube';
8
8
  import { Markdown, MarkdownManager } from '@tiptap/markdown';
9
9
  import StarterKit from '@tiptap/starter-kit';
10
- import { renderToHTMLString } from '@tiptap/static-renderer';
10
+ import { escapeHTML, escapeHTMLAttribute, renderToHTMLString } from '@tiptap/static-renderer';
11
+ import { common, createLowlight } from 'lowlight';
11
12
  import sanitizeHtml from 'sanitize-html';
12
13
  import { BeanBase } from 'vona';
13
14
  import { Bean } from 'vona-module-a-bean';
14
15
 
16
+ const lowlight = createLowlight(common);
17
+
15
18
  const extensions: AnyExtension[] = [
16
19
  Markdown,
17
20
  StarterKit,
@@ -32,6 +35,33 @@ const markdownManager = new MarkdownManager({
32
35
  indentation: { style: 'space', size: 2 },
33
36
  });
34
37
 
38
+ function renderHighlightedCode(code: string, language?: string | null): string {
39
+ const highlighted =
40
+ language && lowlight.registered(language)
41
+ ? lowlight.highlight(language, code)
42
+ : lowlight.highlightAuto(code);
43
+ return highlighted.children.map(renderHighlightedNode).join('');
44
+ }
45
+
46
+ interface HighlightedNode {
47
+ children?: HighlightedNode[];
48
+ properties?: { className?: string[] };
49
+ tagName?: string;
50
+ type: string;
51
+ value?: string;
52
+ }
53
+
54
+ function renderHighlightedNode(node: HighlightedNode): string {
55
+ if (node.type === 'text') return escapeHTML(node.value ?? '');
56
+ const children = node.children?.map(renderHighlightedNode).join('') ?? '';
57
+ if (node.tagName !== 'span') return children;
58
+ const classNames = node.properties?.className;
59
+ const classAttribute = classNames?.length
60
+ ? ` class="${classNames.map(escapeHTMLAttribute).join(' ')}"`
61
+ : '';
62
+ return `<span${classAttribute}>${children}</span>`;
63
+ }
64
+
35
65
  const sanitizeOptions: sanitizeHtml.IOptions = {
36
66
  allowedTags: [
37
67
  'a',
@@ -53,6 +83,7 @@ const sanitizeOptions: sanitizeHtml.IOptions = {
53
83
  'input',
54
84
  'label',
55
85
  'li',
86
+ 'mark',
56
87
  'ol',
57
88
  'p',
58
89
  'pre',
@@ -131,7 +162,21 @@ export class BeanMarkdown extends BeanBase {
131
162
  renderHtml(markdown?: string): string {
132
163
  if (!markdown?.trim()) return '';
133
164
  const json = markdownManager.parse(markdown);
134
- const html = renderToHTMLString({ content: json, extensions });
165
+ const html = renderToHTMLString({
166
+ content: json,
167
+ extensions,
168
+ options: {
169
+ nodeMapping: {
170
+ codeBlock: ({ node }) => {
171
+ const language = node.attrs.language;
172
+ const classAttribute = language
173
+ ? ` class="language-${escapeHTMLAttribute(language)}"`
174
+ : '';
175
+ return `<pre><code${classAttribute}>${renderHighlightedCode(node.textContent, language)}</code></pre>`;
176
+ },
177
+ },
178
+ },
179
+ });
135
180
  return sanitizeHtml(html, sanitizeOptions);
136
181
  }
137
182
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vona-suite-a-cabloy",
3
- "version": "5.1.46",
3
+ "version": "5.1.47",
4
4
  "gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
5
5
  "description": "",
6
6
  "author": "",
@@ -8,7 +8,7 @@
8
8
  "type": "module",
9
9
  "dependencies": {
10
10
  "vona-module-a-cabloy": "workspace:^",
11
- "vona-module-a-markdown": "^5.0.2",
11
+ "vona-module-a-markdown": "^5.0.3",
12
12
  "vona-module-a-rbac": "^5.0.1",
13
13
  "vona-module-a-socket": "workspace:^",
14
14
  "vona-module-a-ssr": "workspace:^",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-jsx",
3
- "version": "1.1.87",
3
+ "version": "1.1.88",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "Zova JSX",
6
6
  "keywords": [
@@ -50,7 +50,7 @@
50
50
  "@cabloy/word-utils": "^2.1.14",
51
51
  "typestyle": "^2.4.0",
52
52
  "vue": "^3.5.38",
53
- "zova-core": "^5.1.87"
53
+ "zova-core": "^5.1.88"
54
54
  },
55
55
  "devDependencies": {
56
56
  "clean-package": "^2.2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova",
3
- "version": "5.1.152",
3
+ "version": "5.1.153",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A vue3 framework with ioc",
6
6
  "keywords": [
@@ -45,8 +45,8 @@
45
45
  "postpack": "clean-package restore"
46
46
  },
47
47
  "dependencies": {
48
- "zova-core": "^5.1.87",
49
- "zova-suite-a-zova": "^5.1.151"
48
+ "zova-core": "^5.1.88",
49
+ "zova-suite-a-zova": "^5.1.152"
50
50
  },
51
51
  "devDependencies": {
52
52
  "clean-package": "^2.2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-core",
3
- "version": "5.1.87",
3
+ "version": "5.1.88",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "A vue3 framework with ioc",
6
6
  "keywords": [
@@ -70,6 +70,7 @@ export class AppLocale extends BeanSimple {
70
70
 
71
71
  /** @internal */
72
72
  public createLocaleText(moduleScope?: string): IModuleLocaleText {
73
+ // eslint-disable-next-line
73
74
  const self = this;
74
75
  const getText = function (text: string, ...args: any[]): string {
75
76
  return self.getText(false, moduleScope, undefined, text, ...args);
@@ -86,6 +87,7 @@ export class AppLocale extends BeanSimple {
86
87
 
87
88
  /** @internal */
88
89
  public createScopeLocaleText(moduleScope: string, text: string): IModuleLocale {
90
+ // eslint-disable-next-line
89
91
  const self = this;
90
92
  const getText = function (...args: any[]): string {
91
93
  return self.getText(false, moduleScope, undefined, text, ...args);
@@ -1,6 +1,5 @@
1
1
  // eslint-disable
2
2
  /** service: begin */
3
- export * from '../service/locale.js';
4
3
  export * from '../service/routerGuards.js';
5
4
  export * from '../service/ssr.js';
6
5
  export * from '../service/ssrLayout.js';
@@ -9,8 +8,7 @@ import 'zova-module-a-bean';
9
8
  declare module 'zova-module-a-bean' {
10
9
 
11
10
  export interface IServiceRecord {
12
- 'home-base:locale': never;
13
- 'home-base:routerGuards': never;
11
+ 'home-base:routerGuards': never;
14
12
  'home-base:ssr': never;
15
13
  'home-base:ssrLayout': never;
16
14
  }
@@ -19,17 +17,6 @@ declare module 'zova-module-a-bean' {
19
17
  }
20
18
  declare module 'zova-module-home-base' {
21
19
 
22
- export interface ServiceLocale {
23
- /** @internal */
24
- get scope(): ScopeModuleHomeBase;
25
- }
26
-
27
- export interface ServiceLocale {
28
- get $beanFullName(): 'home-base.service.locale';
29
- get $onionName(): 'home-base:locale';
30
-
31
- }
32
-
33
20
  export interface ServiceRouterGuards {
34
21
  /** @internal */
35
22
  get scope(): ScopeModuleHomeBase;
@@ -65,15 +52,13 @@ declare module 'zova-module-home-base' {
65
52
  }
66
53
  /** service: end */
67
54
  /** service: begin */
68
- import { ServiceLocale } from '../service/locale.js';
69
55
  import { ServiceRouterGuards } from '../service/routerGuards.js';
70
56
  import { ServiceSsr } from '../service/ssr.js';
71
57
  import { ServiceSsrLayout } from '../service/ssrLayout.js';
72
58
  import 'zova';
73
59
  declare module 'zova' {
74
60
  export interface IBeanRecordGeneral {
75
- 'home-base.service.locale': ServiceLocale;
76
- 'home-base.service.routerGuards': ServiceRouterGuards;
61
+ 'home-base.service.routerGuards': ServiceRouterGuards;
77
62
  'home-base.service.ssr': ServiceSsr;
78
63
  'home-base.service.ssrLayout': ServiceSsrLayout;
79
64
  }
@@ -1,17 +1,11 @@
1
1
  import type { BeanRouter } from 'zova-module-a-router';
2
2
 
3
3
  import { catchError } from '@cabloy/utils';
4
- import { Use } from 'zova';
5
4
  import { Service } from 'zova-module-a-bean';
6
5
  import { BeanRouterGuardsBase } from 'zova-module-a-router';
7
6
 
8
- import { ServiceLocale } from './locale.js';
9
-
10
7
  @Service()
11
8
  export class ServiceRouterGuards extends BeanRouterGuardsBase {
12
- @Use()
13
- $$serviceLocale: ServiceLocale;
14
-
15
9
  protected onRouterGuards(router: BeanRouter) {
16
10
  router.beforeEach(async to => {
17
11
  if (to.meta.requiresAuth === false) return;
@@ -3,7 +3,7 @@ import type { ModelTabs, ModelTabsOptions } from 'zova-module-a-routertabs';
3
3
  import { BeanControllerBase, Use, usePrepareArg } from 'zova';
4
4
  import { Controller } from 'zova-module-a-bean';
5
5
  import { $QueryEnsureLoaded } from 'zova-module-a-model';
6
- import { IServiceSsrLayoutOptions, ServiceLocale, ServiceSsrLayout } from 'zova-module-home-base';
6
+ import { IServiceSsrLayoutOptions, ServiceSsrLayout } from 'zova-module-home-base';
7
7
 
8
8
  import { ModelLayout } from '../../model/layout.js';
9
9
  import { ModelMenu } from '../../model/menu.js';
@@ -33,9 +33,6 @@ export class ControllerLayoutAdmin extends BeanControllerBase {
33
33
  } satisfies IServiceSsrLayoutOptions);
34
34
  }
35
35
 
36
- @Use()
37
- $$serviceLocale: ServiceLocale;
38
-
39
36
  leftDrawerOpen: boolean;
40
37
  leftDrawerOpenMobile: boolean = false;
41
38
  belowBreakpoint: boolean;
@@ -19,7 +19,7 @@ export class RenderLocale extends BeanRenderBase {
19
19
  <li key={key} class={this.app.meta.locale.current === key ? 'disabled' : ''}>
20
20
  <a
21
21
  onClick={event => {
22
- this.$$serviceLocale.setLocale(key as any);
22
+ this.app.meta.locale.current = key as any;
23
23
  closeNearestDetails(event);
24
24
  }}
25
25
  >
@@ -2,7 +2,7 @@ import { BeanControllerBase, Use, usePrepareArg } from 'zova';
2
2
  import { Controller } from 'zova-module-a-bean';
3
3
  import { $QueryEnsureLoaded } from 'zova-module-a-model';
4
4
  import { ModelTabs, ModelTabsOptions, RouteTabInitial } from 'zova-module-a-routertabs';
5
- import { IServiceSsrLayoutOptions, ServiceLocale, ServiceSsrLayout } from 'zova-module-home-base';
5
+ import { IServiceSsrLayoutOptions, ServiceSsrLayout } from 'zova-module-home-base';
6
6
 
7
7
  import { ModelLayout } from '../../model/layout.js';
8
8
  import { ModelMenu } from '../../model/menu.js';
@@ -32,9 +32,6 @@ export class ControllerLayoutWeb extends BeanControllerBase {
32
32
  } satisfies IServiceSsrLayoutOptions);
33
33
  }
34
34
 
35
- @Use()
36
- $$serviceLocale: ServiceLocale;
37
-
38
35
  leftDrawerOpen: boolean;
39
36
  leftDrawerOpenMobile: boolean = false;
40
37
  belowBreakpoint: boolean;
@@ -27,7 +27,7 @@ export class RenderLocale extends BeanRenderBase {
27
27
  query: currentRoute.query,
28
28
  });
29
29
  } else {
30
- this.$$serviceLocale.setLocale(key as any);
30
+ this.app.meta.locale.current = key as any;
31
31
  }
32
32
  closeNearestDetails(event);
33
33
  }}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-ssr",
3
- "version": "5.1.37",
3
+ "version": "5.1.38",
4
4
  "gitHead": "09d901d17140a80ee0764211b441cda72fd94663",
5
5
  "description": "",
6
6
  "keywords": [
@@ -77,6 +77,7 @@ export class Monkey
77
77
  }
78
78
 
79
79
  async beanInit(bean: BeanContainer, beanInstance: BeanBase) {
80
+ // eslint-disable-next-line
80
81
  const self = this;
81
82
  // $ssr
82
83
  bean.defineProperty(beanInstance, '$ssr', {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-zova",
3
- "version": "5.1.102",
3
+ "version": "5.1.103",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "zova",
6
6
  "keywords": [
@@ -43,7 +43,7 @@
43
43
  "@cabloy/word-utils": "^2.1.14",
44
44
  "defu": "^6.1.7",
45
45
  "luxon": "^3.7.2",
46
- "zova-jsx": "^1.1.87"
46
+ "zova-jsx": "^1.1.88"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@cabloy/cli": "^3.1.29",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-suite-a-zova",
3
- "version": "5.1.151",
3
+ "version": "5.1.152",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "zova",
6
6
  "license": "MIT",
@@ -26,13 +26,13 @@
26
26
  "zova-module-a-router": "^5.1.34",
27
27
  "zova-module-a-routerstack": "^5.1.27",
28
28
  "zova-module-a-routertabs": "^5.1.34",
29
- "zova-module-a-ssr": "^5.1.37",
29
+ "zova-module-a-ssr": "^5.1.38",
30
30
  "zova-module-a-ssrhmr": "^5.1.23",
31
31
  "zova-module-a-ssrserver": "^5.1.26",
32
32
  "zova-module-a-style": "^5.1.35",
33
33
  "zova-module-a-table": "^5.1.38",
34
34
  "zova-module-a-zod": "^5.1.37",
35
- "zova-module-a-zova": "^5.1.102"
35
+ "zova-module-a-zova": "^5.1.103"
36
36
  },
37
37
  "title": "a-zova"
38
38
  }
@@ -1,11 +0,0 @@
1
- import { BeanBase, ILocaleRecord } from 'zova';
2
- import { Service } from 'zova-module-a-bean';
3
-
4
- @Service()
5
- export class ServiceLocale extends BeanBase {
6
- protected async __init__() {}
7
-
8
- public setLocale(locale: keyof ILocaleRecord) {
9
- this.app.meta.locale.current = locale;
10
- }
11
- }