diff --git a/.prettierignore b/.prettierignore index 600d2d3..344208f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ -.vscode \ No newline at end of file +.vscode +CHANGELOG.md \ No newline at end of file diff --git a/e2e-tests/cycle-todo-dwim.spec.ts b/e2e-tests/cycle-todo-dwim.spec.ts index c10dafb..4550759 100644 --- a/e2e-tests/cycle-todo-dwim.spec.ts +++ b/e2e-tests/cycle-todo-dwim.spec.ts @@ -1,8 +1,9 @@ -import { expect } from '@playwright/test' +import { expect, Page } from '@playwright/test' import { test } from './fixtures' import { createRandomPage, modKey } from './utils' test('cycling TODO state', async ({ page, block }) => { + await setSkipDoingSettingTo(page, false) await createRandomPage(page) await block.mustFill('foo') @@ -28,6 +29,7 @@ test('cycling TODO state', async ({ page, block }) => { }) test('cycling TODO state while editing', async ({ page, block }) => { + await setSkipDoingSettingTo(page, false) await createRandomPage(page) await block.activeEditing(0) @@ -43,6 +45,7 @@ test('cycling TODO state while editing', async ({ page, block }) => { }) test('cycling TODO state (SCHEDULED)', async ({ page, block }) => { + await setSkipDoingSettingTo(page, false) await createRandomPage(page) await block.mustFill(`LATER foobar\nSCHEDULED: <2000-01-01 Sat .+73y>`) @@ -68,6 +71,7 @@ test('cycling TODO state (SCHEDULED) while editing', async ({ page, block, }) => { + await setSkipDoingSettingTo(page, false) await createRandomPage(page) await block.activeEditing(0) @@ -90,6 +94,7 @@ test('cycling TODO state (SCHEDULED, but not repeating)', async ({ page, block, }) => { + await setSkipDoingSettingTo(page, false) await createRandomPage(page) await block.mustFill(`LATER foobar\nSCHEDULED: <2000-01-01 Sat>`) @@ -110,3 +115,34 @@ test('cycling TODO state (SCHEDULED, but not repeating)', async ({ ).toContainText(`SCHEDULED: ${expected.scheduled}`) } }) + +test('skipping NOW/DOING when this option is enabled', async ({ + page, + block, +}) => { + await setSkipDoingSettingTo(page, true) + await createRandomPage(page) + + await block.mustFill(`LATER foobar`) + await block.escapeEditing() + await page.keyboard.press('ArrowDown', { delay: 10 }) + await page.keyboard.press(modKey + '+Shift+Enter', { delay: 10 }) + await expect(page.locator('.block-content span >> nth=0')).toHaveClass( + `inline done` + ) +}) + +async function setSkipDoingSettingTo(page: Page, enabled: boolean) { + await page.click('#head .toolbar-dots-btn') + await page.click('#head .dropdown-wrapper >> text=Settings') + await page.click('.settings-modal [data-id=plugins] a') + + const setting = page.locator( + '[data-key=cycleTODOdwimSkipDoing] >> input[type=checkbox]' + ) + + await setting.setChecked(enabled) + await page.waitForTimeout(1000) + await page.keyboard.press('Escape') + await page.keyboard.press('Escape') +} diff --git a/e2e-tests/install.spec.ts b/e2e-tests/install.spec.ts index a561c82..93eacd9 100644 --- a/e2e-tests/install.spec.ts +++ b/e2e-tests/install.spec.ts @@ -6,6 +6,6 @@ test('verifying the plugin is installed', async ({ page }) => { await page.keyboard.press('Escape') await page.keyboard.press('t+p') await expect(page.locator('.installed h3 span')).toHaveText( - 'logseq-cycle-todo-dwim' + 'Cycle TODO (Do What I Mean)' ) }) diff --git a/index.ts b/index.ts index 5a5db70..95c8e6c 100644 --- a/index.ts +++ b/index.ts @@ -66,7 +66,16 @@ function setMarker(block: BlockEntity, newMarker: Marker) { async function computeNextMarker(currentMarker: Marker) { const userPreferredStyle = await preferredTodoStyle() const todoSeq = todoSequences[userPreferredStyle] as readonly Marker[] - return todoSeq[(todoSeq.indexOf(currentMarker) + 1) % todoSeq.length] + const nextMarker = + todoSeq[(todoSeq.indexOf(currentMarker) + 1) % todoSeq.length] + if ( + ['NOW', 'DOING'].includes(nextMarker) && + logseq.settings!['cycleTODOdwimSkipDoing'] + ) { + return computeNextMarker(nextMarker) + } else { + return nextMarker + } } type Timestamp = { @@ -153,6 +162,17 @@ async function cycleTODOdwim(): Promise { } async function main() { + logseq.useSettingsSchema([ + { + key: 'cycleTODOdwimSkipDoing', + type: 'boolean', + title: 'Skip NOW/DOING State', + description: + '

Determines whether the Cycle TODO (Do What I Mean) feature skips the NOW/DOING state

', + default: false, + }, + ]) + logseq.App.registerCommandPalette( { label: 'Cycle TODO (Do What I Mean)', diff --git a/package.json b/package.json index c3811d2..ae923d9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "logseq": { "main": "dist/index.html", "icon": "./logo.webp", - "id": "cycle-todo-dwim" + "id": "cycle-todo-dwim", + "title": "Cycle TODO (Do What I Mean)" }, "dependencies": { "@logseq/libs": "^0.2.0",