Skip to content

Commit bf383cc

Browse files
committed
move some stuff to other files
1 parent 9a5639f commit bf383cc

29 files changed

+170
-167
lines changed

packages/core/src/api/API.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
import { type IPlugin } from 'packages/core/src/IPlugin';
22
import { SyntaxHighlightingAPI } from 'packages/core/src/api/SyntaxHighlightingAPI';
3-
import {
4-
type ButtonGroupOptions,
5-
type ButtonOptions,
6-
type EmbedOptions,
7-
type FieldOptionMap,
8-
FieldType,
9-
type InlineFieldType,
10-
type InputFieldOptions,
11-
isFieldTypeAllowedInline,
12-
type JsViewFieldOptions,
13-
NotePosition,
14-
RenderChildType,
15-
type TableOptions,
16-
type ViewFieldOptions,
17-
} from 'packages/core/src/config/FieldConfigs';
183
import { type FieldMountable } from 'packages/core/src/fields/FieldMountable';
194
import { ButtonActionRunner } from 'packages/core/src/fields/button/ButtonActionRunner';
205
import { ButtonMountable } from 'packages/core/src/fields/button/ButtonMountable';
@@ -64,6 +49,21 @@ import {
6449
import { validate } from 'packages/core/src/utils/ZodUtils';
6550
import { z } from 'zod';
6651
import { TableMountable } from 'packages/core/src/fields/metaBindTable/TableMountable';
52+
import {
53+
type ButtonGroupOptions,
54+
type ButtonOptions,
55+
type EmbedOptions,
56+
type FieldOptionMap,
57+
FieldType,
58+
type InlineFieldType,
59+
type APIConfigs,
60+
isFieldTypeAllowedInline,
61+
type JsViewFieldOptions,
62+
NotePosition,
63+
RenderChildType,
64+
type TableOptions,
65+
type ViewFieldOptions,
66+
} from 'packages/core/src/config/APIConfigs';
6767

6868
export interface LifecycleHook {
6969
register(cb: () => void): void;
@@ -307,7 +307,7 @@ export abstract class API<Plugin extends IPlugin> {
307307
});
308308
}
309309

