roamjs-components 0.77.17 → 0.77.19
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.
package/package.json
CHANGED
package/types/native.d.ts
CHANGED
|
@@ -146,11 +146,13 @@ export declare type PullBlock = {
|
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
};
|
|
149
|
+
[k: `:roamjs-${string}`]: Record<string, unknown>;
|
|
149
150
|
};
|
|
150
151
|
":block/refs"?: {
|
|
151
152
|
":db/id": number;
|
|
152
153
|
}[];
|
|
153
154
|
":block/string"?: string;
|
|
155
|
+
":block/view-type"?: `:${BlockViewType}`;
|
|
154
156
|
":block/text-align"?: TextAlignment;
|
|
155
157
|
":block/uid"?: string;
|
|
156
158
|
":children/view-type"?: `:${ViewType}`;
|
|
@@ -185,6 +187,7 @@ export declare type PullBlock = {
|
|
|
185
187
|
};
|
|
186
188
|
export declare type RoamPullResult = RoamPull | null;
|
|
187
189
|
export declare type ViewType = "document" | "bullet" | "numbered";
|
|
190
|
+
export declare type BlockViewType = "tabs" | "outline" | "horizontal" | "popout" | "comment" | "side" | "vertical";
|
|
188
191
|
export declare type TextAlignment = "left" | "center" | "right" | "justify";
|
|
189
192
|
export declare type RoamBlock = {
|
|
190
193
|
attrs?: {
|
package/types/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/types/native.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,4EAA4E","sourcesContent":["// emulating Datalog Grammar\n// https://docs.datomic.com/cloud/query/query-data-reference.html#or-clauses\n\nimport { ChangeEvent } from \"react\";\n\nexport type DatalogSrcVar = {\n type: \"src-var\";\n value: string;\n};\n\nexport type DatalogVariable = {\n type: \"variable\";\n value: string;\n};\n\nexport type DatalogAndClause = {\n type: \"and-clause\";\n clauses: DatalogClause[];\n};\n\nexport type DatalogExpressionClause =\n | DatalogDataPattern\n | DatalogPredExpr\n | DatalogFnExpr\n | DatalogRuleExpr;\n\nexport type DatalogRuleExpr = {\n type: \"rule-expr\";\n srcVar?: DatalogSrcVar;\n ruleName: DatalogRuleName;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogNotClause = {\n type: \"not-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogNotJoinClause = {\n type: \"not-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrClause = {\n type: \"or-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrJoinClause = {\n type: \"or-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogClause =\n | DatalogNotClause\n | DatalogOrJoinClause\n | DatalogExpressionClause\n | DatalogOrClause\n | DatalogNotJoinClause\n | DatalogAndClause;\n\nexport type DatalogDataPattern = {\n type: \"data-pattern\";\n srcVar?: DatalogSrcVar;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogArgument =\n | DatalogSrcVar\n | DatalogVariable\n | DatalogConstant\n | DatalogUnderscore;\n\nexport type DatalogConstant = {\n type: \"constant\";\n value: string;\n};\n\nexport type DatalogPredExpr = {\n type: \"pred-expr\";\n pred:\n | \"<\"\n | \">\"\n | \"re-matches\"\n | \"re-find\"\n | \"clojure.string/includes?\"\n | \"clojure.string/ends-with?\"\n | \"clojure.string/starts-with?\";\n arguments: DatalogArgument[];\n};\n\nexport type DatalogFnExpr = {\n type: \"fn-expr\";\n fn: \"re-pattern\";\n arguments: DatalogArgument[];\n binding: DatalogBinding;\n};\n\nexport type DatalogBinding =\n | DatalogBindScalar\n | DatalogBindTuple\n | DatalogBindColl\n | DatalogBindRel;\n\nexport type DatalogBindScalar = {\n type: \"bind-scalar\";\n variable: DatalogVariable;\n};\nexport type DatalogBindTuple = {\n type: \"bind-tuple\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\nexport type DatalogBindColl = {\n type: \"bind-col\";\n variable: DatalogVariable;\n};\n\nexport type DatalogBindRel = {\n type: \"bind-rel\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\n\nexport type DatalogUnderscore = {\n type: \"underscore\";\n value: \"_\";\n};\n\nexport type DatalogRuleName = {\n type: \"rulename\";\n value: string;\n};\n\nexport type RoamBasicBlock = {\n string: string;\n uid: string;\n};\n\nexport type RoamBasicPage = { title: string; uid: string };\n\nexport type RoamBasicNode = {\n text: string;\n uid: string;\n children: RoamBasicNode[];\n};\n\nexport type RoamPull = {\n \"block/children\"?: RoamNode[];\n \"block/heading\"?: number;\n \"block/open\"?: boolean;\n \"block/order\"?: number;\n \"block/page\"?: RoamNode;\n \"block/parents\"?: RoamNode[];\n \"block/refs\"?: RoamNode[];\n \"block/string\"?: string;\n \"block/uid\"?: string;\n \"children/view-type\"?: `:${ViewType}`;\n \"create/time\"?: number;\n \"create/user\"?: RoamNode;\n \"edit/time\"?: number;\n \"edit/user\"?: RoamNode;\n \"log/id\"?: number;\n \"node/title\"?: string;\n} & RoamNode;\n\nexport type PullBlock = {\n \":block/children\"?: ({ \":db/id\": number } | PullBlock)[];\n \":block/heading\"?: number;\n \":block/open\"?: boolean;\n \":block/order\"?: number;\n \":block/page\"?: { \":db/id\": number };\n \":block/parents\"?: { \":db/id\": number }[];\n \":block/props\"?: {\n \":image-size\"?: {\n [p: string]: {\n \":height\": number;\n \":width\": number;\n };\n };\n \":iframe\"?: {\n [p: string]: {\n \":size\": {\n \":height\": number;\n \":width\": number;\n };\n };\n };\n };\n \":block/refs\"?: { \":db/id\": number }[];\n \":block/string\"?: string;\n \":block/text-align\"?: TextAlignment;\n \":block/uid\"?: string;\n \":children/view-type\"?: `:${ViewType}`;\n \":create/time\"?: number;\n \":create/user\"?: { \":db/id\": number };\n \":edit/time\"?: number;\n \":edit/user\"?: { \":db/id\": number };\n \":db/id\"?: number;\n \":log/id\"?: number;\n \":node/title\"?: string;\n \":user/display-name\"?: string;\n \":user/display-page\"?: { \":db/id\": number };\n \":user/settings\"?: {\n \":namespace-options\": [\":none\", \":partial\", \":full\"];\n \":link-brackets?\": boolean;\n \":showing-inline-references?\": boolean;\n \":right-sidebar-pinned\": {\n [uuid: string]: SidebarWindow;\n };\n \":showing-own-icons?\": boolean;\n \":showing-user-icons?\": boolean;\n \":first-day-of-week\"?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n };\n \":user/uid\"?: string;\n \":user/email\"?: string;\n};\n\nexport type RoamPullResult = RoamPull | null;\n\nexport type ViewType = \"document\" | \"bullet\" | \"numbered\";\n\nexport type TextAlignment = \"left\" | \"center\" | \"right\" | \"justify\";\n\nexport type RoamBlock = {\n attrs?: { source: string[] }[][];\n children?: { id: number }[];\n id?: number;\n string?: string;\n title?: string;\n time?: number;\n uid?: string;\n order?: number;\n \"view-type\"?: ViewType;\n};\n\nexport type RoamError = {\n raw: string;\n \"status-code\": number;\n};\n\nexport type TreeNode = {\n text: string;\n order: number;\n children: TreeNode[];\n parents: number[];\n uid: string;\n heading: number;\n open: boolean;\n viewType: ViewType;\n editTime: Date;\n textAlign: TextAlignment;\n props: {\n imageResize: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n iframe: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n };\n};\n\nexport type TextNode = {\n text: string;\n children: TextNode[];\n};\n\nexport type InputTextNode = {\n text: string;\n children?: InputTextNode[];\n uid?: string;\n heading?: number;\n textAlign?: TextAlignment;\n viewType?: ViewType;\n open?: boolean;\n};\n\ntype PlusType = [number, string];\n\nexport type RoamNode = { \"db/id\": number };\n\nexport type RoamQuery = RoamPull & {\n \"block/graph\"?: RoamNode;\n \"node/graph+title\"?: PlusType;\n \"block/graph+uid\"?: PlusType;\n \"node/graph\"?: RoamNode;\n \"edit/email\"?: string;\n \"entity/graph\"?: RoamNode;\n};\n\nexport type RoamQueryResult = number & RoamQuery;\n\nexport type ClientParams = {\n action:\n | \"pull\"\n | \"q\"\n | \"create-block\"\n | \"update-block\"\n | \"create-page\"\n | \"move-block\"\n | \"delete-block\"\n | \"delete-page\"\n | \"update-page\";\n selector?: string;\n uid?: string;\n query?: string;\n inputs?: string[];\n} & ActionParams;\n\nexport type ActionParams = {\n location?: {\n \"parent-uid\": string;\n order: number;\n };\n block?: {\n string?: string;\n uid?: string;\n open?: boolean;\n heading?: number;\n \"text-align\"?: TextAlignment;\n \"children-view-type\"?: ViewType;\n };\n page?: {\n title?: string;\n uid?: string;\n };\n};\n\nexport type WriteAction = (a: ActionParams) => Promise<void>;\n\nexport type UserSettings = {\n \"global-filters\": {\n includes: string[];\n removes: string[];\n };\n};\n\ntype SidebarWindowType =\n | SidebarBlockWindow\n | SidebarMentionsWindow\n | SidebarGraphWindow\n | SidebarOutlineWindow;\n\nexport type SidebarWindowInput = {\n \"block-uid\": string;\n type: SidebarWindowType[\"type\"];\n};\n\ntype SidebarBlockWindow = {\n type: \"block\";\n \"block-uid\": string;\n};\n\ntype SidebarOutlineWindow = {\n type: \"outline\";\n \"page-uid\": string;\n};\n\ntype SidebarMentionsWindow = {\n type: \"mentions\";\n \"mentions-uid\": string;\n};\n\ntype SidebarGraphWindow = {\n type: \"graph\";\n // \"page-uid\": string; Currently not working despite documentation\n \"block-uid\": string;\n};\n\nexport type SidebarAction = (action: {\n window: SidebarWindowInput;\n}) => Promise<void>;\n\nexport type SidebarWindow = {\n \"collapsed?\": boolean;\n order: number;\n \"pinned?\": boolean;\n \"window-id\": string;\n} & SidebarWindowType;\n\nexport type AddPullWatch = (\n pullPattern: string,\n entityId: string,\n callback: (before: PullBlock | null, after: PullBlock | null) => void\n) => boolean;\n\ntype ButtonAction = {\n type: \"button\";\n onClick?: (e: MouseEvent) => void;\n content: string;\n};\n\ntype SwitchAction = {\n type: \"switch\";\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype InputAction = {\n type: \"input\";\n placeholder: string;\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype SelectAction = {\n type: \"select\";\n items: string[];\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype CustomAction = {\n type: \"reactComponent\";\n component: React.FC;\n};\n\nexport type Action =\n | ButtonAction\n | SwitchAction\n | InputAction\n | SelectAction\n | CustomAction;\n\ntype PanelConfig = {\n tabTitle: string;\n settings: {\n id: string;\n name: string;\n description: string;\n action: Action;\n }[];\n};\n\nexport type AddCommandOptions = {\n label: string;\n callback: () => void;\n disableHotkey?: boolean;\n defaultHotkey?: string | string[];\n};\n\ntype RemoveCommandOptions = {\n label: string;\n};\n\nexport type OnloadArgs = {\n extensionAPI: {\n settings: {\n get: (k: string) => unknown;\n getAll: () => Record<string, unknown>;\n panel: {\n create: (c: PanelConfig) => void;\n };\n set: (k: string, v: unknown) => Promise<void>;\n };\n ui: {\n commandPalette: {\n addCommand: (c: AddCommandOptions) => Promise<void>;\n removeCommand: (c: RemoveCommandOptions) => Promise<void>;\n };\n };\n };\n extension: {\n version: string;\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/types/native.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,4EAA4E","sourcesContent":["// emulating Datalog Grammar\n// https://docs.datomic.com/cloud/query/query-data-reference.html#or-clauses\n\nimport { ChangeEvent } from \"react\";\n\nexport type DatalogSrcVar = {\n type: \"src-var\";\n value: string;\n};\n\nexport type DatalogVariable = {\n type: \"variable\";\n value: string;\n};\n\nexport type DatalogAndClause = {\n type: \"and-clause\";\n clauses: DatalogClause[];\n};\n\nexport type DatalogExpressionClause =\n | DatalogDataPattern\n | DatalogPredExpr\n | DatalogFnExpr\n | DatalogRuleExpr;\n\nexport type DatalogRuleExpr = {\n type: \"rule-expr\";\n srcVar?: DatalogSrcVar;\n ruleName: DatalogRuleName;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogNotClause = {\n type: \"not-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogNotJoinClause = {\n type: \"not-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrClause = {\n type: \"or-clause\";\n srcVar?: DatalogSrcVar;\n clauses: DatalogClause[];\n};\n\nexport type DatalogOrJoinClause = {\n type: \"or-join-clause\";\n srcVar?: DatalogSrcVar;\n variables: DatalogVariable[];\n clauses: DatalogClause[];\n};\n\nexport type DatalogClause =\n | DatalogNotClause\n | DatalogOrJoinClause\n | DatalogExpressionClause\n | DatalogOrClause\n | DatalogNotJoinClause\n | DatalogAndClause;\n\nexport type DatalogDataPattern = {\n type: \"data-pattern\";\n srcVar?: DatalogSrcVar;\n arguments: DatalogArgument[];\n};\n\nexport type DatalogArgument =\n | DatalogSrcVar\n | DatalogVariable\n | DatalogConstant\n | DatalogUnderscore;\n\nexport type DatalogConstant = {\n type: \"constant\";\n value: string;\n};\n\nexport type DatalogPredExpr = {\n type: \"pred-expr\";\n pred:\n | \"<\"\n | \">\"\n | \"re-matches\"\n | \"re-find\"\n | \"clojure.string/includes?\"\n | \"clojure.string/ends-with?\"\n | \"clojure.string/starts-with?\";\n arguments: DatalogArgument[];\n};\n\nexport type DatalogFnExpr = {\n type: \"fn-expr\";\n fn: \"re-pattern\";\n arguments: DatalogArgument[];\n binding: DatalogBinding;\n};\n\nexport type DatalogBinding =\n | DatalogBindScalar\n | DatalogBindTuple\n | DatalogBindColl\n | DatalogBindRel;\n\nexport type DatalogBindScalar = {\n type: \"bind-scalar\";\n variable: DatalogVariable;\n};\nexport type DatalogBindTuple = {\n type: \"bind-tuple\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\nexport type DatalogBindColl = {\n type: \"bind-col\";\n variable: DatalogVariable;\n};\n\nexport type DatalogBindRel = {\n type: \"bind-rel\";\n args: (DatalogVariable | DatalogUnderscore)[];\n};\n\nexport type DatalogUnderscore = {\n type: \"underscore\";\n value: \"_\";\n};\n\nexport type DatalogRuleName = {\n type: \"rulename\";\n value: string;\n};\n\nexport type RoamBasicBlock = {\n string: string;\n uid: string;\n};\n\nexport type RoamBasicPage = { title: string; uid: string };\n\nexport type RoamBasicNode = {\n text: string;\n uid: string;\n children: RoamBasicNode[];\n};\n\nexport type RoamPull = {\n \"block/children\"?: RoamNode[];\n \"block/heading\"?: number;\n \"block/open\"?: boolean;\n \"block/order\"?: number;\n \"block/page\"?: RoamNode;\n \"block/parents\"?: RoamNode[];\n \"block/refs\"?: RoamNode[];\n \"block/string\"?: string;\n \"block/uid\"?: string;\n \"children/view-type\"?: `:${ViewType}`;\n \"create/time\"?: number;\n \"create/user\"?: RoamNode;\n \"edit/time\"?: number;\n \"edit/user\"?: RoamNode;\n \"log/id\"?: number;\n \"node/title\"?: string;\n} & RoamNode;\n\nexport type PullBlock = {\n \":block/children\"?: ({ \":db/id\": number } | PullBlock)[];\n \":block/heading\"?: number;\n \":block/open\"?: boolean;\n \":block/order\"?: number;\n \":block/page\"?: { \":db/id\": number };\n \":block/parents\"?: { \":db/id\": number }[];\n \":block/props\"?: {\n \":image-size\"?: {\n [p: string]: {\n \":height\": number;\n \":width\": number;\n };\n };\n \":iframe\"?: {\n [p: string]: {\n \":size\": {\n \":height\": number;\n \":width\": number;\n };\n };\n };\n [k: `:roamjs-${string}`]: Record<string, unknown>;\n };\n \":block/refs\"?: { \":db/id\": number }[];\n \":block/string\"?: string;\n \":block/view-type\"?: `:${BlockViewType}`;\n \":block/text-align\"?: TextAlignment;\n \":block/uid\"?: string;\n \":children/view-type\"?: `:${ViewType}`;\n \":create/time\"?: number;\n \":create/user\"?: { \":db/id\": number };\n \":edit/time\"?: number;\n \":edit/user\"?: { \":db/id\": number };\n \":db/id\"?: number;\n \":log/id\"?: number;\n \":node/title\"?: string;\n \":user/display-name\"?: string;\n \":user/display-page\"?: { \":db/id\": number };\n \":user/settings\"?: {\n \":namespace-options\": [\":none\", \":partial\", \":full\"];\n \":link-brackets?\": boolean;\n \":showing-inline-references?\": boolean;\n \":right-sidebar-pinned\": {\n [uuid: string]: SidebarWindow;\n };\n \":showing-own-icons?\": boolean;\n \":showing-user-icons?\": boolean;\n \":first-day-of-week\"?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n };\n \":user/uid\"?: string;\n \":user/email\"?: string;\n};\n\nexport type RoamPullResult = RoamPull | null;\n\nexport type ViewType = \"document\" | \"bullet\" | \"numbered\";\n\nexport type BlockViewType =\n | \"tabs\"\n | \"outline\"\n | \"horizontal\"\n | \"popout\"\n | \"comment\"\n | \"side\"\n | \"vertical\";\n\nexport type TextAlignment = \"left\" | \"center\" | \"right\" | \"justify\";\n\nexport type RoamBlock = {\n attrs?: { source: string[] }[][];\n children?: { id: number }[];\n id?: number;\n string?: string;\n title?: string;\n time?: number;\n uid?: string;\n order?: number;\n \"view-type\"?: ViewType;\n};\n\nexport type RoamError = {\n raw: string;\n \"status-code\": number;\n};\n\nexport type TreeNode = {\n text: string;\n order: number;\n children: TreeNode[];\n parents: number[];\n uid: string;\n heading: number;\n open: boolean;\n viewType: ViewType;\n editTime: Date;\n textAlign: TextAlignment;\n props: {\n imageResize: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n iframe: {\n [link: string]: {\n height: number;\n width: number;\n };\n };\n };\n};\n\nexport type TextNode = {\n text: string;\n children: TextNode[];\n};\n\nexport type InputTextNode = {\n text: string;\n children?: InputTextNode[];\n uid?: string;\n heading?: number;\n textAlign?: TextAlignment;\n viewType?: ViewType;\n open?: boolean;\n};\n\ntype PlusType = [number, string];\n\nexport type RoamNode = { \"db/id\": number };\n\nexport type RoamQuery = RoamPull & {\n \"block/graph\"?: RoamNode;\n \"node/graph+title\"?: PlusType;\n \"block/graph+uid\"?: PlusType;\n \"node/graph\"?: RoamNode;\n \"edit/email\"?: string;\n \"entity/graph\"?: RoamNode;\n};\n\nexport type RoamQueryResult = number & RoamQuery;\n\nexport type ClientParams = {\n action:\n | \"pull\"\n | \"q\"\n | \"create-block\"\n | \"update-block\"\n | \"create-page\"\n | \"move-block\"\n | \"delete-block\"\n | \"delete-page\"\n | \"update-page\";\n selector?: string;\n uid?: string;\n query?: string;\n inputs?: string[];\n} & ActionParams;\n\nexport type ActionParams = {\n location?: {\n \"parent-uid\": string;\n order: number;\n };\n block?: {\n string?: string;\n uid?: string;\n open?: boolean;\n heading?: number;\n \"text-align\"?: TextAlignment;\n \"children-view-type\"?: ViewType;\n };\n page?: {\n title?: string;\n uid?: string;\n };\n};\n\nexport type WriteAction = (a: ActionParams) => Promise<void>;\n\nexport type UserSettings = {\n \"global-filters\": {\n includes: string[];\n removes: string[];\n };\n};\n\ntype SidebarWindowType =\n | SidebarBlockWindow\n | SidebarMentionsWindow\n | SidebarGraphWindow\n | SidebarOutlineWindow;\n\nexport type SidebarWindowInput = {\n \"block-uid\": string;\n type: SidebarWindowType[\"type\"];\n};\n\ntype SidebarBlockWindow = {\n type: \"block\";\n \"block-uid\": string;\n};\n\ntype SidebarOutlineWindow = {\n type: \"outline\";\n \"page-uid\": string;\n};\n\ntype SidebarMentionsWindow = {\n type: \"mentions\";\n \"mentions-uid\": string;\n};\n\ntype SidebarGraphWindow = {\n type: \"graph\";\n // \"page-uid\": string; Currently not working despite documentation\n \"block-uid\": string;\n};\n\nexport type SidebarAction = (action: {\n window: SidebarWindowInput;\n}) => Promise<void>;\n\nexport type SidebarWindow = {\n \"collapsed?\": boolean;\n order: number;\n \"pinned?\": boolean;\n \"window-id\": string;\n} & SidebarWindowType;\n\nexport type AddPullWatch = (\n pullPattern: string,\n entityId: string,\n callback: (before: PullBlock | null, after: PullBlock | null) => void\n) => boolean;\n\ntype ButtonAction = {\n type: \"button\";\n onClick?: (e: MouseEvent) => void;\n content: string;\n};\n\ntype SwitchAction = {\n type: \"switch\";\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype InputAction = {\n type: \"input\";\n placeholder: string;\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype SelectAction = {\n type: \"select\";\n items: string[];\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n};\n\ntype CustomAction = {\n type: \"reactComponent\";\n component: React.FC;\n};\n\nexport type Action =\n | ButtonAction\n | SwitchAction\n | InputAction\n | SelectAction\n | CustomAction;\n\ntype PanelConfig = {\n tabTitle: string;\n settings: {\n id: string;\n name: string;\n description: string;\n action: Action;\n }[];\n};\n\nexport type AddCommandOptions = {\n label: string;\n callback: () => void;\n disableHotkey?: boolean;\n defaultHotkey?: string | string[];\n};\n\ntype RemoveCommandOptions = {\n label: string;\n};\n\nexport type OnloadArgs = {\n extensionAPI: {\n settings: {\n get: (k: string) => unknown;\n getAll: () => Record<string, unknown>;\n panel: {\n create: (c: PanelConfig) => void;\n };\n set: (k: string, v: unknown) => Promise<void>;\n };\n ui: {\n commandPalette: {\n addCommand: (c: AddCommandOptions) => Promise<void>;\n removeCommand: (c: RemoveCommandOptions) => Promise<void>;\n };\n };\n };\n extension: {\n version: string;\n };\n};\n"]}
|
package/util/setInputSettings.js
CHANGED
|
@@ -13,9 +13,8 @@ const setInputSettings = ({ blockUid, values, key, index = 0, }) => {
|
|
|
13
13
|
keyNode.children
|
|
14
14
|
.filter(({ text }) => !values.includes(text))
|
|
15
15
|
.forEach(({ uid }) => (0, deleteBlock_1.default)(uid));
|
|
16
|
-
values
|
|
17
|
-
|
|
18
|
-
.forEach((text, order) => (0, createBlock_1.default)({ node: { text }, order, parentUid: keyNode.uid }));
|
|
16
|
+
values.forEach((text, order) => !keyNode.children.some(({ text: c }) => text === c) &&
|
|
17
|
+
(0, createBlock_1.default)({ node: { text }, order, parentUid: keyNode.uid }));
|
|
19
18
|
}
|
|
20
19
|
else {
|
|
21
20
|
(0, createBlock_1.default)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setInputSettings.js","sourceRoot":"","sources":["../../src/util/setInputSettings.ts"],"names":[],"mappings":";;;;AAAA,yGAAyE;AACzE,gFAAgD;AAChD,gFAAgD;AAChD,wEAAwC;AAEjC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,GAAG,EACH,KAAK,GAAG,CAAC,GAMV,EAAQ,EAAE;IACT,MAAM,IAAI,GAAG,IAAA,iCAAuB,EAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,qBAAW,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,QAAQ;aACb,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC5C,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,IAAA,qBAAW,EAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,MAAM
|
|
1
|
+
{"version":3,"file":"setInputSettings.js","sourceRoot":"","sources":["../../src/util/setInputSettings.ts"],"names":[],"mappings":";;;;AAAA,yGAAyE;AACzE,gFAAgD;AAChD,gFAAgD;AAChD,wEAAwC;AAEjC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,GAAG,EACH,KAAK,GAAG,CAAC,GAMV,EAAQ,EAAE;IACT,MAAM,IAAI,GAAG,IAAA,iCAAuB,EAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,qBAAW,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,QAAQ;aACb,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC5C,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,IAAA,qBAAW,EAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,OAAO,CACZ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACd,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC;YACnD,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CACjE,CAAC;KACH;SAAM;QACL,IAAA,qBAAW,EAAC;YACV,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;SAChE,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AA7BW,QAAA,gBAAgB,oBA6B3B;AAEF,kBAAe,wBAAgB,CAAC","sourcesContent":["import getBasicTreeByParentUid from \"../queries/getBasicTreeByParentUid\";\nimport deleteBlock from \"../writes/deleteBlock\";\nimport createBlock from \"../writes/createBlock\";\nimport toFlexRegex from \"./toFlexRegex\";\n\nexport const setInputSettings = ({\n blockUid,\n values,\n key,\n index = 0,\n}: {\n blockUid: string;\n values: string[];\n key: string;\n index?: number;\n}): void => {\n const tree = getBasicTreeByParentUid(blockUid);\n const keyNode = tree.find((t) => toFlexRegex(key).test(t.text));\n if (keyNode) {\n keyNode.children\n .filter(({ text }) => !values.includes(text))\n .forEach(({ uid }) => deleteBlock(uid));\n values.forEach(\n (text, order) =>\n !keyNode.children.some(({ text: c }) => text === c) &&\n createBlock({ node: { text }, order, parentUid: keyNode.uid })\n );\n } else {\n createBlock({\n parentUid: blockUid,\n order: index,\n node: { text: key, children: values.map((text) => ({ text })) },\n });\n }\n};\n\nexport default setInputSettings;\n"]}
|