diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index a9e24fc..5cc60f8 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -18,11 +18,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: current - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: npm audit --omit=dev @@ -36,28 +36,28 @@ jobs: node-version: [ '14', '16', '18' ] steps: - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: npm ci - name: Test run: npm test - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: failure() with: - name: cypress-screenshots + name: cypress-screenshots-nodejs-${{ matrix.node-version }} path: cypress/screenshots retention-days: 7 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: - name: cypress-videos + name: cypress-videos-nodejs-${{ matrix.node-version }} path: cypress/videos retention-days: 7 @@ -68,11 +68,11 @@ jobs: if: github.event_name == 'push' steps: - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: current - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: npm ci diff --git a/CHANGELOG.md b/CHANGELOG.md index dfac172..0264691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.20.0] - 2025-03-04 +### Added +- Support for `marked` extensions (Thanks to [@codingjoe], [#611], [#514]). + +## [2.19.0] - 2025-02-18 +### Added +- `updateStatusBar` type to typescript definitions (Thanks to [@borodean], [#519]). +- `"upload-image"` option to the `ToolbarButton` typescript definitions (Thanks to [@borodean], [#520]). +- `imageInputName` option to set a custom "name" attribute for the image input (Thanks to [@robinvandernoord], [#573]). + +### Fixed +- Relative image paths using the stylesheet as the source instead of the document (Thanks to [@p1gp1g], [#591]). +- Excessive memory usage with the `previewImagesInEditor` option (Thanks to [@p1gp1g], [#592]). +- Parentheses in the alt text of images causing the image not to load then using `previewImagesInEditor` (Thanks to [@mayraamaral], [#608]). + ## [2.18.0] - 2022-09-20 ### Added - `toolbarButtonClassPrefix` option to resolve conflicts with Bootstrap classes ([#493]). @@ -257,6 +272,8 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown - Cursor not always showing in "text" mode over the edit field +[#611]: https://github.com/Ionaru/easy-markdown-editor/issues/611 +[#514]: https://github.com/Ionaru/easy-markdown-editor/issues/514 [#493]: https://github.com/Ionaru/easy-markdown-editor/issues/493 [#478]: https://github.com/Ionaru/easy-markdown-editor/issues/478 [#399]: https://github.com/Ionaru/easy-markdown-editor/issues/399 @@ -278,6 +295,12 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown [#9]: https://github.com/Ionaru/easy-markdown-editor/issues/9 +[#608]: https://github.com/Ionaru/easy-markdown-editor/pull/608 +[#592]: https://github.com/Ionaru/easy-markdown-editor/pull/592 +[#591]: https://github.com/Ionaru/easy-markdown-editor/pull/591 +[#573]: https://github.com/Ionaru/easy-markdown-editor/pull/573 +[#520]: https://github.com/Ionaru/easy-markdown-editor/pull/520 +[#519]: https://github.com/Ionaru/easy-markdown-editor/pull/519 [#492]: https://github.com/Ionaru/easy-markdown-editor/pull/492 [#488]: https://github.com/Ionaru/easy-markdown-editor/pull/488 [#486]: https://github.com/Ionaru/easy-markdown-editor/pull/486 @@ -417,9 +440,16 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown [@hlf20010508]: https://github.com/hlf20010508 [@ZsgsDesign]: https://github.com/ZsgsDesign [@sghoweri]: https://github.com/sghoweri +[@borodean]: https://github.com/borodean +[@robinvandernoord]: https://github.com/robinvandernoord +[@p1gp1g]: https://github.com/p1gp1g +[@mayraamaral]: https://github.com/mayraamaral +[@codingjoe]: https://github.com/codingjoe -[Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.18.0...HEAD +[Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.20.0...HEAD +[2.20.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.19.0...2.20.0 +[2.19.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.18.0...2.19.0 [2.18.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.17.0...2.18.0 [2.17.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.1...2.17.0 [2.16.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.0...2.16.1 diff --git a/README.md b/README.md index 6b1f074..529509e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # EasyMDE - Markdown Editor [![npm version](https://img.shields.io/npm/v/easymde.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde) -[![npm version](https://img.shields.io/npm/v/easymde/next.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/next) +[![npm @next version](https://img.shields.io/npm/v/easymde/next.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/next) +[![npm @v3-alpha version](https://img.shields.io/npm/v/easymde/v3-alpha.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/v3-alpha) [![Build Status](https://img.shields.io/github/actions/workflow/status/ionaru/easy-markdown-editor/cd.yaml?branch=master&style=for-the-badge)](https://github.com/Ionaru/easy-markdown-editor/actions?query=branch%3Amaster) > This repository is a fork of diff --git a/cypress/e2e/4.image-rendering/image-rendering.cy.js b/cypress/e2e/4.image-rendering/image-rendering.cy.js new file mode 100644 index 0000000..e25e6b5 --- /dev/null +++ b/cypress/e2e/4.image-rendering/image-rendering.cy.js @@ -0,0 +1,43 @@ +/// + +describe('Image rendering', () => { + + const imageUrl = 'https://picsum.photos/id/237/150'; + + beforeEach(() => { + cy.visit(__dirname + '/index.html'); + cy.intercept('GET', imageUrl).as('image'); + }); + + it('must render an image inside the editor', () => { + cy.get('.EasyMDEContainer').should('be.visible'); + cy.get('#textarea').should('not.be.visible'); + + cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl); + cy.get('.EasyMDEContainer .CodeMirror').type('{home}![Dog!]({end})'); + + cy.wait('@image'); + + cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible'); + + cy.previewOn(); + + cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `

Dog!

`); + }); + + it('must be able to handle parentheses inside image alt text', () => { + cy.get('.EasyMDEContainer').should('be.visible'); + cy.get('#textarea').should('not.be.visible'); + + cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl); + cy.get('.EasyMDEContainer .CodeMirror').type('{home}![Dog! (He\'s a good boy!)]({end})'); + + cy.wait('@image'); + + cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible'); + + cy.previewOn(); + + cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `

Dog! (He's a good boy!)

`); + }); +}); diff --git a/cypress/e2e/4.image-rendering/index.html b/cypress/e2e/4.image-rendering/index.html new file mode 100644 index 0000000..045bc33 --- /dev/null +++ b/cypress/e2e/4.image-rendering/index.html @@ -0,0 +1,20 @@ + + + + + + Default + + + + + + + + + + diff --git a/cypress/e2e/5-marked-options/index.html b/cypress/e2e/5-marked-options/index.html new file mode 100644 index 0000000..5dc4d3d --- /dev/null +++ b/cypress/e2e/5-marked-options/index.html @@ -0,0 +1,24 @@ + + + + + + Default + + + + + + + + + + diff --git a/cypress/e2e/5-marked-options/marked-options.cy.js b/cypress/e2e/5-marked-options/marked-options.cy.js new file mode 100644 index 0000000..935b86a --- /dev/null +++ b/cypress/e2e/5-marked-options/marked-options.cy.js @@ -0,0 +1,18 @@ +/// + +describe('Marked options', () => { + beforeEach(() => { + cy.visit(__dirname + '/index.html'); + }); + + it('must apply the markedOptions to the markdown parser', () => { + cy.get('.EasyMDEContainer').should('be.visible'); + cy.get('#textarea').should('not.be.visible'); + + cy.get('.EasyMDEContainer .CodeMirror').type('# Title{enter}'); + + cy.previewOn(); + + cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '

Title

'); + }); +}); diff --git a/package-lock.json b/package-lock.json index 6095e76..d0180be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "easymde", - "version": "2.18.0", + "version": "2.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "easymde", - "version": "2.18.0", + "version": "2.20.0", "license": "MIT", "dependencies": { "@types/codemirror": "^5.60.10", diff --git a/package.json b/package.json index 8f1fad3..7cd8ce1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "easymde", - "version": "2.18.0", + "version": "2.20.0", "description": "A simple, beautiful, and embeddable JavaScript Markdown editor that easy to use. Features include autosaving and spell checking.", "files": [ "dist/**/*", diff --git a/src/js/easymde.js b/src/js/easymde.js index d2117fb..13f4e72 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -2071,7 +2071,7 @@ EasyMDE.prototype.markdown = function (text) { } // Set options - marked.setOptions(markedOptions); + marked.use(markedOptions); // Convert the markdown to HTML var htmlText = marked.parse(text); @@ -2681,7 +2681,7 @@ EasyMDE.prototype.render = function (el) { return; } if (!parentEl.hasAttribute('data-img-src')) { - var srcAttr = parentEl.innerText.match('\\((.*)\\)'); // might require better parsing according to markdown spec + var srcAttr = parentEl.innerText.match(/!\[.*?\]\((.*?)\)/); // might require better parsing according to markdown spec if (!window.EMDEimagesCache) { window.EMDEimagesCache = {}; } diff --git a/types/easymde.d.ts b/types/easymde.d.ts index 351939a..502b29d 100644 --- a/types/easymde.d.ts +++ b/types/easymde.d.ts @@ -101,7 +101,7 @@ declare namespace EasyMDE { interface RenderingOptions { codeSyntaxHighlighting?: boolean; hljs?: any; - markedOptions?: marked.MarkedOptions; + markedOptions?: marked.MarkedExtension; sanitizerFunction?: (html: string) => string; singleLineBreaks?: boolean; }