310-
public createInputFieldMountable(filePath: string, options: InputFieldOptions): InputFieldMountable {
310+
public createInputFieldMountable(filePath: string, options: APIConfigs): InputFieldMountable {
311311
validate(
312312
z.object({
313313
filePath: V_FilePath,

packages/core/src/api/SyntaxHighlightingAPI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
} from 'packages/core/src/parsers/syntaxHighlighting/HLPs';
1111
import { type Highlight } from 'packages/core/src/parsers/syntaxHighlighting/Highlight';
1212
import { SyntaxHighlighting } from 'packages/core/src/parsers/syntaxHighlighting/SyntaxHighlighting';
13-
import { FieldType } from 'packages/core/src/config/FieldConfigs';
13+
14+
import { FieldType } from 'packages/core/src/config/APIConfigs';
1415

1516
export class SyntaxHighlightingAPI {
1617
public readonly plugin: IPlugin;

packages/core/src/api/Validators.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
import { schemaForType } from 'packages/core/src/utils/ZodUtils';
2-
import {
3-
type ButtonGroupOptions,
4-
type ButtonOptions,
5-
type EmbedOptions,
6-
FieldType,
7-
type InputFieldOptions,
8-
InputFieldType,
9-
type JsViewFieldOptions,
10-
NotePosition,
11-
RenderChildType,
12-
type TableOptions,
13-
type ViewFieldOptions,
14-
} from 'packages/core/src/config/FieldConfigs';
2+
import { InputFieldType } from 'packages/core/src/config/FieldConfigs';
153
import { BindTargetScope } from 'packages/core/src/metadata/BindTargetScope';
164
import type { ParsingResultNode } from 'packages/core/src/parsers/nomParsers/GeneralNomParsers';
175
import type {
@@ -44,6 +32,18 @@ import {
4432
} from 'packages/core/src/parsers/nomParsers/FieldArgumentNomParsers';
4533
import { FieldMountable } from 'packages/core/src/fields/FieldMountable';
4634
import { Mountable } from 'packages/core/src/utils/Mountable';
35+
import {
36+
type ButtonGroupOptions,
37+
type ButtonOptions,
38+
type EmbedOptions,
39+
FieldType,
40+
type APIConfigs,
41+
type JsViewFieldOptions,
42+
NotePosition,
43+
RenderChildType,
44+
type TableOptions,
45+
type ViewFieldOptions,
46+
} from 'packages/core/src/config/APIConfigs';
4747

4848
export const V_FilePath = schemaForType<string>()(z.string());
4949

@@ -195,7 +195,7 @@ export const V_SimpleInlineButtonDeclaration = schemaForType<SimpleButtonGroupDe
195195
}),
196196
);
197197

198-
export const V_InputFieldOptions = schemaForType<InputFieldOptions>()(
198+
export const V_InputFieldOptions = schemaForType<APIConfigs>()(
199199
z.object({
200200
renderChildType: V_RenderChildType,
201201
declaration: z.union([z.string(), V_SimpleInputFieldDeclaration]),
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import type { SimpleInputFieldDeclaration } from 'packages/core/src/parsers/inputFieldParser/InputFieldDeclaration';
2+
import type { BindTargetScope } from 'packages/core/src/metadata/BindTargetScope';
3+
import type {
4+
SimpleJsViewFieldDeclaration,
5+
SimpleViewFieldDeclaration,
6+
} from 'packages/core/src/parsers/viewFieldParser/ViewFieldDeclaration';
7+
import type { BindTargetDeclaration } from 'packages/core/src/parsers/bindTargetParser/BindTargetDeclaration';
8+
import type { MetaBindColumnDeclaration } from 'packages/core/src/fields/metaBindTable/TableMountable';
9+
import type { SimpleButtonGroupDeclaration } from 'packages/core/src/parsers/ButtonParser';
10+
import type { ButtonConfig } from 'packages/core/src/config/ButtonConfig';
11+
12+
export enum RenderChildType {
13+
INLINE = 'inline',
14+
BLOCK = 'block',
15+
}
16+
17+
export enum FieldType {
18+
INPUT = 'INPUT',
19+
VIEW = 'VIEW',
20+
JS_VIEW = 'JS_VIEW',
21+
TABLE = 'TABLE',
22+
BUTTON_GROUP = 'BUTTON_GROUP',
23+
BUTTON = 'BUTTON',
24+
EMBED = 'EMBED',
25+
EXCLUDED = 'EXCLUDED',
26+
}
27+
28+
export interface APIConfigs {
29+
renderChildType: RenderChildType;
30+
declaration: SimpleInputFieldDeclaration | string;
31+
scope?: BindTargetScope | undefined;
32+
}
33+
34+
export interface ViewFieldOptions {
35+
renderChildType: RenderChildType;
36+
declaration: SimpleViewFieldDeclaration | string;
37+
scope?: BindTargetScope | undefined;
38+
}
39+
40+
export interface JsViewFieldOptions {
41+
declaration: SimpleJsViewFieldDeclaration | string;
42+
}
43+
44+
export interface TableOptions {
45+
bindTarget: BindTargetDeclaration;
46+
tableHead: string[];
47+
columns: MetaBindColumnDeclaration[];
48+
}
49+
50+
export interface ButtonGroupOptions {
51+
renderChildType: RenderChildType;
52+
declaration: SimpleButtonGroupDeclaration | string;
53+
position?: NotePosition | undefined;
54+
}
55+
56+
export interface ButtonOptions {
57+
declaration: ButtonConfig | string;
58+
position?: NotePosition | undefined;
59+
isPreview: boolean;
60+
}
61+
62+
export class NotePosition {
63+
linePosition: LinePosition | undefined;
64+
65+
constructor(linePosition: LinePosition | undefined) {
66+
this.linePosition = linePosition;
67+
}
68+
69+
getPosition(): LinePosition | undefined {
70+
return this.linePosition;
71+
}
72+
}
73+
74+
export interface LinePosition {
75+
lineStart: number;
76+
lineEnd: number;
77+
}
78+
79+
export interface EmbedOptions {
80+
depth: number;
81+
content: string;
82+
}
83+
84+
export interface FieldOptionMap {
85+
[FieldType.INPUT]: APIConfigs;
86+
[FieldType.VIEW]: ViewFieldOptions;
87+
[FieldType.JS_VIEW]: JsViewFieldOptions;
88+
[FieldType.TABLE]: TableOptions;
89+
[FieldType.BUTTON_GROUP]: ButtonGroupOptions;
90+
[FieldType.BUTTON]: ButtonOptions;
91+
[FieldType.EMBED]: EmbedOptions;
92+
[FieldType.EXCLUDED]: undefined;
93+
}
94+
95+
export type InlineFieldType = FieldType.INPUT | FieldType.VIEW | FieldType.BUTTON_GROUP;
96+
97+
/**
98+
* @internal
99+
* @param type
100+
*/
101+
export function isFieldTypeAllowedInline(type: FieldType): type is InlineFieldType {
102+
return type === FieldType.INPUT || type === FieldType.VIEW || type === FieldType.BUTTON_GROUP;
103+
}

packages/core/src/config/FieldConfigs.ts

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
import type {
2-
SimpleJsViewFieldDeclaration,
3-
SimpleViewFieldDeclaration,
4-
} from 'packages/core/src/parsers/viewFieldParser/ViewFieldDeclaration';
5-
import type { BindTargetScope } from 'packages/core/src/metadata/BindTargetScope';
6-
import type { SimpleInputFieldDeclaration } from 'packages/core/src/parsers/inputFieldParser/InputFieldDeclaration';
7-
import type { ButtonConfig } from 'packages/core/src/config/ButtonConfig';
8-
import type { SimpleButtonGroupDeclaration } from 'packages/core/src/parsers/ButtonParser';
9-
import { type BindTargetDeclaration } from 'packages/core/src/parsers/bindTargetParser/BindTargetDeclaration';
10-
import { type MetaBindColumnDeclaration } from 'packages/core/src/fields/metaBindTable/TableMountable';
11-
121
/**
132
* @internal
143
*/
@@ -604,93 +593,4 @@ export const ViewFieldArgumentConfigs: Record<ViewFieldArgumentType, ViewFieldAr
604593
},
605594
};
606595

607-
export enum RenderChildType {
608-
INLINE = 'inline',
609-
BLOCK = 'block',
610-
}
611-
612596
export const EMBED_MAX_DEPTH = 8;
613-
614-
export enum FieldType {
615-
INPUT = 'INPUT',
616-
VIEW = 'VIEW',
617-
JS_VIEW = 'JS_VIEW',
618-
TABLE = 'TABLE',
619-
BUTTON_GROUP = 'BUTTON_GROUP',
620-
BUTTON = 'BUTTON',
621-
EMBED = 'EMBED',
622-
EXCLUDED = 'EXCLUDED',
623-
}
624-
625-
export interface InputFieldOptions {
626-
renderChildType: RenderChildType;
627-
declaration: SimpleInputFieldDeclaration | string;
628-
scope?: BindTargetScope | undefined;
629-
}
630-
631-
export interface ViewFieldOptions {
632-
renderChildType: RenderChildType;
633-
declaration: SimpleViewFieldDeclaration | string;
634-
scope?: BindTargetScope | undefined;
635-
}
636-
637-
export interface JsViewFieldOptions {
638-
declaration: SimpleJsViewFieldDeclaration | string;
639-
}
640-
641-
export interface TableOptions {
642-
bindTarget: BindTargetDeclaration;
643-
tableHead: string[];
644-
columns: MetaBindColumnDeclaration[];
645-
}
646-
647-
export interface ButtonGroupOptions {
648-
renderChildType: RenderChildType;
649-
declaration: SimpleButtonGroupDeclaration | string;
650-
position?: NotePosition | undefined;
651-
}
652-
653-
export interface ButtonOptions {
654-
declaration: ButtonConfig | string;
655-
position?: NotePosition | undefined;
656-
isPreview: boolean;
657-
}
658-
659-
export class NotePosition {
660-
linePosition: LinePosition | undefined;
661-
662-
constructor(linePosition: LinePosition | undefined) {
663-
this.linePosition = linePosition;
664-
}
665-
666-
getPosition(): LinePosition | undefined {
667-
return this.linePosition;
668-
}
669-
}
670-
671-
export interface LinePosition {
672-
lineStart: number;
673-
lineEnd: number;
674-
}
675-
676-
export interface EmbedOptions {
677-
depth: number;
678-
content: string;
679-
}
680-
681-
export interface FieldOptionMap {
682-
[FieldType.INPUT]: InputFieldOptions;
683-
[FieldType.VIEW]: ViewFieldOptions;
684-
[FieldType.JS_VIEW]: JsViewFieldOptions;
685-
[FieldType.TABLE]: TableOptions;
686-
[FieldType.BUTTON_GROUP]: ButtonGroupOptions;
687-
[FieldType.BUTTON]: ButtonOptions;
688-
[FieldType.EMBED]: EmbedOptions;
689-
[FieldType.EXCLUDED]: undefined;
690-
}
691-
692-
export type InlineFieldType = FieldType.INPUT | FieldType.VIEW | FieldType.BUTTON_GROUP;
693-
694-
export function isFieldTypeAllowedInline(type: FieldType): type is InlineFieldType {
695-
return type === FieldType.INPUT || type === FieldType.VIEW || type === FieldType.BUTTON_GROUP;
696-
}

packages/core/src/fields/button/ButtonActionRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { MDLinkParser } from 'packages/core/src/parsers/MarkdownLinkParser';
2222
import { expectType, openURL } from 'packages/core/src/utils/Utils';
2323
import { parseLiteral } from 'packages/core/src/utils/Literal';
2424

25-
import { type NotePosition } from 'packages/core/src/config/FieldConfigs';
25+
import { type NotePosition } from 'packages/core/src/config/APIConfigs';
2626

2727
export class ButtonActionRunner {
2828
plugin: IPlugin;

packages/core/src/fields/button/ButtonField.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { type ButtonConfig } from 'packages/core/src/config/ButtonConfig';
33
import { DomHelpers, isTruthy } from 'packages/core/src/utils/Utils';
44
import ButtonComponent from 'packages/core/src/utils/components/ButtonComponent.svelte';
55
import { Mountable } from 'packages/core/src/utils/Mountable';
6-
import { type NotePosition, RenderChildType } from 'packages/core/src/config/FieldConfigs';
6+
import { type NotePosition, RenderChildType } from 'packages/core/src/config/APIConfigs';
77

88
export class ButtonField extends Mountable {
99
plugin: IPlugin;

packages/core/src/fields/button/ButtonGroupField.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ButtonField } from 'packages/core/src/fields/button/ButtonField';
44
import { DomHelpers } from 'packages/core/src/utils/Utils';
55
import ButtonComponent from 'packages/core/src/utils/components/ButtonComponent.svelte';
66
import { Mountable } from 'packages/core/src/utils/Mountable';
7-
import { type NotePosition, RenderChildType } from 'packages/core/src/config/FieldConfigs';
7+
import { type NotePosition, RenderChildType } from 'packages/core/src/config/APIConfigs';
88

99
export class ButtonGroupField extends Mountable {
1010
plugin: IPlugin;

packages/core/src/fields/button/ButtonGroupMountable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ButtonGroupField } from 'packages/core/src/fields/button/ButtonGroupFie
44
import { DomHelpers, showUnloadedMessage } from 'packages/core/src/utils/Utils';
55
import { ErrorCollection } from 'packages/core/src/utils/errors/ErrorCollection';
66
import { type ButtonGroupDeclaration } from 'packages/core/src/parsers/ButtonParser';
7-
import { type NotePosition, type RenderChildType } from 'packages/core/src/config/FieldConfigs';
7+
import { type NotePosition, type RenderChildType } from 'packages/core/src/config/APIConfigs';
88

99
export class ButtonGroupMountable extends FieldMountable {
1010
errorCollection: ErrorCollection;

packages/core/src/fields/button/ButtonMountable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ButtonField } from 'packages/core/src/fields/button/ButtonField';
44
import { DomHelpers, showUnloadedMessage } from 'packages/core/src/utils/Utils';
55
import { ErrorCollection } from 'packages/core/src/utils/errors/ErrorCollection';
66
import { type ButtonDeclaration } from 'packages/core/src/parsers/ButtonParser';
7-
import { type NotePosition, RenderChildType } from 'packages/core/src/config/FieldConfigs';
7+
import { type NotePosition, RenderChildType } from 'packages/core/src/config/APIConfigs';
88

99
export class ButtonMountable extends FieldMountable {
1010
errorCollection: ErrorCollection;

0 commit comments

Comments
 (0)