-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2235 from nextcloud/feature/114/tables
Feature/114/tables
- Loading branch information
Showing
62 changed files
with
1,460 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
## Preserve Tables | ||
|
||
This is a table | ||
|
||
| Header | other Header | | ||
|--------|--------------| | ||
| Cell | other cell | | ||
| Cell | other cell | | ||
|
||
--- | ||
|
||
This is a table | ||
|
||
| Header | other Header | | ||
|--------|--------------| | ||
| Cell | other cell | | ||
| Cell | other cell | | ||
|
||
## Create a table | ||
|
||
insertTable | ||
|
||
--- | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | | | ||
|
||
did insertTable | ||
|
||
## Create second tables | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | | | ||
|
||
insertTable | ||
|
||
--- | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | | | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | | | ||
|
||
did insertTable | ||
|
||
## Add a new row at the end | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | addRowAfter | | ||
|
||
|
||
--- | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | did addRowAfter | | ||
| | | | | ||
|
||
## Add a new column at the end | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | addColumnAfter | | ||
|
||
|
||
--- | ||
|
||
| | | | | | ||
|--|--|--|--| | ||
| | | | | | ||
| | | did addColumnAfter | | | ||
|
||
## Delete row at the end | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | deleteRow | | ||
|
||
|
||
--- | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
|
||
## Delete column at the end | ||
|
||
| | | | | ||
|--|--|--| | ||
| | | | | ||
| | | deleteColumn | | ||
|
||
|
||
--- | ||
|
||
| | | | ||
|--|--| | ||
| | | | ||
| | | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import Table from './../../src/nodes/Table' | ||
import TableCell from './../../src/nodes/TableCell' | ||
import TableHeader from './../../src/nodes/TableHeader' | ||
import TableRow from './../../src/nodes/TableRow' | ||
import TableHeadRow from './../../src/nodes/TableHeadRow' | ||
import Markdown from './../../src/extensions/Markdown' | ||
import markdownit from './../../src/markdownit' | ||
import { createMarkdownSerializer } from './../../src/extensions/Markdown'; | ||
import { findChildren, findChildrenByType } from 'prosemirror-utils' | ||
import createEditor from './../../src/tests/createEditor' | ||
import testData from '../fixtures/Table.md' | ||
|
||
describe('ListItem extension integrated in the editor', () => { | ||
|
||
const editor = createEditor({ | ||
content: '', | ||
extensions: [ | ||
Markdown, | ||
Table, | ||
TableCell, | ||
TableHeader, | ||
TableHeadRow, | ||
TableRow, | ||
], | ||
}) | ||
|
||
for (const spec of testData.split(/#+\s+/)){ | ||
const [description, ...rest] = spec.split(/\n/) | ||
const [input, output] = rest.join('\n').split(/\n\n---\n\n/) | ||
if (!description) { | ||
continue | ||
} | ||
it(description, () => { | ||
expect(spec).to.include('\n') | ||
expect(input).to.be.ok | ||
expect(output).to.be.ok | ||
loadMarkdown(input) | ||
runCommands() | ||
expectMarkdown(output.replace(/\n*$/, '')) | ||
}) | ||
} | ||
|
||
function loadMarkdown(markdown) { | ||
editor.commands.setContent(markdownit.render(markdown)) | ||
} | ||
|
||
function runCommands() { | ||
let found | ||
while (found = findCommand()) { | ||
const name = found.node.text | ||
editor.commands.setTextSelection(found.pos) | ||
editor.commands[name]() | ||
const updated = findCommand() | ||
if (updated) { | ||
editor.commands.setTextSelection(updated.pos) | ||
editor.commands.insertContent('did ') | ||
} | ||
} | ||
} | ||
|
||
function findCommand() { | ||
const doc = editor.state.doc | ||
return findChildren(doc, child => { | ||
return child.isText && editor.commands.hasOwnProperty(child.text) | ||
})[0] | ||
} | ||
|
||
function expectMarkdown(markdown) { | ||
expect(getMarkdown().replace(/\n$/, '')).to.equal(markdown) | ||
} | ||
|
||
function getMarkdown() { | ||
const serializer = createMarkdownSerializer(editor.schema) | ||
return serializer.serialize(editor.state.doc) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.