Merge branch 'main' into feature/blockquote-extension
This commit is contained in:
@@ -10,117 +10,91 @@ context('/examples/markdown-shortcuts', () => {
|
|||||||
|
|
||||||
describe('headlines', () => {
|
describe('headlines', () => {
|
||||||
it('should make a h1', () => {
|
it('should make a h1', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('# Headline', {force: true})
|
||||||
.type('# Headline', {force: true})
|
.contains('h1', 'Headline')
|
||||||
.contains('h1', 'Headline')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make a h2', () => {
|
it('should make a h2', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('## Headline', {force: true})
|
||||||
.type('## Headline', {force: true})
|
.contains('h2', 'Headline')
|
||||||
.contains('h2', 'Headline')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make a h3', () => {
|
it('should make a h3', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('### Headline', {force: true})
|
||||||
.type('### Headline', {force: true})
|
.contains('h3', 'Headline')
|
||||||
.contains('h3', 'Headline')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make a h4', () => {
|
it('should make a h4', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('#### Headline', {force: true})
|
||||||
.type('#### Headline', {force: true})
|
.contains('h4', 'Headline')
|
||||||
.contains('h4', 'Headline')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make a h5', () => {
|
it('should make a h5', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('##### Headline', {force: true})
|
||||||
.type('##### Headline', {force: true})
|
.contains('h5', 'Headline')
|
||||||
.contains('h5', 'Headline')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make a h6', () => {
|
it('should make a h6', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('###### Headline', {force: true})
|
||||||
.type('###### Headline', {force: true})
|
.contains('h6', 'Headline')
|
||||||
.contains('h6', 'Headline')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('code', () => {
|
describe('code', () => {
|
||||||
it('should create inline code', () => {
|
it('should create inline code', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('`$foobar`', {force: true})
|
||||||
.type('`$foobar`', {force: true})
|
.contains('code', '$foobar')
|
||||||
.contains('code', '$foobar')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('code block', () => {
|
describe('code block', () => {
|
||||||
it.skip('should create a code block without language', () => {
|
it.skip('should create a code block without language', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('``` {enter}const foo = bar{enter}```', {force: true})
|
||||||
.type('``` {enter}const foo = bar{enter}```', {force: true})
|
.contains('pre', 'const foo = bar')
|
||||||
.contains('pre', 'const foo = bar')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('bullet list', () => {
|
describe('bullet list', () => {
|
||||||
it.skip('should create a bullet list from asteriks', () => {
|
it.skip('should create a bullet list from asteriks', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('* foobar', {force: true})
|
||||||
.type('* foobar', {force: true})
|
.contains('ul', 'foobar')
|
||||||
.contains('ul', 'foobar')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('should create a bullet list from dashes', () => {
|
it.skip('should create a bullet list from dashes', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('- foobar', {force: true})
|
||||||
.type('- foobar', {force: true})
|
.contains('ul', 'foobar')
|
||||||
.contains('ul', 'foobar')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('should create a bullet list from pluses', () => {
|
it.skip('should create a bullet list from pluses', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('+ foobar', {force: true})
|
||||||
.type('+ foobar', {force: true})
|
.contains('ul', 'foobar')
|
||||||
.contains('ul', 'foobar')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('ordered list', () => {
|
describe('ordered list', () => {
|
||||||
it.skip('should create a ordered list', () => {
|
it.skip('should create a ordered list', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('1. foobar', {force: true})
|
||||||
.type('1. foobar', {force: true})
|
.contains('ol', 'foobar')
|
||||||
.contains('ol', 'foobar')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('blockquote', () => {
|
describe('blockquote', () => {
|
||||||
it.skip('should create a blockquote', () => {
|
it.skip('should create a blockquote', () => {
|
||||||
cy.get('.ProseMirror').window().then(window => {
|
cy.get('.ProseMirror')
|
||||||
cy.get('.ProseMirror')
|
.type('> foobar', {force: true})
|
||||||
.type('> foobar', {force: true})
|
.contains('blockquote', 'foobar')
|
||||||
.contains('blockquote', 'foobar')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -21,16 +21,12 @@ context('/api/extensions/bold', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('the keyboard shortcut should make the selected text bold', () => {
|
it('the keyboard shortcut should make the selected text bold', () => {
|
||||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b'
|
cy.get('.ProseMirror').type('{meta}b', {force: true})
|
||||||
|
|
||||||
cy.get('.ProseMirror').type(shortcut, {force: true})
|
|
||||||
cy.get('.ProseMirror').contains('strong', 'Example Text')
|
cy.get('.ProseMirror').contains('strong', 'Example Text')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('the keyboard shortcut should toggle the selected text bold', () => {
|
it('the keyboard shortcut should toggle the selected text bold', () => {
|
||||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b'
|
cy.get('.ProseMirror').type('{meta}b', {force: true}).type('{meta}b', {force: true})
|
||||||
|
|
||||||
cy.get('.ProseMirror').type(shortcut, {force: true}).type(shortcut, {force: true})
|
|
||||||
cy.get('.ProseMirror strong').should('not.exist')
|
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', () => {
|
it('the keyboard shortcut should make the last change undone', () => {
|
||||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}z' : '{ctrl}z'
|
cy.get('.ProseMirror').type('{meta}z', {force: true})
|
||||||
|
|
||||||
cy.get('.ProseMirror').type(shortcut, {force: true})
|
|
||||||
cy.get('.ProseMirror').should('not.contain', 'Mistake')
|
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', () => {
|
it.skip('the keyboard shortcut should apply the last undone change again', () => {
|
||||||
const undoShortcut = Cypress.platform === 'darwin' ? '{meta}z' : '{ctrl}z'
|
cy.get('.ProseMirror').type('{meta}z', {force: true})
|
||||||
const redoShortcut = Cypress.platform === 'darwin' ? '{meta}{shift}z' : '{ctrl}{shift}z'
|
|
||||||
|
|
||||||
cy.get('.ProseMirror').type(undoShortcut, {force: true})
|
|
||||||
cy.get('.ProseMirror').should('not.contain', 'Mistake')
|
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')
|
cy.get('.ProseMirror').should('contain', 'Mistake')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,16 +21,12 @@ context('/api/extensions/italic', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('the keyboard shortcut should make the selected text italic', () => {
|
it('the keyboard shortcut should make the selected text italic', () => {
|
||||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}i' : '{ctrl}i'
|
cy.get('.ProseMirror').type('{meta}i', {force: true})
|
||||||
|
|
||||||
cy.get('.ProseMirror').type(shortcut, {force: true})
|
|
||||||
cy.get('.ProseMirror').contains('em', 'Example Text')
|
cy.get('.ProseMirror').contains('em', 'Example Text')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('the keyboard shortcut should toggle the selected text italic', () => {
|
it('the keyboard shortcut should toggle the selected text italic', () => {
|
||||||
const shortcut = Cypress.platform === 'darwin' ? '{meta}i' : '{ctrl}i'
|
cy.get('.ProseMirror').type('{meta}i', {force: true}).type('{meta}i', {force: true})
|
||||||
|
|
||||||
cy.get('.ProseMirror').type(shortcut, {force: true}).type(shortcut, {force: true})
|
|
||||||
cy.get('.ProseMirror em').should('not.exist')
|
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. |
|
| blockquote | — | Wrap content in a blockquote. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* Windows & Linux: `Control` + `Shift` + `9`
|
* Windows & Linux: `Control` + `Shift` + `9`
|
||||||
* macOS: `Command` + `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. |
|
| bold | — | Mark text bold. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* Windows & Linux: `Control` + `B`
|
* Windows & Linux: `Control` + `B`
|
||||||
* macOS: `Command` + `B`
|
* macOS: `Command` + `B`
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ It’s intended to be used with the `ListItem` extension.
|
|||||||
| ----------- | ------- | --------------------- |
|
| ----------- | ------- | --------------------- |
|
||||||
| bullet_list | — | Toggle a bullet list. |
|
| bullet_list | — | Toggle a bullet list. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* `Control` + `Shift` + `8`
|
* `Control` + `Shift` + `8`
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ Enables you to use the `<pre>` HTML tag with auto-detected syntax highlighting i
|
|||||||
## Commands
|
## Commands
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
*None*
|
*None*
|
||||||
@@ -7,5 +7,5 @@ Enables you to use the `<pre>` HTML tag in the editor.
|
|||||||
## Commands
|
## Commands
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
*None*
|
*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. |
|
| code | — | Mark text as inline code. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* `Alt` + `
|
* `Alt` + `
|
||||||
|
|
||||||
## Source Code
|
## Source Code
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ Enables you to use the `<br>` HTML tag in the editor.
|
|||||||
## Options
|
## Options
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* `Command` + `Enter`
|
* `Command` + `Enter`
|
||||||
* `Shift` + `Enter`
|
* `Shift` + `Enter`
|
||||||
@@ -12,7 +12,7 @@ Enables you to use headline HTML tags in the editor.
|
|||||||
| ------- | ------- | ----------------------- |
|
| ------- | ------- | ----------------------- |
|
||||||
| heading | level | Creates a heading node. |
|
| heading | level | Creates a heading node. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* `Control` + `Shift` + `1` → H1
|
* `Control` + `Shift` + `1` → H1
|
||||||
* `Control` + `Shift` + `2` → H2
|
* `Control` + `Shift` + `2` → H2
|
||||||
* `Control` + `Shift` + `3` → H3
|
* `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. |
|
| undo | — | Undo the last change. |
|
||||||
| redo | — | Redo the last change. |
|
| redo | — | Redo the last change. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* Windows & Linux: `Control` + `Z`
|
* Windows & Linux: `Control` + `Z`
|
||||||
* macOS: `Command` + `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. |
|
| horizontal_rule | — | Create a horizontal rule. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ The extension will generate the corresponding `<em>` HTML tags when reading cont
|
|||||||
| ------- | ------- | ----------------- |
|
| ------- | ------- | ----------------- |
|
||||||
| italic | — | Mark text italic. |
|
| italic | — | Mark text italic. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* Windows & Linux: `Control` + `I`
|
* Windows & Linux: `Control` + `I`
|
||||||
* macOS: `Command` + `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. |
|
| ordered_list | — | Toggle an ordered list. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* `Control` + `Shift` + `9`
|
* `Control` + `Shift` + `9`
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Yes, the schema is very strict. Without this extension you won’t even be able
|
|||||||
## Commands
|
## Commands
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Source Code
|
## Source Code
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Enables you to use the `<s>` HTML tag in the editor.
|
|||||||
| ------- | ------- | --------------------------- |
|
| ------- | ------- | --------------------------- |
|
||||||
| strike | — | Mark text as strikethrough. |
|
| strike | — | Mark text as strikethrough. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* Windows & Linux: `Control` + `D`
|
* Windows & Linux: `Control` + `D`
|
||||||
* macOS: `Command` + `D`
|
* macOS: `Command` + `D`
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ This extensions is intended to be used with the `TodoList` extension.
|
|||||||
## Commands
|
## Commands
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
*None*
|
*None*
|
||||||
@@ -13,7 +13,7 @@ This extensions is intended to be used with the `TodoItem` extension.
|
|||||||
| --------- | ------- | ----------------- |
|
| --------- | ------- | ----------------- |
|
||||||
| todo_list | — | Toggle todo list. |
|
| todo_list | — | Toggle todo list. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
*None*
|
*None*
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Enables you to use the `<u>` HTML tag in the editor.
|
|||||||
| --------- | ------- | ------------------------ |
|
| --------- | ------- | ------------------------ |
|
||||||
| underline | — | Mark text as underlined. |
|
| underline | — | Mark text as underlined. |
|
||||||
|
|
||||||
## Keybindings
|
## Keyboard shortcuts
|
||||||
* Windows & Linux: `Control` + `U`
|
* Windows & Linux: `Control` + `U`
|
||||||
* macOS: `Command` + `U`
|
* macOS: `Command` + `U`
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default new Mark()
|
|||||||
],
|
],
|
||||||
toDOM: () => ['strong', 0],
|
toDOM: () => ['strong', 0],
|
||||||
}))
|
}))
|
||||||
.commands(({ editor, name, type }) => ({
|
.commands(({ editor, name }) => ({
|
||||||
bold: next => () => {
|
bold: next => () => {
|
||||||
editor.toggleMark(name)
|
editor.toggleMark(name)
|
||||||
next()
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user