Skip to content
Open
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
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ const editor = EditorJS({

## Config Params

| Field | Type | Description |
| -------------- | --------- | ------------------------------- |
| embed | `{display: boolean}` | You could display or not the embed tab, If you don't fill the embed config by default the value is set on true
| unsplash | `{appName: string, clientId: string, maxResults: string}` | Config for **Unsplash API**. Contains 3 fields: <br><br> **appName**: Unspalsh `Application Name`. <br><br> **clientId**: Unsplash `Access Key`. <br><br> **maxResults**: Max number of images per search (default 30). |
| Field | Type | Description |
| -------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| embed | `{display: boolean}` | You could display or not the embed tab, If you don't fill the embed config by default the value is set on true |
| unsplash | `{appName: string, clientId: string, maxResults: string}` | Config for **Unsplash API**. Contains 3 fields: <br><br> **appName**: Unspalsh `Application Name`. <br><br> **clientId**: Unsplash `Access Key`. <br><br> **maxResults**: Max number of images per search (default 30). |

## Tool's tunes

Expand All @@ -71,14 +71,15 @@ const editor = EditorJS({

## Output data

| Field | Type | Description |
| -------------- | --------- | ------------------------------- |
| url | `string` | Image's url |
| caption | `string` | Image's caption |
| withBorder | `boolean` | Add border to image |
| withBackground | `boolean` | Add background |
| stretched | `boolean` | Stretch image to screen's width |
| unsplash | `{author: string, profileLink: string}` | Unsplash image author information. <br><br> **author**: Author's name. <br><br> **profileLink**: Unsplash porfile link.
| Field | Type | Description |
| -------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| url | `string` | Image's url |
| caption | `string` | Image's caption |
| withBorder | `boolean` | Add border to image |
| withBackground | `boolean` | Add background |
| stretched | `boolean` | Stretch image to screen's width |
| middle | `boolean` | Stretch image to screen's width middle |
| unsplash | `{author: string, profileLink: string}` | Unsplash image author information. <br><br> **author**: Author's name. <br><br> **profileLink**: Unsplash porfile link. |

**Image**

Expand All @@ -90,7 +91,8 @@ const editor = EditorJS({
"caption" : "An image",
"withBorder" : false,
"withBackground" : false,
"stretched" : true
"stretched" : true,
"middle" : true
}
}
```
Expand All @@ -106,6 +108,7 @@ const editor = EditorJS({
"withBorder": false,
"withBackground": true,
"stretched": false,
"middle" : false
"unsplash": {
"author": "John Doe",
"profileLink": "https://unsplash.com/@john_doe_fake"
Expand Down
4 changes: 4 additions & 0 deletions assets/middleIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
max-width: none;
width: 100%;
}
.inline-image__picture--middle img {
max-width: none;
width: 50%;
display: block;
margin-left: auto;
margin-right: auto;
}


.inline-image__tab-wrapper {
display: flex;
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import toolboxIcon from '../assets/toolboxIcon.svg';
* @property {boolean} withBorder - should image be rendered with border
* @property {boolean} withBackground - should image be rendered with background
* @property {boolean} stretched - should image be stretched to full width of container
* @property {boolean} middle - should image be stretched to middle width of container
* @property {object} unsplash - Unsplash image information
* - author: Unsplash image author name
* - profileLink: Author profile link
Expand Down Expand Up @@ -63,6 +64,7 @@ export default class InlineImage {
withBorder: data.withBorder !== undefined ? data.withBorder : false,
withBackground: data.withBackground !== undefined ? data.withBackground : false,
stretched: data.stretched !== undefined ? data.stretched : false,
middle: data.middle !== undefined ? data.middle : false,
unsplash: data.unsplash,
};
}
Expand Down Expand Up @@ -112,6 +114,7 @@ export default class InlineImage {
withBorder: {},
withBackground: {},
stretched: {},
middle: {},
caption: {
br: true,
},
Expand Down
7 changes: 6 additions & 1 deletion src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ControlPanel from './controlPanel';
import bgIcon from '../assets/backgroundIcon.svg';
import borderIcon from '../assets/borderIcon.svg';
import stretchedIcon from '../assets/toolboxIcon.svg';
import middleIcon from '../assets/middleIcon.svg';

/**
* Class for working with UI:
Expand Down Expand Up @@ -47,6 +48,10 @@ export default class Ui {
name: 'stretched',
icon: stretchedIcon,
},
{
name: 'middle',
icon: middleIcon,
},
{
name: 'withBackground',
icon: bgIcon,
Expand Down Expand Up @@ -221,7 +226,7 @@ export default class Ui {
applyTune(tuneName, status) {
this.nodes.imageHolder.classList.toggle(`${this.CSS.imageHolder}--${tuneName}`, status);

if (tuneName === 'stretched') {
if (tuneName === 'stretched' || tuneName === 'middle') {
Promise.resolve().then(() => {
const blockIndex = this.api.blocks.getCurrentBlockIndex();
this.api.blocks.stretchBlock(blockIndex, status);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/toolData.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const data = {
withBorder: false,
withBackground: false,
stretched: false,
middle: false,
unsplash: {
author: 'John Doe',
profileLink: 'https://unsplash.com/@john_doe_fake',
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/tunes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const settings = [
{
name: 'stretched',
},
{
name: 'middle',
},
{
name: 'withBackground',
},
Expand Down