Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: scroll to new fields in the editor #85

Merged
merged 11 commits into from
Oct 22, 2023
17 changes: 17 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build and Test
on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
cache: "npm"

- run: npm install
- name: Build and Test
run: npm run build && npm run test
123 changes: 118 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"check": "tsc --noEmit",
"build": "npm run check && node esbuild.config.mjs production",
"check": "svelte-check --tsconfig tsconfig.json",
"test": "jest",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
Expand All @@ -25,6 +25,7 @@
"jest": "^29.7.0",
"obsidian": "^1.4.11",
"svelte": "^4.2.0",
"svelte-check": "^3.5.2",
"svelte-preprocess": "^5.0.4",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
Expand All @@ -35,4 +36,4 @@
"fuse.js": "^6.6.2",
"valibot": "^0.19.0"
}
}
}
9 changes: 6 additions & 3 deletions src/core/formDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { object, number, literal, type Output, is, array, string, union, optional, safeParse, minLength, toTrimmed, flatten } from "valibot";
import { object, number, literal, type Output, is, array, string, union, optional, safeParse, minLength, toTrimmed } from "valibot";
/**
* Here are the core logic around the main domain of the plugin,
* which is the form definition.
Expand Down Expand Up @@ -32,7 +32,7 @@ const InputSelectFixedSchema = object({
type: literal("select"),
source: literal("fixed"),
options: array(object({
value: nonEmptyString('Value of a select option'), label: string()
value: string([toTrimmed()]), label: string()
}))
});

Expand Down Expand Up @@ -170,7 +170,10 @@ export function validateFields(fields: unknown) {
}
console.error('Fields issues', result.issues)
return result.issues.map(issue =>
({ message: issue.message, path: issue.path?.map(item => item.key).join('.') })
({
message: issue.message, path: issue.path?.map(item => item.key).join('.'),
index: issue.path?.[0]?.key ?? 0
})
);
}

Expand Down
1 change: 0 additions & 1 deletion src/views/EditFormView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class EditFormView extends ItemView {
target: this.containerEl,
props: {
definition: this.formState,
app: this.app,
onChange: () => {
console.log(this.formState)
this.app.workspace.requestSaveLayout()
Expand Down
Loading