yzhang-gh / vscode-markdown

Markdown All in One
https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one
MIT License
2.93k stars 325 forks source link

Add snippet for task list and table #1006

Open heartacker opened 3 years ago

heartacker commented 3 years ago

Proposal

help to input fast with table and task list

References

image

vscode has created snippet for commonMark https://github.com/microsoft/vscode/blob/cb842dcad0cc6293f207ce4bf26f2b08de3fe261/extensions/markdown-basics/snippets/markdown.code-snippets#L1

now all-in-one support github style, may be we be better to create the snippet for that, like task-list

vscode reject beacuse vscode doesn't include that style, https://github.com/microsoft/vscode/pull/131374 https://github.com/microsoft/vscode/pull/131452

and now all-in-one supported.

yzhang-gh commented 3 years ago

If I don't miss something, this extension doesn't provide any code snippet.

For the task list, I think it is okay to have an unassigned toggleTaskList command (like in #551)

For the GFM table, I agree that "A fixed size table snippet is not useful enough". Probably we can introduce an emmet-style expansion (tb for a default-size table and tbx3x4 for a 3-row 4-column table) Please also see #23.

heartacker commented 3 years ago

0

If I don't miss something, this extension doesn't provide any code snippet.

In my opinion:

  1. use the same style/way to support creating task list which could make it same experience. e.g. within vscode snippet: typing ordered list could insert order list, so using task list is harmonious image

  2. also we could trigger insert snippet to insert, image

  3. vscode creates those snippet because of vscode include those feature and close those pr because of not included, With this theory, vscode will add those snippet once included. so, this extension implement TASK LIST, so It is necessary to add.

1

For the task list, I think it is okay to have an unassigned toggleTaskList command (like in #551)

markdown extension. editing. toggleCodeSpan
markdown extension. editing. toggleMath
markdown extension. editing. toggleMathReverse
markdown extension. editing. toggleList
markdown. extension. editing. toggleCodeBlock
markdown extension. editing. toggleBold
markdown extension. editing. toggleItalic
markdown extension. editing. togglestrikethrough
markdown extension. editing. toggleHeadingUp
markdown extension. editing. toggleHeadingDown

are use for toggle exited code/text(or multi lines) to another , like: togglelist could create one prefix char - when nothing selection, I think that is ==Side effect== of toggle,maybe typing - is better than trigger the command in a text-editor

it is diffenent between toggle command and snippet, one is for toggle , another is for creating

BTW:

there are 2 questions about toggleCodeBlock:

  1. code block usually expands whole line of editor, diff with inline code. so, maybe this command should trying to toggle the whole line or multi lines.

  2. when cause using editorTextFocus and TM_SELECTED_TEXT, Does this command aim to convert a word to fenced code?

https://github.com/axiqia/vscode-markdown/blob/fdd5a678d055816ea915dd0c0cc0086fb91c9b06/package.json#L75

{
    "command": "markdown.extension.editing.toggleCodeBlock",
    "key": "ctrl+shift+k",
    "mac": "cmd+shift+k",
    "when": "editorTextFocus && !editorReadonly && editorLangId == markdown"
},

https://github.com/axiqia/vscode-markdown/blob/fdd5a678d055816ea915dd0c0cc0086fb91c9b06/src/formatting.ts#L44

return editor.insertSnippet( new vscode.SnippetString('```language$0 \n$TM_SELECTED_TEXT\n```'));

like(工 stand for Cursor position):

console.log(" I want to convert this line to fenced工 code"); 

will be convert to

console.log(" I want to convert this line to fenced` ` `language
` ` `
 code"); 

maybe the feature is what we need indeed

2

For the GFM table, I agree that "A fixed size table snippet is not useful enough". Probably we can introduce an emmet-style expansion (tb for a default-size table and tbx3x4 for a 3-row 4-column table) Please also see #23.

  1. emmet is great, agree
  2. typing table snippet could has the same experience above, even creating a simple table
  3. typing table snippet is easy and Intuitive then https://github.com/yzhang-gh/vscode-markdown/issues/23#issuecomment-319990000
yzhang-gh commented 3 years ago

I don't see any advantage of the snippet (for task list) except that you need to type even more characters.

There are a number of extensions that generate markdown tables of configurable sizes: https://marketplace.visualstudio.com/items?itemName=JayFiDev.tablegenerator

A fixed size table snippet is not useful enough to include in core Markdown All in One IMO

https://github.com/microsoft/vscode/pull/131374

VS Code introduces User Snippets just for this case.