mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-29 08:19:34 +08:00
Merge branch 'main' into feature/blockquote-extension
This commit is contained in:
commit
e92da4c966
@ -10,117 +10,91 @@ context('/examples/markdown-shortcuts', () => {
|
||||
|
||||
describe('headlines', () => {
|
||||
it('should make a h1', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('# Headline', {force: true})
|
||||
.contains('h1', 'Headline')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('# Headline', {force: true})
|
||||
.contains('h1', 'Headline')
|
||||
})
|
||||
|
||||
it('should make a h2', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('## Headline', {force: true})
|
||||
.contains('h2', 'Headline')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('## Headline', {force: true})
|
||||
.contains('h2', 'Headline')
|
||||
})
|
||||
|
||||
it('should make a h3', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('### Headline', {force: true})
|
||||
.contains('h3', 'Headline')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('### Headline', {force: true})
|
||||
.contains('h3', 'Headline')
|
||||
})
|
||||
|
||||
it('should make a h4', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('#### Headline', {force: true})
|
||||
.contains('h4', 'Headline')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('#### Headline', {force: true})
|
||||
.contains('h4', 'Headline')
|
||||
})
|
||||
|
||||
it('should make a h5', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('##### Headline', {force: true})
|
||||
.contains('h5', 'Headline')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('##### Headline', {force: true})
|
||||
.contains('h5', 'Headline')
|
||||
})
|
||||
|
||||
it('should make a h6', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('###### Headline', {force: true})
|
||||
.contains('h6', 'Headline')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('###### Headline', {force: true})
|
||||
.contains('h6', 'Headline')
|
||||
})
|
||||
})
|
||||
|
||||
describe('code', () => {
|
||||
it('should create inline code', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('`$foobar`', {force: true})
|
||||
.contains('code', '$foobar')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('`$foobar`', {force: true})
|
||||
.contains('code', '$foobar')
|
||||
})
|
||||
})
|
||||
|
||||
describe('code block', () => {
|
||||
it.skip('should create a code block without language', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('``` {enter}const foo = bar{enter}```', {force: true})
|
||||
.contains('pre', 'const foo = bar')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('``` {enter}const foo = bar{enter}```', {force: true})
|
||||
.contains('pre', 'const foo = bar')
|
||||
})
|
||||
})
|
||||
|
||||
describe('bullet list', () => {
|
||||
it.skip('should create a bullet list from asteriks', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('* foobar', {force: true})
|
||||
.contains('ul', 'foobar')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('* foobar', {force: true})
|
||||
.contains('ul', 'foobar')
|
||||
})
|
||||
|
||||
it.skip('should create a bullet list from dashes', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('- foobar', {force: true})
|
||||
.contains('ul', 'foobar')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('- foobar', {force: true})
|
||||
.contains('ul', 'foobar')
|
||||
})
|
||||
|
||||
it.skip('should create a bullet list from pluses', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('+ foobar', {force: true})
|
||||
.contains('ul', 'foobar')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('+ foobar', {force: true})
|
||||
.contains('ul', 'foobar')
|
||||
})
|
||||
})
|
||||
|
||||
describe('ordered list', () => {
|
||||
it.skip('should create a ordered list', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('1. foobar', {force: true})
|
||||
.contains('ol', 'foobar')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('1. foobar', {force: true})
|
||||
.contains('ol', 'foobar')
|
||||
})
|
||||
})
|
||||
|
||||
describe('blockquote', () => {
|
||||
it.skip('should create a blockquote', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('> foobar', {force: true})
|
||||
.contains('blockquote', 'foobar')
|
||||
})
|
||||
cy.get('.ProseMirror')
|
||||
.type('> foobar', {force: true})
|
||||
.contains('blockquote', 'foobar')
|
||||
})
|
||||
})
|
||||
})
|
@ -21,16 +21,12 @@ context('/api/extensions/bold', () => {
|
||||
})
|
||||
|
||||
it('the keyboard shortcut should make the selected text bold', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true})
|
||||
cy.get('.ProseMirror').type('{meta}b', {force: true})
|
||||
cy.get('.ProseMirror').contains('strong', 'Example Text')
|
||||
})
|
||||
|
||||
it('the keyboard shortcut should toggle the selected text bold', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true}).type(shortcut, {force: true})
|
||||
cy.get('.ProseMirror').type('{meta}b', {force: true}).type('{meta}b', {force: true})
|
||||
cy.get('.ProseMirror strong').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
@ -19,9 +19,7 @@ context('/api/extensions/history', () => {
|
||||
})
|
||||
|
||||
it('the keyboard shortcut should make the last change undone', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}z' : '{ctrl}z'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true})
|
||||
cy.get('.ProseMirror').type('{meta}z', {force: true})
|
||||
cy.get('.ProseMirror').should('not.contain', 'Mistake')
|
||||
})
|
||||
})
|
||||
@ -39,13 +37,10 @@ context('/api/extensions/history', () => {
|
||||
})
|
||||
|
||||
it.skip('the keyboard shortcut should apply the last undone change again', () => {
|
||||
const undoShortcut = Cypress.platform === 'darwin' ? '{meta}z' : '{ctrl}z'
|
||||
const redoShortcut = Cypress.platform === 'darwin' ? '{meta}{shift}z' : '{ctrl}{shift}z'
|
||||
|
||||
cy.get('.ProseMirror').type(undoShortcut, {force: true})
|
||||
cy.get('.ProseMirror').type('{meta}z', {force: true})
|
||||
cy.get('.ProseMirror').should('not.contain', 'Mistake')
|
||||
|
||||
cy.get('.ProseMirror').type(redoShortcut, {force: true})
|
||||
cy.get('.ProseMirror').type('{meta}{shift}z', {force: true})
|
||||
cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||
})
|
||||
})
|
||||
|
@ -21,16 +21,12 @@ context('/api/extensions/italic', () => {
|
||||
})
|
||||
|
||||
it('the keyboard shortcut should make the selected text italic', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}i' : '{ctrl}i'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true})
|
||||
cy.get('.ProseMirror').type('{meta}i', {force: true})
|
||||
cy.get('.ProseMirror').contains('em', 'Example Text')
|
||||
})
|
||||
|
||||
it('the keyboard shortcut should toggle the selected text italic', () => {
|
||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}i' : '{ctrl}i'
|
||||
|
||||
cy.get('.ProseMirror').type(shortcut, {force: true}).type(shortcut, {force: true})
|
||||
cy.get('.ProseMirror').type('{meta}i', {force: true}).type('{meta}i', {force: true})
|
||||
cy.get('.ProseMirror em').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
@ -13,7 +13,7 @@ Type `> ` on the beginning of a new line and it will be magically transformed to
|
||||
| ---------- | ------- | ----------------------------- |
|
||||
| blockquote | — | Wrap content in a blockquote. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* Windows & Linux: `Control` + `Shift` + `9`
|
||||
* macOS: `Command` + `Shift` + `9`
|
||||
|
||||
|
@ -17,7 +17,7 @@ The extension will generate the corresponding `<strong>` HTML tags when reading
|
||||
| ------- | ------- | --------------- |
|
||||
| bold | — | Mark text bold. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* Windows & Linux: `Control` + `B`
|
||||
* macOS: `Command` + `B`
|
||||
|
||||
|
@ -15,7 +15,7 @@ It’s intended to be used with the `ListItem` extension.
|
||||
| ----------- | ------- | --------------------- |
|
||||
| bullet_list | — | Toggle a bullet list. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* `Control` + `Shift` + `8`
|
||||
|
||||
## Usage
|
||||
|
@ -7,5 +7,5 @@ Enables you to use the `<pre>` HTML tag with auto-detected syntax highlighting i
|
||||
## Commands
|
||||
*None*
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
*None*
|
@ -7,5 +7,5 @@ Enables you to use the `<pre>` HTML tag in the editor.
|
||||
## Commands
|
||||
*None*
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
*None*
|
@ -11,7 +11,7 @@ The Code extensions enables you to use the `<code>` HTML tag in the editor. If y
|
||||
| ------- | ------- | ------------------------- |
|
||||
| code | — | Mark text as inline code. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* `Alt` + `
|
||||
|
||||
## Source Code
|
||||
|
@ -4,6 +4,6 @@ Enables you to use the `<br>` HTML tag in the editor.
|
||||
## Options
|
||||
*None*
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* `Command` + `Enter`
|
||||
* `Shift` + `Enter`
|
@ -12,7 +12,7 @@ Enables you to use headline HTML tags in the editor.
|
||||
| ------- | ------- | ----------------------- |
|
||||
| heading | level | Creates a heading node. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* `Control` + `Shift` + `1` → H1
|
||||
* `Control` + `Shift` + `2` → H2
|
||||
* `Control` + `Shift` + `3` → H3
|
||||
|
@ -10,7 +10,7 @@ This extension provides history support. All changes to the document will be tra
|
||||
| undo | — | Undo the last change. |
|
||||
| redo | — | Redo the last change. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* Windows & Linux: `Control` + `Z`
|
||||
* macOS: `Command` + `Z`
|
||||
|
||||
|
@ -11,7 +11,7 @@ Enables you to use the `<hr>` HTML tag in the editor.
|
||||
| --------------- | ------- | ------------------------- |
|
||||
| horizontal_rule | — | Create a horizontal rule. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
*None*
|
||||
|
||||
## Usage
|
||||
|
@ -15,7 +15,7 @@ The extension will generate the corresponding `<em>` HTML tags when reading cont
|
||||
| ------- | ------- | ----------------- |
|
||||
| italic | — | Mark text italic. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* Windows & Linux: `Control` + `I`
|
||||
* macOS: `Command` + `I`
|
||||
|
||||
|
@ -15,7 +15,7 @@ This extensions is intended to be used with the `ListItem` extension.
|
||||
| ------------ | ------- | ----------------------- |
|
||||
| ordered_list | — | Toggle an ordered list. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* `Control` + `Shift` + `9`
|
||||
|
||||
## Usage
|
||||
|
@ -9,7 +9,7 @@ Yes, the schema is very strict. Without this extension you won’t even be able
|
||||
## Commands
|
||||
*None*
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
*None*
|
||||
|
||||
## Source Code
|
||||
|
@ -11,7 +11,7 @@ Enables you to use the `<s>` HTML tag in the editor.
|
||||
| ------- | ------- | --------------------------- |
|
||||
| strike | — | Mark text as strikethrough. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* Windows & Linux: `Control` + `D`
|
||||
* macOS: `Command` + `D`
|
||||
|
||||
|
@ -13,5 +13,5 @@ This extensions is intended to be used with the `TodoList` extension.
|
||||
## Commands
|
||||
*None*
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
*None*
|
@ -13,7 +13,7 @@ This extensions is intended to be used with the `TodoItem` extension.
|
||||
| --------- | ------- | ----------------- |
|
||||
| todo_list | — | Toggle todo list. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
*None*
|
||||
|
||||
## Usage
|
||||
|
@ -11,7 +11,7 @@ Enables you to use the `<u>` HTML tag in the editor.
|
||||
| --------- | ------- | ------------------------ |
|
||||
| underline | — | Mark text as underlined. |
|
||||
|
||||
## Keybindings
|
||||
## Keyboard shortcuts
|
||||
* Windows & Linux: `Control` + `U`
|
||||
* macOS: `Command` + `U`
|
||||
|
||||
|
@ -29,7 +29,7 @@ export default new Mark()
|
||||
],
|
||||
toDOM: () => ['strong', 0],
|
||||
}))
|
||||
.commands(({ editor, name, type }) => ({
|
||||
.commands(({ editor, name }) => ({
|
||||
bold: next => () => {
|
||||
editor.toggleMark(name)
|
||||
next()
|
||||
|
47
packages/extension-strike/index.ts
Normal file
47
packages/extension-strike/index.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { Mark, markInputRule, markPasteRule } from '@tiptap/core'
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface Editor {
|
||||
strike(): Editor,
|
||||
}
|
||||
}
|
||||
|
||||
export const inputRegex = /(?:^|\s)((?:~)((?:[^~]+))(?:~))$/gm
|
||||
export const pasteRegex = /(?:^|\s)((?:~)((?:[^~]+))(?:~))/gm
|
||||
|
||||
export default new Mark()
|
||||
.name('strike')
|
||||
.schema(() => ({
|
||||
parseDOM: [
|
||||
{
|
||||
tag: 's',
|
||||
},
|
||||
{
|
||||
tag: 'del',
|
||||
},
|
||||
{
|
||||
tag: 'strike',
|
||||
},
|
||||
{
|
||||
style: 'text-decoration',
|
||||
getAttrs: node => node === 'line-through' ? {} : false,
|
||||
},
|
||||
],
|
||||
toDOM: () => ['s', 0],
|
||||
}))
|
||||
.commands(({ editor, name }) => ({
|
||||
strike: next => () => {
|
||||
editor.toggleMark(name)
|
||||
next()
|
||||
},
|
||||
}))
|
||||
.keys(({ editor }) => ({
|
||||
'Mod-d': () => editor.strike()
|
||||
}))
|
||||
.inputRules(({ type }) => [
|
||||
markInputRule(inputRegex, type)
|
||||
])
|
||||
.pasteRules(({ type }) => [
|
||||
markPasteRule(inputRegex, type)
|
||||
])
|
||||
.create()
|
17
packages/extension-strike/package.json
Normal file
17
packages/extension-strike/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@tiptap/extension-strike",
|
||||
"version": "1.0.0",
|
||||
"source": "index.ts",
|
||||
"main": "dist/tiptap-extension-strike.js",
|
||||
"umd:main": "dist/tiptap-extension-strike.umd.js",
|
||||
"module": "dist/tiptap-extension-strike.mjs",
|
||||
"unpkg": "dist/tiptap-extension-strike.js",
|
||||
"jsdelivr": "dist/tiptap-extension-strike.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "2.x"
|
||||
}
|
||||
}
|
32
packages/extension-underline/index.ts
Normal file
32
packages/extension-underline/index.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { Mark } from '@tiptap/core'
|
||||
|
||||
declare module '@tiptap/core/src/Editor' {
|
||||
interface Editor {
|
||||
underline(): Editor,
|
||||
}
|
||||
}
|
||||
|
||||
export default new Mark()
|
||||
.name('underline')
|
||||
.schema(() => ({
|
||||
parseDOM: [
|
||||
{
|
||||
tag: 'u',
|
||||
},
|
||||
{
|
||||
style: 'text-decoration',
|
||||
getAttrs: node => node === 'underline' ? {} : false,
|
||||
},
|
||||
],
|
||||
toDOM: () => ['u', 0],
|
||||
}))
|
||||
.commands(({ editor, name }) => ({
|
||||
underline: next => () => {
|
||||
editor.toggleMark(name)
|
||||
next()
|
||||
},
|
||||
}))
|
||||
.keys(({ editor }) => ({
|
||||
'Mod-u': () => editor.underline()
|
||||
}))
|
||||
.create()
|
17
packages/extension-underline/package.json
Normal file
17
packages/extension-underline/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@tiptap/extension-underline",
|
||||
"version": "1.0.0",
|
||||
"source": "index.ts",
|
||||
"main": "dist/tiptap-extension-underline.js",
|
||||
"umd:main": "dist/tiptap-extension-underline.umd.js",
|
||||
"module": "dist/tiptap-extension-underline.mjs",
|
||||
"unpkg": "dist/tiptap-extension-underline.js",
|
||||
"jsdelivr": "dist/tiptap-extension-underline.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "2.x"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user