From e7e903bafc11f8a36cb866c453af4957f93ed471 Mon Sep 17 00:00:00 2001 From: Matt Jeff Date: Mon, 25 Apr 2022 22:33:22 +0100 Subject: [PATCH 1/6] add github service --- src/services.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/services.js b/src/services.js index c6b44910..f8d535e0 100644 --- a/src/services.js +++ b/src/services.js @@ -164,5 +164,13 @@ export default { regex: /https:\/\/miro.com\/\S+(\S{12})\/(\S+)?/, embedUrl: 'https://miro.com/app/live-embed/<%= remote_id %>', html: '', + }, + github: { + regex: /https?:\/\/gist.github.com\/([^\/\?\&]*)\/([^\/\?\&]*)/, + embedUrl: 'data:text/html;charset=utf-8,', + html: '', + height: 300, + width: 600, + id: (groups) => groups.join('/') } }; From 7ed164ee9a571438f7c811b14bb34f58c4804f0f Mon Sep 17 00:00:00 2001 From: userharis Date: Tue, 3 May 2022 06:43:27 +0500 Subject: [PATCH 2/6] add test case for github service --- test/services.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/services.js b/test/services.js index 6c49ad8c..9f698df1 100644 --- a/test/services.js +++ b/test/services.js @@ -392,6 +392,33 @@ describe('Services Regexps', () => { }); }); + it('Github', async () => { + const service = 'github'; + + const urls = [ + { + source: 'https://gist.github.com/userharis/091b56505c804276e1f91925976f11db', + embed: 'data:text/html;charset=utf-8,', + }, + { + source: 'https://gist.github.com/userharis/a8c2977094d4716c43e35e6c20b7d306', + embed: 'data:text/html;charset=utf-8,', + }, + ]; + + urls.forEach(url => { + expect(patterns[service].test(url.source)).to.be.true; + + const event = composePasteEventMock('pattern', service, url.source); + + embed.onPaste(event); + + expect(embed.data.service).to.be.equal(service); + expect(embed.data.embed).to.be.equal(url.embed); + expect(embed.data.source).to.be.equal(url.source); + }); + }); + }); describe('Miro service', () => { From f7e161285600acb3dc17c05b1ebb316140818f6c Mon Sep 17 00:00:00 2001 From: userharis Date: Tue, 3 May 2022 07:11:54 +0500 Subject: [PATCH 3/6] lint:fix --- src/services.js | 4 ++-- test/services.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/services.js b/src/services.js index f8d535e0..84f43028 100644 --- a/src/services.js +++ b/src/services.js @@ -171,6 +171,6 @@ export default { html: '', height: 300, width: 600, - id: (groups) => groups.join('/') - } + id: (groups) => groups.join('/'), + }, }; diff --git a/test/services.js b/test/services.js index 9f698df1..643c3d22 100644 --- a/test/services.js +++ b/test/services.js @@ -418,7 +418,6 @@ describe('Services Regexps', () => { expect(embed.data.source).to.be.equal(url.source); }); }); - }); describe('Miro service', () => { From 61f8188c0d481fe75971c60a1613c44433703ead Mon Sep 17 00:00:00 2001 From: userharis Date: Tue, 3 May 2022 07:41:05 +0500 Subject: [PATCH 4/6] id should end with .js and src attribute value should be quoted --- src/services.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services.js b/src/services.js index 84f43028..8d5388d5 100644 --- a/src/services.js +++ b/src/services.js @@ -167,10 +167,10 @@ export default { }, github: { regex: /https?:\/\/gist.github.com\/([^\/\?\&]*)\/([^\/\?\&]*)/, - embedUrl: 'data:text/html;charset=utf-8,', + embedUrl: 'data:text/html;charset=utf-8,', html: '', height: 300, width: 600, - id: (groups) => groups.join('/'), + id: (groups) => `${groups.join('/')}.js`, }, }; From d9adfe2459a875e9c57e2969eead2befd002b257 Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Wed, 18 Oct 2023 18:22:43 +0300 Subject: [PATCH 5/6] chore: update frame appearance and readme --- README.md | 1 + package.json | 2 +- src/services.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c462f87b..2b2575ca 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Tool uses Editor.js pasted patterns handling and inserts iframe with embedded co - [Coub](https://coub.com) — `coub` service - [CodePen](https://codepen.io) — `codepen` service - [Pinterest](https://www.pinterest.com) - `pinterest` service +- [GitHub Gist](https://gist.github.com) - `github` service - 👇 Any other [customized service](#add-more-services) diff --git a/package.json b/package.json index 718447b1..9ee78695 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/embed", - "version": "2.5.1", + "version": "2.6.0", "keywords": [ "codex editor", "embed", diff --git a/src/services.js b/src/services.js index 8d5388d5..8d9949c4 100644 --- a/src/services.js +++ b/src/services.js @@ -168,7 +168,7 @@ export default { github: { regex: /https?:\/\/gist.github.com\/([^\/\?\&]*)\/([^\/\?\&]*)/, embedUrl: 'data:text/html;charset=utf-8,', - html: '', + html: '', height: 300, width: 600, id: (groups) => `${groups.join('/')}.js`, From 0f513d651db9c31762b30560026292c72e4827ed Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Wed, 18 Oct 2023 18:28:35 +0300 Subject: [PATCH 6/6] fix(ci): setup node version --- .github/workflows/npm-publish.yml | 2 +- .github/workflows/test.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 7f359d02..cad0c93e 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 16 registry-url: https://registry.npmjs.org/ - run: yarn - run: yarn build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d44cacdf..30cac242 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ - name: Cache node modules uses: actions/cache@v1