Skip to content

feat: Task Line Modal with given description#3389

Closed
Nizbel92 wants to merge 1 commit intoobsidian-tasks-group:mainfrom
Nizbel92:modal-from-string
Closed

feat: Task Line Modal with given description#3389
Nizbel92 wants to merge 1 commit intoobsidian-tasks-group:mainfrom
Nizbel92:modal-from-string

Conversation

@Nizbel92
Copy link
Copy Markdown

@Nizbel92 Nizbel92 commented Mar 22, 2025

Types of changes

Changes visible to users:

  • New feature (prefix: feat - non-breaking change which adds functionality)
    • Issue/discussion:
    • WARNING: If the link is absent, the PR may be closed without review, due to the workload that such reviews usually require.
  • Documentation (prefix: docs - improvements to any documentation content for users)

Internal changes:

  • Tests (prefix: test - additions and improvements to unit tests and the smoke tests)

Description

I'm not very familiar with JavaScript and GitHub, so I would appreciate any corrections and advice to ensure my pull request is acceptable. Thank you!

Writing task descriptions repeatedly can be exhausting. To simplify this process, I've added a new function, createTaskLineModalFromString, to the API. This function is similar to createTaskLineModal but allows the description to be passed as an argument. When called, it opens the same modal window but with the description field already filled in.

Please review my changes and provide any feedback or suggestions for improvement.

Motivation and Context

How has this been tested?

I have tested this new function using QuickAdd Capture with the following format:

const editor = this.app.workspace.activeEditor.editor;
const cursor = editor.getCursor().line;
const matches = editor.getLine(cursor).match(/[А-Яа-яA-Za-z0-9]+.*$/);
var description = "";
if (matches.length != 0) {
    description = matches[0].trim();
}

return await this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1.createTaskLineModalFromString(description) + "\n";

Screenshots (if appropriate)

Checklist

Terms

@sonarqubecloud
Copy link
Copy Markdown

@claremacrae
Copy link
Copy Markdown
Member

Hi, thank you for offering a contribution to Tasks.

My first thought is that this looks it behaves the same as if the user ran the existing Tasks-plugin-provided command to open the Edit Task Modal, which loads the current markdown line in to the Description field (as well as handling any fields on the line).

So what is the advantage of this new mechanism please? What am I missing?

@claremacrae claremacrae added question Further information is requested scope: for plugin developers Tools for use by plugin developers, including the Tasks API labels Mar 22, 2025
@Nizbel92
Copy link
Copy Markdown
Author

Nizbel92 commented Mar 24, 2025

@claremacrae

So what is the advantage of this new mechanism please? What am I missing?

Hi!

I guess you're describing a case where the user opens a modal on an existing task or by command from command palette. My idea is the same - I, as a user, want to open a modal with the text selected in the Editor as the description in the modal. But main point is that this feature don't work with the method createTaskLineModal from API, and I can't use this feature in compex action like QuickAdd Capture

For example, I have a note with random thoughts as a list or just raw text, click a button (which currently refers to the QuickAdd command), and see the modal with the selected text or the text under the current line as the description in the modal.

Thanks!

@claremacrae
Copy link
Copy Markdown
Member

Thanks for the reply.

I didn't explain the question very well, but I can see that what you have done is useful in more situations than the current command.

@claremacrae
Copy link
Copy Markdown
Member

Transparency note from @claremacrae: I've edited the original description to reinstate the text that was deleted from the new PR template, as best as I can...

@claremacrae claremacrae removed the question Further information is requested label Mar 24, 2025
@claremacrae
Copy link
Copy Markdown
Member

Types of changes

Changes visible to users:

  • New feature (prefix: feat - non-breaking change which adds functionality)
    • Issue/discussion:
    • WARNING: If the link is absent, the PR may be closed without review, due to the workload that such reviews usually require.

There isn't an existing issue feature request that matches this functionality.

The closest match for this request is:

But that would need to do more work, because it would need to parse any existing signifiers from the input string. This would need to take care of whether the user's selected format is Tasks Emojis or Dataview format, for example.

@claremacrae
Copy link
Copy Markdown
Member

@Nizbel92,

I have been giving this a lot of thought.

It was kind of you to offer this pull request - thank you.

What's needed

However, the functionality that has been requested by users (in #1945) is considerably more complex than the code in this pull request, because of the need to handle parsing of Emoji or Dataview signifiers from the input line.

Additionally, new tests would be required, in addition to the existing API unit tests.

And careful documentation is needed too.

I'm not very familiar with JavaScript and GitHub, so I would appreciate any corrections and advice to ensure my pull request is acceptable. Thank you!

My feeling is that it's not reasonable to ask someone new to Typescript to try and implement #1945 to the standard that would be needed to merge a pull request - and I'm afraid I don't have enough spare time to support anyone through learning to do that anymore.

Getting help

Do you know anyone with Typescript experience who you could ask to help you with this?

@claremacrae
Copy link
Copy Markdown
Member

In the meantime I'm setting this to Draft, as it doesn't have tests and user documentation, so isn't suitable for merging.

@claremacrae claremacrae marked this pull request as draft March 24, 2025 23:03
@claremacrae
Copy link
Copy Markdown
Member

@Nizbel92,

I have been giving this a lot of thought.

It was kind of you to offer this pull request - thank you.

What's needed

However, the functionality that has been requested by users (in #1945) is considerably more complex than the code in this pull request, because of the need to handle parsing of Emoji or Dataview signifiers from the input line.

Additionally, new tests would be required, in addition to the existing API unit tests.

And careful documentation is needed too.

I'm not very familiar with JavaScript and GitHub, so I would appreciate any corrections and advice to ensure my pull request is acceptable. Thank you!

My feeling is that it's not reasonable to ask someone new to Typescript to try and implement #1945 to the standard that would be needed to merge a pull request - and I'm afraid I don't have enough spare time to support anyone through learning to do that anymore.

Getting help

Do you know anyone with Typescript experience who you could ask to help you with this?

I am sorry that I didn't have time to help review and refine this to make it releasable.

Someone else is now looking at enabling the editing of existing task lines via the API, so I will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: for plugin developers Tools for use by plugin developers, including the Tasks API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants