Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax <max@nextcloud.com>2022-02-15 10:02:07 +0300
committerMax <max@nextcloud.com>2022-03-02 15:26:11 +0300
commit0afc3236c2d773791de05d457367c73faf113ca0 (patch)
treee6c78d3228e7b915645e605f5cf414f6002a160b /cypress
parent69a9acce3a66b13dd7a22d2eef3b2e285ec91a71 (diff)
fix: indicator of the task list.
See #2018. Use tiptap TaskList and TaskItem. Markdown-it happily mixes tasks and bullet points in the same list. Tiptap lists are strictly separated. Split bullet and tasks into BulletList and TaskList in markdown-io. Just like this will turn into three different lists: * one - two + three This will now also turn into three different lists with the middle one being a task list: * first list * [ ] todo * [x] done * third list Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'cypress')
-rw-r--r--cypress/fixtures/ListItem.md97
-rw-r--r--cypress/integration/ListItem.spec.js27
-rw-r--r--cypress/integration/workspace.spec.js19
3 files changed, 117 insertions, 26 deletions
diff --git a/cypress/fixtures/ListItem.md b/cypress/fixtures/ListItem.md
index 97ff201f8..7e59ca711 100644
--- a/cypress/fixtures/ListItem.md
+++ b/cypress/fixtures/ListItem.md
@@ -1,62 +1,121 @@
-## creates todo lists
+## Keeps homogeneous lists together
-* todo\_item
+* foo
+* bar
+
+1. one
+2. two
+
+* [ ] todo
+* [x] done
+
+---
+
+* foo
+* bar
+
+1. one
+2. two
+
+* [ ] todo
+* [x] done
+
+## Splits mixed lists with empty lines
+
+* foo
+* bar
+* [ ] todo
+* [x] done
+1. one
+2. two
+
+---
+
+* foo
+* bar
+
+* [ ] todo
+* [x] done
+
+1. one
+2. two
+
+## bullet list to task list
+
+* toggleTaskList
+* keep
---
-* [ ] todo\_item
+* [ ] did toggleTaskList
+
+* keep
-## removes the list when toggling todo off
+## bullet list to ordered list
-* [ ] todo\_item
+* toggleOrderedList
+* keep
---
-todo\_item
+1. did toggleOrderedList
+2. keep
+
+
+## removes the list when toggling task off
+
+* [ ] toggleTaskList
+
+---
+
+did toggleTaskList
## creates a bullet list
-bulletListItem
+toggleBulletList
---
-* bulletListItem
+* did toggleBulletList
-## only toggles one list item
+## Splits bullet list when turning one item into task
-* todo\_item
+* toggleTaskList
* not todo
---
-* [ ] todo\_item
+* [ ] did toggleTaskList
+
* not todo
## toggles two list items separately
-* todo\_item
+* toggleTaskList
* not todo
-* todo\_item
+* toggleTaskList
---
-* [ ] todo\_item
+* [ ] did toggleTaskList
+
* not todo
-* [ ] todo\_item
-## toggle off todo list item should turn it into normal list item
+* [ ] did toggleTaskList
+
+## toggle off task list item should turn it into normal list item
* not todo
-* [ ] todo\_item
+* [ ] toggleTaskList
---
* not todo
-todo\_item
+did toggleTaskList
---
* not todo
-* todo\_item
+* toggleTaskList
diff --git a/cypress/integration/ListItem.spec.js b/cypress/integration/ListItem.spec.js
index dd0c95a87..c45a8b2cc 100644
--- a/cypress/integration/ListItem.spec.js
+++ b/cypress/integration/ListItem.spec.js
@@ -1,5 +1,8 @@
+import OrderedList from '@tiptap/extension-ordered-list'
+import ListItem from '@tiptap/extension-list-item'
+import TaskList from './../../src/nodes/TaskList'
+import TaskItem from './../../src/nodes/TaskItem'
import BulletList from './../../src/nodes/BulletList'
-import ListItem from './../../src/nodes/ListItem'
import Markdown from './../../src/extensions/Markdown'
import markdownit from './../../src/markdownit'
import { createMarkdownSerializer } from './../../src/extensions/Markdown';
@@ -11,7 +14,14 @@ describe('ListItem extension integrated in the editor', () => {
const editor = createEditor({
content: '',
- extensions: [Markdown, BulletList, ListItem],
+ extensions: [
+ Markdown,
+ BulletList,
+ OrderedList,
+ ListItem,
+ TaskList,
+ TaskItem,
+ ],
})
for (const spec of testData.split(/#+\s+/)){
@@ -36,18 +46,21 @@ describe('ListItem extension integrated in the editor', () => {
}
function runCommands() {
- for (const { node, pos } of findCommands()) {
- const command = node.text
+ let found
+ while (found = findCommand()) {
+ const { node, pos } = found
+ const name = node.text
editor.commands.setTextSelection(pos)
- editor.commands[command]()
+ editor.commands[name]()
+ editor.commands.insertContent('did ')
}
}
- function findCommands() {
+ function findCommand() {
const doc = editor.state.doc
return findChildren(doc, child => {
return child.isText && editor.commands.hasOwnProperty(child.text)
- })
+ })[0]
}
function expectMarkdown(markdown) {
diff --git a/cypress/integration/workspace.spec.js b/cypress/integration/workspace.spec.js
index efa3e5953..01829cd7c 100644
--- a/cypress/integration/workspace.spec.js
+++ b/cypress/integration/workspace.spec.js
@@ -104,6 +104,25 @@ describe('Workspace', function() {
})
})
+ it('creates lists', function() {
+ openWorkspace()
+ .type('List me')
+ .type('{selectall}')
+ ;[
+ ['ul', 'ul'],
+ ['ol', 'ol'],
+ ['checkmark', 'ul[data-type="taskList"]'],
+ ].forEach(([button, tag]) => {
+ menuButton(button)
+ .click()
+ .should('have.class', 'is-active')
+ cy.get(`.ProseMirror ${tag}`).should('contain', 'List me')
+ menuButton(button)
+ .click()
+ .should('not.have.class', 'is-active')
+ })
+ })
+
it('takes README.md into account', function() {
cy.uploadFile('test.md', 'text/markdown', `${Cypress.currentTest.title}/README.md`)
cy.reload()