Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Tool uses Editor.js pasted patterns handling and inserts iframe with embedded co
- [Pinterest](https://www.pinterest.com) - `pinterest` service
- [GitHub Gist](https://gist.github.com) - `github` service
- [Reddit](https://www.reddit.com/) - `reddit` service
- [Figma](https://www.figma.com/) - `figma` service
- [Whimsical](https://whimsical.com/) - whimsical service
- 👇 Any other [customized service](#add-more-services)



## Installation

Get the package
Expand Down Expand Up @@ -152,6 +152,7 @@ var editor = EditorJS({
```

#### Inline Toolbar

Editor.js provides useful inline toolbar. You can allow it\`s usage in the Embed Tool caption by providing `inlineToolbar: true`.

```javascript
Expand Down Expand Up @@ -181,7 +182,6 @@ var editor = EditorJS({
| height | `number` | embedded content height
| caption | `string` | content caption


```json
{
"type" : "embed",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/embed",
"version": "2.7.7",
"version": "2.8.0",
"keywords": [
"codex editor",
"embed",
Expand Down
16 changes: 15 additions & 1 deletion src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ const SERVICES: ServicesConfigType = {
id: (ids) => ids.join('/embed/'),
},
instagram: {
//it support both reel and post
regex: /^https:\/\/(?:www\.)?instagram\.com\/(?:reel|p)\/(.*)/,
embedUrl: 'https://www.instagram.com/p/<%= remote_id %>/embed',
html: '<iframe width="400" height="505" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
Expand Down Expand Up @@ -205,6 +204,21 @@ const SERVICES: ServicesConfigType = {
width: 600,
id: (groups) => `${groups.join('/')}.js`,
},
whimsical: {
regex: /(https:\/\/)?whimsical.com\/(?:[a-zA-Z0-9\-]+\-)?([a-km-zA-HJ-NP-Z1-9]{16,22})(@[a-km-zA-HJ-NP-Z1-9]+)?/,
embedUrl: 'https://whimsical.com/embed/<%= remote_id %>',
html: "<iframe height='300' scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>",
height: 300,
width: 600,
id: (ids) => ids[1]
},
figma:{
regex: /(https:\/\/www\.figma\.com\/.*)?/,
embedUrl: 'https://www.figma.com/embed?embed_host=share&url=<%= remote_id %>',
html: "<iframe height='450' scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>",
height: 300,
width: 600
},
};

export default SERVICES;
28 changes: 28 additions & 0 deletions test/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,31 @@ describe('Miro service', () => {
expect(embed.data.source).to.be.equal(regularBoardUrl);
});
});

describe('whimsical', () => {
it('should correctly parse URL got from a browser', () => {
const regularBoardUrl = 'https://whimsical.com/test-86ajy7vWEzYATvwFFvbwfA';
const event = composePasteEventMock('pattern', 'whimsical', regularBoardUrl);

embed.onPaste(event);

expect(patterns.whimsical.test(regularBoardUrl)).to.be.true;
expect(embed.data.service).to.be.equal('whimsical');
expect(embed.data.embed).to.be.equal('https://whimsical.com/embed/86ajy7vWEzYATvwFFvbwfA');
expect(embed.data.source).to.be.equal(regularBoardUrl);
});
});

describe('figma', () => {
it('should correctly parse URL got from a browser', () => {
const regularBoardUrl = 'https://www.figma.com/file/3BYrViWFPvfhbrpm1aO3ha/Untitled?type=design&node-id=0%3A1&mode=design&t=WutMRT9L8VJNEL5z-1';
const event = composePasteEventMock('pattern', 'figma', regularBoardUrl);

embed.onPaste(event);

expect(patterns.figma.test(regularBoardUrl)).to.be.true;
expect(embed.data.service).to.be.equal('figma');
expect(embed.data.embed).to.be.equal('https://www.figma.com/embed?embed_host=share&url=https://www.figma.com/file/3BYrViWFPvfhbrpm1aO3ha/Untitled?type=design&node-id=0%3A1&mode=design&t=WutMRT9L8VJNEL5z-1');
expect(embed.data.source).to.be.equal(regularBoardUrl);
});
});