Merge branch 'main' of github.com:ueberdosis/tiptap-next into main
This commit is contained in:
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2.3.3
|
- uses: actions/checkout@v2.3.3
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2.1.1
|
uses: actions/setup-node@v2.1.2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2.3.3
|
- uses: actions/checkout@v2.3.3
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2.1.1
|
uses: actions/setup-node@v2.1.2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
@@ -87,14 +87,14 @@ jobs:
|
|||||||
browser: chrome
|
browser: chrome
|
||||||
|
|
||||||
- name: Export screenshots (on failure only)
|
- name: Export screenshots (on failure only)
|
||||||
uses: actions/upload-artifact@v2.1.4
|
uses: actions/upload-artifact@v2.2.0
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: cypress-screenshots
|
name: cypress-screenshots
|
||||||
path: tests/cypress/screenshots
|
path: tests/cypress/screenshots
|
||||||
|
|
||||||
- name: Export screen recordings (on failure only)
|
- name: Export screen recordings (on failure only)
|
||||||
uses: actions/upload-artifact@v2.1.4
|
uses: actions/upload-artifact@v2.2.0
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: cypress-videos
|
name: cypress-videos
|
||||||
@@ -125,7 +125,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2.3.3
|
- uses: actions/checkout@v2.3.3
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2.1.1
|
uses: actions/setup-node@v2.1.2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ context('/examples/focus', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should have class', () => {
|
it('should have class', () => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
|
||||||
editor.focus('start')
|
|
||||||
|
|
||||||
cy.get('.ProseMirror p:first').should('have.class', 'has-focus')
|
cy.get('.ProseMirror p:first').should('have.class', 'has-focus')
|
||||||
})
|
})
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="editor">
|
<div>
|
||||||
<editor-content :editor="editor" />
|
<editor-content :editor="editor" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -58,17 +58,6 @@ context('/api/extensions/code-block', () => {
|
|||||||
.should('not.exist')
|
.should('not.exist')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make a code block from markdown shortcuts', () => {
|
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
|
||||||
editor.clearContent()
|
|
||||||
|
|
||||||
cy.get('.ProseMirror')
|
|
||||||
.type('``` Code')
|
|
||||||
.find('pre>code')
|
|
||||||
.should('contain', 'Code')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should parse the language from a HTML code block', () => {
|
it('should parse the language from a HTML code block', () => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
editor.setContent('<pre><code class="language-css">body { display: none; }</code></pre>')
|
editor.setContent('<pre><code class="language-css">body { display: none; }</code></pre>')
|
||||||
@@ -79,7 +68,29 @@ context('/api/extensions/code-block', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make a code block for js', () => {
|
it('should make a code block from backtick markdown shortcuts', () => {
|
||||||
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
|
editor.clearContent()
|
||||||
|
|
||||||
|
cy.get('.ProseMirror')
|
||||||
|
.type('``` Code')
|
||||||
|
.find('pre>code')
|
||||||
|
.should('contain', 'Code')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should make a code block from tilde markdown shortcuts', () => {
|
||||||
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
|
editor.clearContent()
|
||||||
|
|
||||||
|
cy.get('.ProseMirror')
|
||||||
|
.type('~~~ Code')
|
||||||
|
.find('pre>code')
|
||||||
|
.should('contain', 'Code')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should make a code block for js with backticks', () => {
|
||||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
editor.clearContent()
|
editor.clearContent()
|
||||||
|
|
||||||
@@ -89,4 +100,15 @@ context('/api/extensions/code-block', () => {
|
|||||||
.should('contain', 'Code')
|
.should('contain', 'Code')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should make a code block for js with tildes', () => {
|
||||||
|
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||||
|
editor.clearContent()
|
||||||
|
|
||||||
|
cy.get('.ProseMirror')
|
||||||
|
.type('~~~js Code')
|
||||||
|
.find('pre>code.language-js')
|
||||||
|
.should('contain', 'Code')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ context('/api/extensions/strike', () => {
|
|||||||
|
|
||||||
it('should make a striked text from the markdown shortcut', () => {
|
it('should make a striked text from the markdown shortcut', () => {
|
||||||
cy.get('.ProseMirror')
|
cy.get('.ProseMirror')
|
||||||
.type('~Strike~')
|
.type('~~Strike~~')
|
||||||
.find('s')
|
.find('s')
|
||||||
.should('contain', 'Strike')
|
.should('contain', 'Strike')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# CodeBlock
|
# CodeBlock
|
||||||
With the CodeBlock extension you can add fenced code blocks to your documents. It’ll wrap the code in `<pre>` and `<code>` HTML tags.
|
With the CodeBlock extension you can add fenced code blocks to your documents. It’ll wrap the code in `<pre>` and `<code>` HTML tags.
|
||||||
|
|
||||||
Type three backticks and a space <code>```</code> and a code block is instantly added for you.
|
Type <code>``` </code> (three backticks and a space) or <code>∼∼∼ </code> (three tildes and a space) and a code block is instantly added for you. You can even specify the language, try writing <code>```css </code>. That should add a `language-css` class to the `<code>`-tag.
|
||||||
|
|
||||||
::: warning Restrictions
|
::: warning Restrictions
|
||||||
The CodeBlock extension doesn’t come with styling and has no syntax highlighting built-in. It’s on our roadmap though.
|
The CodeBlock extension doesn’t come with styling and has no syntax highlighting built-in. It’s on our roadmap though.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Strike
|
# Strike
|
||||||
Use this extension to render ~~striked text~~. If you pass `<s>`, `<del>`, `<strike>` tags, or text with inline `style` attributes setting `text-decoration: line-through` in the editor’s initial content, they all will be rendered accordingly.
|
Use this extension to render ~~striked text~~. If you pass `<s>`, `<del>`, `<strike>` tags, or text with inline `style` attributes setting `text-decoration: line-through` in the editor’s initial content, they all will be rendered accordingly.
|
||||||
|
|
||||||
Type <code>~text between tildes~</code> and it will be magically ~~striked through~~ while you type.
|
Type <code>∼∼text between tildes∼∼</code> and it will be magically ~~striked through~~ while you type.
|
||||||
|
|
||||||
::: warning Restrictions
|
::: warning Restrictions
|
||||||
The extension will generate the corresponding `<s>` HTML tags when reading contents of the `Editor` instance. All text striked through, regardless of the method will be normalized to `<s>` HTML tags.
|
The extension will generate the corresponding `<s>` HTML tags when reading contents of the `Editor` instance. All text striked through, regardless of the method will be normalized to `<s>` HTML tags.
|
||||||
|
|||||||
@@ -56,8 +56,8 @@
|
|||||||
# - title: Placeholder
|
# - title: Placeholder
|
||||||
# link: /examples/placeholder
|
# link: /examples/placeholder
|
||||||
# draft: true
|
# draft: true
|
||||||
# - title: Focus
|
- title: Focus
|
||||||
# link: /examples/focus
|
link: /examples/focus
|
||||||
# - title: Title
|
# - title: Title
|
||||||
# link: /examples/title
|
# link: /examples/title
|
||||||
# draft: true
|
# draft: true
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export class Editor extends EventEmitter {
|
|||||||
this.registerCommands(coreCommands)
|
this.registerCommands(coreCommands)
|
||||||
this.injectCSS()
|
this.injectCSS()
|
||||||
|
|
||||||
this.proxy.focus(this.options.autoFocus)
|
window.setTimeout(() => this.proxy.focus(this.options.autoFocus), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ declare module '@tiptap/core/src/Editor' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inputRegex = /^```(?<language>[a-z]*)? $/
|
export const backtickInputRegex = /^```(?<language>[a-z]*)? $/
|
||||||
|
export const tildeInputRegex = /^~~~(?<language>[a-z]*)? $/
|
||||||
|
|
||||||
export default new Node<CodeBlockOptions>()
|
export default new Node<CodeBlockOptions>()
|
||||||
.name('code_block')
|
.name('code_block')
|
||||||
@@ -62,6 +63,7 @@ export default new Node<CodeBlockOptions>()
|
|||||||
'Shift-Control-\\': () => editor.codeBlock(),
|
'Shift-Control-\\': () => editor.codeBlock(),
|
||||||
}))
|
}))
|
||||||
.inputRules(({ type }) => [
|
.inputRules(({ type }) => [
|
||||||
textblockTypeInputRule(inputRegex, type, ({ groups }: any) => groups),
|
textblockTypeInputRule(backtickInputRegex, type, ({ groups }: any) => groups),
|
||||||
|
textblockTypeInputRule(tildeInputRegex, type, ({ groups }: any) => groups),
|
||||||
])
|
])
|
||||||
.create()
|
.create()
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ declare module '@tiptap/core/src/Editor' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inputRegex = /(?:^|\s)((?:~)((?:[^~]+))(?:~))$/gm
|
export const inputRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))$/gm
|
||||||
export const pasteRegex = /(?:^|\s)((?:~)((?:[^~]+))(?:~))/gm
|
export const pasteRegex = /(?:^|\s)((?:~~)((?:[^~]+))(?:~~))/gm
|
||||||
|
|
||||||
export default new Mark()
|
export default new Mark()
|
||||||
.name('strike')
|
.name('strike')
|
||||||
|
|||||||
Reference in New Issue
Block a user