Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for editing meta data #52

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
73 changes: 37 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ npm i --save-dev @editorjs/link
Include module at your application

```javascript
const LinkTool = require('@editorjs/link');
const LinkTool = require("@editorjs/link");
```

### Download to your project's source dir
Expand Down Expand Up @@ -67,34 +67,35 @@ const editor = EditorJS({

Link Tool supports these configuration parameters:

| Field | Type | Description |
| ---------|-------------|------------------------------------------------|
| endpoint | `string` | **Required:** the endpoint for link data fetching. |
| headers | `object` | **Optional:** the headers used in the GET request. |
| Field | Type | Description |
| ------------- | --------- | ---------------------------------------------------------- |
| endpoint | `string` | **Required:** the endpoint for link data fetching. |
| headers | `object` | **Optional:** the headers used in the GET request. |
| allowMetaEdit | `boolean` | **Optional:** Allow editing meta data after being fetched. |

## Output data

This Tool returns `data` with following format

| Field | Type | Description |
| -------------- | --------- | ------------------------------- |
| link | `string` | Pasted link's url |
| meta | `object` | Fetched link's data. Any data got from the backend. Currently, the plugin's design supports the 'title', 'image', and 'description' fields. |
| Field | Type | Description |
| ----- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| link | `string` | Pasted link's url |
| meta | `object` | Fetched link's data. Any data got from the backend. Currently, the plugin's design supports the 'title', 'image', and 'description' fields. |

```json
{
"type" : "linkTool",
"data" : {
"link" : "https://codex.so",
"meta" : {
"title" : "CodeX Team",
"site_name" : "CodeX",
"description" : "Club of web-development, design and marketing. We build team learning how to build full-valued projects on the world market.",
"image" : {
"url" : "https://codex.so/public/app/img/meta_img.png"
}
}
"type": "linkTool",
"data": {
"link": "https://codex.so",
"meta": {
"title": "CodeX Team",
"site_name": "CodeX",
"description": "Club of web-development, design and marketing. We build team learning how to build full-valued projects on the world market.",
"image": {
"url": "https://codex.so/public/app/img/meta_img.png"
}
}
}
}
```

Expand All @@ -107,11 +108,11 @@ Backend response **should** cover following format:

```json5
{
"success" : 1,
"link": "https://codex.so", // Optionally return a link to set the hyperlink URL
"meta": {
// ... any fields you want
}
success: 1,
link: "https://codex.so", // Optionally return a link to set the hyperlink URL
meta: {
// ... any fields you want
},
}
```

Expand All @@ -125,14 +126,14 @@ Currently, the plugin's design supports the 'title', 'image', and 'description'

```json5
{
"success" : 1,
"meta": {
"title" : "CodeX Team",
"description" : "Club of web-development, design and marketing. We build team learning how to build full-valued projects on the world market.",
"image" : {
"url" : "https://codex.so/public/app/img/meta_img.png"
}
}
success: 1,
meta: {
title: "CodeX Team",
description: "Club of web-development, design and marketing. We build team learning how to build full-valued projects on the world market.",
image: {
url: "https://codex.so/public/app/img/meta_img.png",
},
},
}
```

Expand All @@ -144,6 +145,6 @@ Also, it can contain any additional fields you want to store.

CodeX is a team of digital specialists around the world interested in building high-quality open source products on a global market. We are [open](https://codex.so/join) for young people who want to constantly improve their skills and grow professionally with experiments in cutting-edge technologies.

| 🌐 | Join 👋 | Twitter | Instagram |
| -- | -- | -- | -- |
| [codex.so](https://codex.so) | [codex.so/join](https://codex.so/join) |[@codex_team](http://twitter.com/codex_team) | [@codex_team](http://instagram.com/codex_team/) |
| 🌐 | Join 👋 | Twitter | Instagram |
| ---------------------------- | -------------------------------------- | -------------------------------------------- | ----------------------------------------------- |
| [codex.so](https://codex.so) | [codex.so/join](https://codex.so/join) | [@codex_team](http://twitter.com/codex_team) | [@codex_team](http://instagram.com/codex_team/) |
25 changes: 16 additions & 9 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,35 @@
background-color: #fff3f6;
border-color: #f3e0e0;
color: #a95a5a;
box-shadow: inset 0 1px 3px 0 rgba(146, 62, 62, .05);
box-shadow: inset 0 1px 3px 0 rgba(146, 62, 62, 0.05);
}
}
}
}

[contentEditable="true"] {
&:focus {
outline: none;
}

&[contentEditable=true][data-placeholder]::before{
&[data-placeholder]::before {
position: absolute;
content: attr(data-placeholder);
color: #707684;
font-weight: normal;
opacity: 0;
cursor: text;
pointer-events: none;
}

&[contentEditable=true][data-placeholder]:empty {

&[data-placeholder]:empty {
&::before {
opacity: 1;
}

&:focus::before {
opacity: 0;
}
opacity: 0;
}
}
}

Expand Down Expand Up @@ -79,13 +86,13 @@
&--rendered {
background: #fff;
border: 1px solid rgba(201, 201, 204, 0.48);
box-shadow: 0 1px 3px rgba(0,0,0, .1);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border-radius: 6px;
will-change: filter;
animation: link-in 450ms 1 cubic-bezier(0.215, 0.61, 0.355, 1);

&:hover {
box-shadow: 0 0 3px rgba(0,0,0, .16);
box-shadow: 0 0 3px rgba(0, 0, 0, 0.16);
}
}
}
Expand Down Expand Up @@ -123,7 +130,7 @@
}

&__anchor {
display: block;
display: inline-block;
font-size: 15px;
line-height: 1em;
color: #888 !important;
Expand Down
Loading