migrate image editor component
This commit is contained in:
22
packages/netlify-cms-editor-component-image/package.json
Normal file
22
packages/netlify-cms-editor-component-image/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "netlify-cms-editor-component-image",
|
||||
"description": "Image component for Netlify CMS editor widget",
|
||||
"version": "2.0.0-alpha.0",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"netlify",
|
||||
"netlify-cms",
|
||||
"editor",
|
||||
"component"
|
||||
],
|
||||
"scripts": {
|
||||
"watch": "parcel watch src/*.js --out-dir . --no-cache",
|
||||
"build": "parcel build src/*.js --out-dir . --no-cache"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^16.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"parcel-bundler": "^1.9.4"
|
||||
}
|
||||
}
|
23
packages/netlify-cms-editor-component-image/src/index.js
Normal file
23
packages/netlify-cms-editor-component-image/src/index.js
Normal file
@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
|
||||
const image = {
|
||||
label: 'Image',
|
||||
id: 'image',
|
||||
fromBlock: match => match && {
|
||||
image: match[2],
|
||||
alt: match[1],
|
||||
},
|
||||
toBlock: data => ``,
|
||||
toPreview: (data, getAsset) => <img src={getAsset(data.image) || ''} alt={data.alt || ''} />,
|
||||
pattern: /^!\[(.*)\]\((.*)\)$/,
|
||||
fields: [{
|
||||
label: 'Image',
|
||||
name: 'image',
|
||||
widget: 'image',
|
||||
}, {
|
||||
label: 'Alt Text',
|
||||
name: 'alt',
|
||||
}],
|
||||
};
|
||||
|
||||
export default image;
|
Reference in New Issue
Block a user