Skip to content

Commit 7eae9fc

Browse files
authored
Merge pull request #3268 from obsidian-tasks-group/chore-obsidian-api-1.4.0
build(deps-dev): bump obsidian API from 1.1.1 to 1.4.0
2 parents 5351ab4 + 378497e commit 7eae9fc

File tree

8 files changed

+75
-67
lines changed

8 files changed

+75
-67
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "obsidian-tasks-plugin",
33
"name": "Tasks",
44
"version": "7.14.0",
5-
"minAppVersion": "1.1.1",
5+
"minAppVersion": "1.4.0",
66
"description": "Track tasks across your vault. Supports due dates, recurring tasks, done dates, sub-set of checklist items, and filtering.",
77
"helpUrl": "https://publish.obsidian.md/tasks/",
88
"author": "Clare Macrae and Ilyas Landikov (created by Martin Schenck)",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"madge": "^8.0.0",
5555
"markdownlint-cli2": "^0.13.0",
5656
"moment": "^2.29.4",
57-
"obsidian": "^1.1.1",
57+
"obsidian": "^1.4.0",
5858
"prettier": "^2.8.8",
5959
"prettier-plugin-svelte": "^2.10.1",
6060
"svelte": "^3.59.1",

resources/sample_vaults/Tasks-Demo/Manual Testing/Smoke Testing the Tasks Plugin.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ heading includes Rendering of Task Blocks
149149
150150
- View this file in **Reading mode**...
151151
- On the task line above:
152-
- [ ] #task **left**-click on a date value, and use the date picker to select and save a different date. Check that the date is updated.
153-
- [ ] #task **left**-click on a date value, and click outside the date picker, to confirm that the picker closes.
154-
- [ ] #task **right**-click on a date value, and use the context menu to select and save a different date. Check that the date is updated.
155-
- [ ] #task **right**-click on a date value, and click outside the context menu, to confirm that the menu closes.
152+
- [ ] #task **left**-click on a date value (above), and use the date picker to select and save a different date. Check that the date is updated.
153+
- [ ] #task **left**-click on a date value (above), and click outside the date picker, to confirm that the picker closes.
154+
- [ ] #task **right**-click on a date value (above), and use the context menu to select and save a different date. Check that the date is updated.
155+
- [ ] #task **right**-click on a date value (above), and click outside the context menu, to confirm that the menu closes.
156156
- In the tasks search block below:
157-
- [ ] #task **left**-click on a date value, and use the date picker to select and save a different date. Check that the date is updated.
158-
- [ ] #task **left**-click on a date value, and click outside the date picker, to confirm that the picker closes.
159-
- [ ] #task **right**-click on a date value, and use the context menu to select and save a different date. Check that the date is updated.
160-
- [ ] #task **right**-click on a date value, and click outside the context menu, to confirm that the menu closes.
157+
- [ ] #task **left**-click on a date value (below), and use the date picker to select and save a different date. Check that the date is updated.
158+
- [ ] #task **left**-click on a date value (below), and click outside the date picker, to confirm that the picker closes.
159+
- [ ] #task **right**-click on a date value (below), and use the context menu to select and save a different date. Check that the date is updated.
160+
- [ ] #task **right**-click on a date value (below), and click outside the context menu, to confirm that the menu closes.
161161
- [ ] #task **check**: Checked all above steps for **editing dates** worked
162162

