Skip to content

Commit

Permalink
feat: apply settings to config
Browse files Browse the repository at this point in the history
  • Loading branch information
waynevanson committed Aug 29, 2023
1 parent f0f81c3 commit 85371d9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
15 changes: 8 additions & 7 deletions .vault/.obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"type": "split",
"children": [
{
"id": "de95ac78283896a0",
"id": "9eaa83374cb4cf87",
"type": "tabs",
"children": [
{
"id": "73baacbde27bf18c",
"id": "76b757e0be450594",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "Sample 05.md",
"file": "Sample 06.md",
"mode": "source",
"source": true
}
Expand Down Expand Up @@ -85,7 +85,7 @@
"state": {
"type": "backlink",
"state": {
"file": "Sample 05.md",
"file": "Sample 06.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -102,7 +102,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "Sample 05.md",
"file": "Sample 06.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -125,7 +125,7 @@
"state": {
"type": "outline",
"state": {
"file": "Sample 05.md"
"file": "Sample 06.md"
}
}
}
Expand All @@ -147,8 +147,9 @@
"command-palette:Open command palette": false
}
},
"active": "73baacbde27bf18c",
"active": "76b757e0be450594",
"lastOpenFiles": [
"Sample 06.md",
"Sample 05.md",
"Sample 04.md",
"Sample 03.md",
Expand Down
15 changes: 15 additions & 0 deletions .vault/Sample 06.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
schema:
properties:
name:
type: string
datasource:
name: Yo bro
---

```yaml-data-entry
datasource:
file:
schema:
file:
```
16 changes: 10 additions & 6 deletions packages/data-entry/src/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ import {
Notice,
Plugin,
PluginManifest,
PluginSettingTab,
YamlParseError,
parseYaml,
} from 'obsidian';
import * as React from 'react';
import { StrictMode } from 'react';
import { Root, createRoot } from 'react-dom/client';
import { configuration } from './config';
import { Application } from './components';
import { ApplicationProvider } from './components/context';
import { useTheme } from './components/material';
import { ApplicationSettings, SettingsConfiguration } from './settings';
import { configuration } from './config';
import { ApplicationSettings } from './settings';

type Handler = Parameters<Plugin['registerMarkdownCodeBlockProcessor']>[1];

Expand Down Expand Up @@ -77,14 +76,19 @@ export class MainPlugin extends Plugin {
const contents = createJsonify(yamls.includes(extension))(source);
console.debug({ contents });

const settings = this.settings.settings;

const config = pipe(
contents,
either.chainW(
flow(
configuration({
datasource: { path, frontmatter: 'data' }, // todo - change to `datasource`
schema: { path, frontmatter: 'schema' },
uischema: { path, frontmatter: 'uischema' },
datasource: {
path,
frontmatter: settings.datasource.frontmatter,
}, // todo - change to `datasource`
schema: { path, frontmatter: settings.schema.frontmatter },
uischema: { path, frontmatter: settings.uischema.frontmatter },
}).decode,
either.mapLeft(decoder.draw),
),
Expand Down
10 changes: 0 additions & 10 deletions packages/data-entry/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ export class ApplicationSettings extends PluginSettingTab {
this.containerEl.empty();

this.containerEl.createEl('h1').setText('Data Entry');

this.containerEl
.createEl('p')
.setText(
[
'These settings are currently disabled and are for testing purposes only.',
'Please wait another release for these to be enabled.',
].join('\n'),
);

this.containerEl.createEl('h2').setText('Configuration');
this.containerEl.createEl('h3').setText('Defaults');

Expand Down

0 comments on commit 85371d9

Please sign in to comment.