diff --git a/demos/src/Marks/Bold/Vue/index.html b/demos/src/Marks/Bold/Vue/index.html new file mode 100644 index 00000000..af5ade7d --- /dev/null +++ b/demos/src/Marks/Bold/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Bold/Vue/index.spec.js b/demos/src/Marks/Bold/Vue/index.spec.js new file mode 100644 index 00000000..0a891146 --- /dev/null +++ b/demos/src/Marks/Bold/Vue/index.spec.js @@ -0,0 +1,91 @@ +context('/demos/Marks/Bold', () => { + before(() => { + cy.visit('/demos/Marks/Bold') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('should transform b tags to strong tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('sould omit b tags with normal font weight inline style', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should transform any tag with bold inline style to strong tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('the button should make the selected text bold', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('strong') + .should('contain', 'Example Text') + }) + + it('the button should toggle the selected text bold', () => { + cy.get('button:first').click() + cy.get('.ProseMirror').type('{selectall}') + cy.get('button:first').click() + cy.get('.ProseMirror strong').should('not.exist') + }) + + it('should make the selected text bold when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'b' }) + .find('strong') + .should('contain', 'Example Text') + }) + + it('should toggle the selected text bold when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'b' }) + .find('strong') + .should('contain', 'Example Text') + + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'b' }) + + cy.get('.ProseMirror strong').should('not.exist') + }) + + it('should make a bold text from the default markdown shortcut', () => { + cy.get('.ProseMirror') + .type('**Bold**') + .find('strong') + .should('contain', 'Bold') + }) + + it('should make a bold text from the alternative markdown shortcut', () => { + cy.get('.ProseMirror') + .type('__Bold__') + .find('strong') + .should('contain', 'Bold') + }) +}) diff --git a/demos/src/Marks/Bold/Vue/index.vue b/demos/src/Marks/Bold/Vue/index.vue new file mode 100644 index 00000000..4d70b531 --- /dev/null +++ b/demos/src/Marks/Bold/Vue/index.vue @@ -0,0 +1,53 @@ + + + diff --git a/demos/src/Marks/Code/Vue/index.html b/demos/src/Marks/Code/Vue/index.html new file mode 100644 index 00000000..a9f0261d --- /dev/null +++ b/demos/src/Marks/Code/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Code/Vue/index.spec.js b/demos/src/Marks/Code/Vue/index.spec.js new file mode 100644 index 00000000..508d2a18 --- /dev/null +++ b/demos/src/Marks/Code/Vue/index.spec.js @@ -0,0 +1,71 @@ +context('/demos/Marks/Code', () => { + before(() => { + cy.visit('/demos/Marks/Code') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('should parse code tags correctly', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + + editor.commands.setContent('Example Text') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should mark the selected text as inline code', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('code') + .should('contain', 'Example Text') + }) + + it('should toggle the selected text as inline code', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .type('{selectall}') + + cy.get('button:first') + .click() + + cy.get('.ProseMirror code') + .should('not.exist') + }) + + it('should make the selected text bold when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'e' }) + .find('code') + .should('contain', 'Example Text') + }) + + it('should toggle the selected text bold when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'e' }) + .find('code') + .should('contain', 'Example Text') + + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'e' }) + + cy.get('.ProseMirror code').should('not.exist') + }) + + it('should make inline code from the markdown shortcut', () => { + cy.get('.ProseMirror') + .type('`Example`') + .find('code') + .should('contain', 'Example') + }) +}) diff --git a/demos/src/Marks/Code/Vue/index.vue b/demos/src/Marks/Code/Vue/index.vue new file mode 100644 index 00000000..45629c11 --- /dev/null +++ b/demos/src/Marks/Code/Vue/index.vue @@ -0,0 +1,48 @@ + + + diff --git a/demos/src/Marks/Highlight/Vue/index.html b/demos/src/Marks/Highlight/Vue/index.html new file mode 100644 index 00000000..2f5a9a26 --- /dev/null +++ b/demos/src/Marks/Highlight/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Highlight/Vue/index.spec.js b/demos/src/Marks/Highlight/Vue/index.spec.js new file mode 100644 index 00000000..7e0b74dc --- /dev/null +++ b/demos/src/Marks/Highlight/Vue/index.spec.js @@ -0,0 +1,139 @@ +context('/demos/Marks/Highlight', () => { + before(() => { + cy.visit('/demos/Marks/Highlight') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() + }) + }) + + it('the button should highlight the selected text', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('mark') + .should('contain', 'Example Text') + }) + + it('should highlight the text in a specific color', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.toggleHighlight({ color: 'red' }) + + cy.get('.ProseMirror') + .find('mark') + .should('contain', 'Example Text') + .should('have.attr', 'data-color', 'red') + }) + }) + + it('should update the attributes of existing marks', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .toggleHighlight({ color: 'rgb(255, 0, 0)' }) + .run() + + cy.get('.ProseMirror') + .find('mark') + .should('have.css', 'background-color', 'rgb(255, 0, 0)') + }) + }) + + it('should remove existing marks with the same attributes', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .toggleHighlight({ color: 'rgb(255, 0, 0)' }) + .run() + + cy.get('.ProseMirror') + .find('mark') + .should('not.exist') + }) + }) + + it('is active for mark with any attributes', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() + + expect(editor.isActive('highlight')).to.eq(true) + }) + }) + + it('is active for mark with same attributes', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() + + const isActive = editor.isActive('highlight', { + color: 'rgb(255, 0, 0)', + }) + + expect(isActive).to.eq(true) + }) + }) + + it('isn’t active for mark with other attributes', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor + .chain() + .setContent('

Example Text

') + .selectAll() + .run() + + const isActive = editor.isActive('highlight', { + color: 'rgb(0, 0, 0)', + }) + + expect(isActive).to.eq(false) + }) + }) + + it('the button should toggle the selected text highlighted', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .type('{selectall}') + + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('mark') + .should('not.exist') + }) + + it('should highlight the selected text when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, shiftKey: true, key: 'h' }) + .find('mark') + .should('contain', 'Example Text') + }) + + it('should toggle the selected text highlighted when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, shiftKey: true, key: 'h' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 'h' }) + .find('mark') + .should('not.exist') + }) +}) diff --git a/demos/src/Marks/Highlight/Vue/index.vue b/demos/src/Marks/Highlight/Vue/index.vue new file mode 100644 index 00000000..c6654eda --- /dev/null +++ b/demos/src/Marks/Highlight/Vue/index.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/demos/src/Marks/Italic/Vue/index.html b/demos/src/Marks/Italic/Vue/index.html new file mode 100644 index 00000000..01bca6a6 --- /dev/null +++ b/demos/src/Marks/Italic/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Italic/Vue/index.spec.js b/demos/src/Marks/Italic/Vue/index.spec.js new file mode 100644 index 00000000..1e9b9a50 --- /dev/null +++ b/demos/src/Marks/Italic/Vue/index.spec.js @@ -0,0 +1,71 @@ +context('/demos/Marks/Italic', () => { + before(() => { + cy.visit('/demos/Marks/Italic') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('i tags should be transformed to em tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('i tags with normal font style should be omitted', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('generic tags with italic style should be transformed to strong tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('the button should make the selected text italic', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('em') + .should('contain', 'Example Text') + }) + + it('the button should toggle the selected text italic', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .type('{selectall}') + + cy.get('button:first') + .click() + + cy.get('.ProseMirror em') + .should('not.exist') + }) + + it('the keyboard shortcut should make the selected text italic', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'i' }) + .find('em') + .should('contain', 'Example Text') + }) + + it('the keyboard shortcut should toggle the selected text italic', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'i' }) + .trigger('keydown', { modKey: true, key: 'i' }) + .find('em') + .should('not.exist') + }) +}) diff --git a/demos/src/Marks/Italic/Vue/index.vue b/demos/src/Marks/Italic/Vue/index.vue new file mode 100644 index 00000000..e8ff16fb --- /dev/null +++ b/demos/src/Marks/Italic/Vue/index.vue @@ -0,0 +1,50 @@ + + + diff --git a/demos/src/Marks/Link/Vue/index.html b/demos/src/Marks/Link/Vue/index.html new file mode 100644 index 00000000..04176185 --- /dev/null +++ b/demos/src/Marks/Link/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Link/Vue/index.spec.js b/demos/src/Marks/Link/Vue/index.spec.js new file mode 100644 index 00000000..403cb8c0 --- /dev/null +++ b/demos/src/Marks/Link/Vue/index.spec.js @@ -0,0 +1,76 @@ +context('/demos/Marks/Link', () => { + before(() => { + cy.visit('/demos/Marks/Link') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('should parse a tags correctly', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should parse a tags with target attribute correctly', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should parse a tags with rel attribute correctly', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('the button should add a link to the selected text', () => { + cy.window().then(win => { + cy.stub(win, 'prompt').returns('https://tiptap.dev') + + cy.get('button:first') + .click() + + cy.window().its('prompt').should('be.called') + + cy.get('.ProseMirror') + .find('a') + .should('contain', 'Example Text') + .should('have.attr', 'href', 'https://tiptap.dev') + }) + }) + + it('detects a pasted URL within a text', () => { + cy.get('.ProseMirror').paste({ pastePayload: 'some text https://example.com around an url', pasteType: 'text/plain' }) + .find('a') + .should('contain', 'https://example.com') + .should('have.attr', 'href', 'https://example.com') + }) + + it('detects a pasted URL', () => { + cy.get('.ProseMirror').paste({ pastePayload: 'https://example.com', pasteType: 'text/plain' }) + .find('a') + .should('contain', 'Example Text') + .should('have.attr', 'href', 'https://example.com') + }) + + it('correctly detects multiple pasted URLs', () => { + cy.get('.ProseMirror').paste({ pastePayload: 'https://example1.com, https://example2.com/foobar, (http://example3.com/foobar)', pasteType: 'text/plain' }) + + cy.get('.ProseMirror').find('a[href="https://example1.com"]') + .should('contain', 'https://example1.com') + + cy.get('.ProseMirror').find('a[href="https://example2.com/foobar"]') + .should('contain', 'https://example2.com/foobar') + + cy.get('.ProseMirror').find('a[href="http://example3.com/foobar"]') + .should('contain', 'http://example3.com/foobar') + }) +}) diff --git a/demos/src/Marks/Link/Vue/index.vue b/demos/src/Marks/Link/Vue/index.vue new file mode 100644 index 00000000..8bd2467d --- /dev/null +++ b/demos/src/Marks/Link/Vue/index.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/demos/src/Marks/Strike/Vue/index.html b/demos/src/Marks/Strike/Vue/index.html new file mode 100644 index 00000000..66f796eb --- /dev/null +++ b/demos/src/Marks/Strike/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Strike/Vue/index.spec.js b/demos/src/Marks/Strike/Vue/index.spec.js new file mode 100644 index 00000000..b3410136 --- /dev/null +++ b/demos/src/Marks/Strike/Vue/index.spec.js @@ -0,0 +1,86 @@ +context('/demos/Marks/Strike', () => { + before(() => { + cy.visit('/demos/Marks/Strike') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('should parse s tags correctly', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should transform del tags to s tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should transform strike tags to s tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should transform any tag with text decoration line through to s tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('the button should strike the selected text', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('s') + .should('contain', 'Example Text') + }) + + it('the button should toggle the selected text striked', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .type('{selectall}') + + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('s') + .should('not.exist') + }) + + it('should strike the selected text when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, shiftKey: true, key: 'x' }) + .find('s') + .should('contain', 'Example Text') + }) + + it('should toggle the selected text striked when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, shiftKey: true, key: 'x' }) + .trigger('keydown', { modKey: true, shiftKey: true, key: 'x' }) + .find('s') + .should('not.exist') + }) + + it('should make a striked text from the markdown shortcut', () => { + cy.get('.ProseMirror') + .type('~~Strike~~') + .find('s') + .should('contain', 'Strike') + }) +}) diff --git a/demos/src/Marks/Strike/Vue/index.vue b/demos/src/Marks/Strike/Vue/index.vue new file mode 100644 index 00000000..827c76b6 --- /dev/null +++ b/demos/src/Marks/Strike/Vue/index.vue @@ -0,0 +1,51 @@ + + + diff --git a/demos/src/Marks/Subscript/Vue/index.html b/demos/src/Marks/Subscript/Vue/index.html new file mode 100644 index 00000000..045b6734 --- /dev/null +++ b/demos/src/Marks/Subscript/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Subscript/Vue/index.spec.js b/demos/src/Marks/Subscript/Vue/index.spec.js new file mode 100644 index 00000000..70392d4c --- /dev/null +++ b/demos/src/Marks/Subscript/Vue/index.spec.js @@ -0,0 +1,42 @@ +context('/demos/Marks/Subscript', () => { + before(() => { + cy.visit('/demos/Marks/Subscript') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('should transform inline style to sub tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('sould omit inline style with a different vertical align', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('the button should make the selected text bold', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('sub') + .should('contain', 'Example Text') + }) + + it('the button should toggle the selected text bold', () => { + cy.get('button:first').click() + cy.get('.ProseMirror').type('{selectall}') + cy.get('button:first').click() + cy.get('.ProseMirror sub').should('not.exist') + }) +}) diff --git a/demos/src/Marks/Subscript/Vue/index.vue b/demos/src/Marks/Subscript/Vue/index.vue new file mode 100644 index 00000000..73202969 --- /dev/null +++ b/demos/src/Marks/Subscript/Vue/index.vue @@ -0,0 +1,49 @@ + + + diff --git a/demos/src/Marks/Superscript/Vue/index.html b/demos/src/Marks/Superscript/Vue/index.html new file mode 100644 index 00000000..0fc33f69 --- /dev/null +++ b/demos/src/Marks/Superscript/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Superscript/Vue/index.spec.js b/demos/src/Marks/Superscript/Vue/index.spec.js new file mode 100644 index 00000000..9c642cc4 --- /dev/null +++ b/demos/src/Marks/Superscript/Vue/index.spec.js @@ -0,0 +1,42 @@ +context('/demos/Marks/Superscript', () => { + before(() => { + cy.visit('/demos/Marks/Superscript') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('should transform inline style to sup tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('sould omit inline style with a different vertical align', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('the button should make the selected text bold', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('sup') + .should('contain', 'Example Text') + }) + + it('the button should toggle the selected text bold', () => { + cy.get('button:first').click() + cy.get('.ProseMirror').type('{selectall}') + cy.get('button:first').click() + cy.get('.ProseMirror sup').should('not.exist') + }) +}) diff --git a/demos/src/Marks/Superscript/Vue/index.vue b/demos/src/Marks/Superscript/Vue/index.vue new file mode 100644 index 00000000..d798c63b --- /dev/null +++ b/demos/src/Marks/Superscript/Vue/index.vue @@ -0,0 +1,49 @@ + + + diff --git a/demos/src/Marks/TextStyle/Vue/index.html b/demos/src/Marks/TextStyle/Vue/index.html new file mode 100644 index 00000000..4196bfee --- /dev/null +++ b/demos/src/Marks/TextStyle/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/TextStyle/Vue/index.spec.js b/demos/src/Marks/TextStyle/Vue/index.spec.js new file mode 100644 index 00000000..564be7bf --- /dev/null +++ b/demos/src/Marks/TextStyle/Vue/index.spec.js @@ -0,0 +1,7 @@ +context('/demos/Marks/TextStyle', () => { + before(() => { + cy.visit('/demos/Marks/TextStyle') + }) + + // TODO: Write tests +}) diff --git a/demos/src/Marks/TextStyle/Vue/index.vue b/demos/src/Marks/TextStyle/Vue/index.vue new file mode 100644 index 00000000..27d808dd --- /dev/null +++ b/demos/src/Marks/TextStyle/Vue/index.vue @@ -0,0 +1,44 @@ + + + diff --git a/demos/src/Marks/Underline/Vue/index.html b/demos/src/Marks/Underline/Vue/index.html new file mode 100644 index 00000000..1f0c595b --- /dev/null +++ b/demos/src/Marks/Underline/Vue/index.html @@ -0,0 +1,15 @@ + + + + + + + +
+ + + diff --git a/demos/src/Marks/Underline/Vue/index.spec.js b/demos/src/Marks/Underline/Vue/index.spec.js new file mode 100644 index 00000000..94db9677 --- /dev/null +++ b/demos/src/Marks/Underline/Vue/index.spec.js @@ -0,0 +1,65 @@ +context('/demos/Marks/Underline', () => { + before(() => { + cy.visit('/demos/Marks/Underline') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + cy.get('.ProseMirror').type('{selectall}') + }) + }) + + it('should parse u tags correctly', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('should transform any tag with text decoration underline to u tags', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.setContent('

Example Text

') + expect(editor.getHTML()).to.eq('

Example Text

') + }) + }) + + it('the button should underline the selected text', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('u') + .should('contain', 'Example Text') + }) + + it('the button should toggle the selected text underline', () => { + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .type('{selectall}') + + cy.get('button:first') + .click() + + cy.get('.ProseMirror') + .find('u') + .should('not.exist') + }) + + it('should underline the selected text when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'u' }) + .find('u') + .should('contain', 'Example Text') + }) + + it('should toggle the selected text underline when the keyboard shortcut is pressed', () => { + cy.get('.ProseMirror') + .trigger('keydown', { modKey: true, key: 'u' }) + .trigger('keydown', { modKey: true, key: 'u' }) + .find('u') + .should('not.exist') + }) +}) diff --git a/demos/src/Marks/Underline/Vue/index.vue b/demos/src/Marks/Underline/Vue/index.vue new file mode 100644 index 00000000..170c14b5 --- /dev/null +++ b/demos/src/Marks/Underline/Vue/index.vue @@ -0,0 +1,49 @@ + + +