163163
```tasks

src/Obsidian/TasksEvents.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export class TasksEvents {
2424

2525
public onCacheUpdate(handler: (cacheData: CacheUpdateData) => void): EventRef {
2626
this.logger.debug('TasksEvents.onCacheUpdate()');
27+
// @ts-expect-error: error TS2345: Argument of type '(cacheData: CacheUpdateData) => void'
28+
// is not assignable to parameter of type '(...data: unknown[]) => unknown'.
2729
return this.obsidianEvents.on(Event.CacheUpdate, handler);
2830
}
2931

@@ -34,6 +36,8 @@ export class TasksEvents {
3436

3537
public onRequestCacheUpdate(handler: (fn: (cacheData: CacheUpdateData) => void) => void): EventRef {
3638
this.logger.debug('TasksEvents.onRequestCacheUpdate()');
39+
// @ts-expect-error: error TS2345: Argument of type '(cacheData: CacheUpdateData) => void'
40+
// is not assignable to parameter of type '(...data: unknown[]) => unknown'.
3741
return this.obsidianEvents.on(Event.RequestCacheUpdate, handler);
3842
}
3943

src/Renderer/QueryRenderer.ts

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type { TasksEvents } from '../Obsidian/TasksEvents';
1717
import { TasksFile } from '../Scripting/TasksFile';
1818
import { DateFallback } from '../DateTime/DateFallback';
1919
import type { Task } from '../Task/Task';
20-
import { QueryResultsRenderer } from './QueryResultsRenderer';
20+
import { type BacklinksEventHandler, type EditButtonClickHandler, QueryResultsRenderer } from './QueryResultsRenderer';
2121
import { createAndAppendElement } from './TaskLineRenderer';
2222

2323
export class QueryRenderer {
@@ -155,62 +155,68 @@ class QueryRenderChild extends MarkdownRenderChild {
155155
await this.queryResultsRenderer.render(state, tasks, content, {
156156
allTasks: this.plugin.getTasks(),
157157
allMarkdownFiles: this.app.vault.getMarkdownFiles(),
158-
backlinksClickHandler,
159-
backlinksMousedownHandler,
160-
editTaskPencilClickHandler,
158+
backlinksClickHandler: createBacklinksClickHandler(this.app),
159+
backlinksMousedownHandler: createBacklinksMousedownHandler(this.app),
160+
editTaskPencilClickHandler: createEditTaskPencilClickHandler(this.app),
161161
});
162162

163163
this.containerEl.firstChild?.replaceWith(content);
164164
}
165165
}
166166

167-
function editTaskPencilClickHandler(event: MouseEvent, task: Task, allTasks: Task[]) {
168-
event.preventDefault();
169-
170-
const onSubmit = async (updatedTasks: Task[]): Promise<void> => {
171-
await replaceTaskWithTasks({
172-
originalTask: task,
173-
newTasks: DateFallback.removeInferredStatusIfNeeded(task, updatedTasks),
167+
function createEditTaskPencilClickHandler(app: App): EditButtonClickHandler {
168+
return function editTaskPencilClickHandler(event: MouseEvent, task: Task, allTasks: Task[]) {
169+
event.preventDefault();
170+
171+
const onSubmit = async (updatedTasks: Task[]): Promise<void> => {
172+
await replaceTaskWithTasks({
173+
originalTask: task,
174+
newTasks: DateFallback.removeInferredStatusIfNeeded(task, updatedTasks),
175+
});
176+
};
177+
178+
// Need to create a new instance every time, as cursor/task can change.
179+
const taskModal = new TaskModal({
180+
app,
181+
task,
182+
onSubmit,
183+
allTasks,
174184
});
185+
taskModal.open();
175186
};
176-
177-
// Need to create a new instance every time, as cursor/task can change.
178-
const taskModal = new TaskModal({
179-
app,
180-
task,
181-
onSubmit,
182-
allTasks,
183-
});
184-
taskModal.open();
185-
}
186-
187-
async function backlinksClickHandler(ev: MouseEvent, task: Task) {
188-
const result = await getTaskLineAndFile(task, app.vault);
189-
if (result) {
190-
const [line, file] = result;
191-
const leaf = app.workspace.getLeaf(Keymap.isModEvent(ev));
192-
// When the corresponding task has been found,
193-
// suppress the default behavior of the mouse click event
194-
// (which would interfere e.g. if the query is rendered inside a callout).
195-
ev.preventDefault();
196-
// Instead of the default behavior, open the file with the required line highlighted.
197-
await leaf.openFile(file, { eState: { line: line } });
198-
}
199187
}
200188

201-
async function backlinksMousedownHandler(ev: MouseEvent, task: Task) {
202-
// Open in a new tab on middle-click.
203-
// This distinction is not available in the 'click' event, so we handle the 'mousedown' event
204-
// solely for this.
205-
// (for regular left-click we prefer the 'click' event, and not to just do everything here, because
206-
// the 'click' event is more generic for touch devices etc.)
207-
if (ev.button === 1) {
189+
function createBacklinksClickHandler(app: App): BacklinksEventHandler {
190+
return async function backlinksClickHandler(ev: MouseEvent, task: Task) {
208191
const result = await getTaskLineAndFile(task, app.vault);
209192
if (result) {
210193
const [line, file] = result;
211-
const leaf = app.workspace.getLeaf('tab');
194+
const leaf = app.workspace.getLeaf(Keymap.isModEvent(ev));
195+
// When the corresponding task has been found,
196+
// suppress the default behavior of the mouse click event
197+
// (which would interfere e.g. if the query is rendered inside a callout).
212198
ev.preventDefault();
213-
await leaf.openFile(file, { eState: { line: line } });
199+
// Instead of the default behavior, open the file with the required line highlighted.
200+
await leaf.openFile(file, { eState: { line } });
214201
}
215-
}
202+
};
203+
}
204+
205+
function createBacklinksMousedownHandler(app: App): BacklinksEventHandler {
206+
return async function backlinksMousedownHandler(ev: MouseEvent, task: Task) {
207+
// Open in a new tab on middle-click.
208+
// This distinction is not available in the 'click' event, so we handle the 'mousedown' event
209+
// solely for this.
210+
// (for regular left-click we prefer the 'click' event, and not to just do everything here, because
211+
// the 'click' event is more generic for touch devices etc.)
212+
if (ev.button === 1) {
213+
const result = await getTaskLineAndFile(task, app.vault);
214+
if (result) {
215+
const [line, file] = result;
216+
const leaf = app.workspace.getLeaf('tab');
217+
ev.preventDefault();
218+
await leaf.openFile(file, { eState: { line: line } });
219+
}
220+
}
221+
};
216222
}

src/Renderer/QueryResultsRenderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import { Task } from '../Task/Task';
1717
import { PostponeMenu } from '../ui/Menus/PostponeMenu';
1818
import { TaskLineRenderer, type TextRenderer, createAndAppendElement } from './TaskLineRenderer';
1919

20-
type BacklinksEventHandler = (ev: MouseEvent, task: Task) => Promise<void>;
21-
type EditButtonClickHandler = (event: MouseEvent, task: Task, allTasks: Task[]) => void;
20+
export type BacklinksEventHandler = (ev: MouseEvent, task: Task) => Promise<void>;
21+
export type EditButtonClickHandler = (event: MouseEvent, task: Task, allTasks: Task[]) => void;
2222

2323
export interface QueryRendererParameters {
2424
allTasks: Task[];

tests/Obsidian/Cache.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,6 @@ describe('accessing links in file', function () {
649649
});
650650

651651
it('should access links in frontmatter', () => {
652-
// Update to Obsidian API 1.4.0 to access cachedMetadata.frontmatterLinks
653-
// @ts-expect-error TS2551: Property frontmatterLinks does not exist on type CachedMetadata
654652
const frontMatterLinks = cachedMetadata['frontmatterLinks'];
655653
expect(frontMatterLinks).toBeDefined();
656654

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,10 +1112,10 @@
11121112
dependencies:
11131113
"@babel/types" "^7.3.0"
11141114

1115-
"@types/codemirror@0.0.108":
1116-
version "0.0.108"
1117-
resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-0.0.108.tgz#e640422b666bf49251b384c390cdeb2362585bde"
1118-
integrity sha512-3FGFcus0P7C2UOGCNUVENqObEb4SFk+S8Dnxq7K6aIsLVs/vDtlangl3PEO0ykaKXyK56swVF6Nho7VsA44uhw==
1115+
"@types/codemirror@5.60.8":
1116+
version "5.60.8"
1117+
resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-5.60.8.tgz#b647d04b470e8e1836dd84b2879988fc55c9de68"
1118+
integrity sha512-VjFgDF/eB+Aklcy15TtOTLQeMjTo07k7KAjql8OK5Dirr7a6sJY4T1uVBDuTVG9VEmn1uUsohOpYnVfgC6/jyw==
11191119
dependencies:
11201120
"@types/tern" "*"
11211121

@@ -4573,12 +4573,12 @@ object.values@^1.1.7:
45734573
define-properties "^1.2.0"
45744574
es-abstract "^1.22.1"
45754575

4576-
obsidian@^1.1.1:
4577-
version "1.2.5"
4578-
resolved "https://registry.yarnpkg.com/obsidian/-/obsidian-1.2.5.tgz#86a075de3894303b90450fb98af1293918d13bc3"
4579-
integrity sha512-RKN4W3PaHsoWwlNRg1SV+iJssQ5vnQYzsCSfmFAUHvA8Q8nzk4pW3HGWXSvor3ZM532KECljG86lEx02OvBwpA==
4576+
obsidian@^1.4.0:
4577+
version "1.7.2"
4578+
resolved "https://registry.yarnpkg.com/obsidian/-/obsidian-1.7.2.tgz#2d989288742ae7a65760fd87a953d1ff2a402808"
4579+
integrity sha512-k9hN9brdknJC+afKr5FQzDRuEFGDKbDjfCazJwpgibwCAoZNYHYV8p/s3mM8I6AsnKrPKNXf8xGuMZ4enWelZQ==
45804580
dependencies:
4581-
"@types/codemirror" "0.0.108"
4581+
"@types/codemirror" "5.60.8"
45824582
moment "2.29.4"
45834583

45844584
once@^1.3.0:

0 commit comments

Comments
 (0)