diff --git a/packages/netlify-cms-core/package.json b/packages/netlify-cms-core/package.json index 1a3eb6ad..40261eb2 100644 --- a/packages/netlify-cms-core/package.json +++ b/packages/netlify-cms-core/package.json @@ -57,7 +57,6 @@ "react-scroll-sync": "^0.4.0", "react-sortable-hoc": "^0.6.8", "react-split-pane": "^0.1.82", - "react-textarea-autosize": "^5.2.0", "react-toggled": "^1.1.2", "react-topbar-progress-indicator": "^2.0.0", "react-transition-group": "^2.2.1", diff --git a/packages/netlify-cms-core/scripts/load-extensions.js b/packages/netlify-cms-core/scripts/load-extensions.js index 0becf58b..553e6bc0 100644 --- a/packages/netlify-cms-core/scripts/load-extensions.js +++ b/packages/netlify-cms-core/scripts/load-extensions.js @@ -11,11 +11,11 @@ import { ImageControl, ImagePreview } from 'netlify-cms-widget-image'; import { ListControl, ListPreview } from 'netlify-cms-widget-list'; import { ObjectControl, ObjectPreview } from 'netlify-cms-widget-object'; import { MarkdownControl, MarkdownPreview } from 'netlify-cms-widget-markdown'; -import { StringControl, StringPreview } from 'netlify-cms-widget-string'; -// import { NumberControl, NumberPreview } from 'netlify-cms-widget-number'; -// import { TextControl, TextPreview } from 'netlify-cms-widget-text'; -// import { SelectControl, SelectPreview } from 'netlify-cms-widget-select'; +import { NumberControl, NumberPreview } from 'netlify-cms-widget-number'; // import { RelationControl, RelationPreview } from 'netlify-cms-widget-relation'; +import { StringControl, StringPreview } from 'netlify-cms-widget-string'; +import { SelectControl, SelectPreview } from 'netlify-cms-widget-select'; +import { TextControl, TextPreview } from 'netlify-cms-widget-text'; import image from 'netlify-cms-editor-component-image'; registerBackend('git-gateway', GitGatewayBackend); @@ -29,10 +29,10 @@ registerWidget('file', FileControl, FilePreview); registerWidget('image', ImageControl, ImagePreview); registerWidget('list', ListControl, ListPreview); registerWidget('markdown', MarkdownControl, MarkdownPreview); +registerWidget('number', NumberControl, NumberPreview); registerWidget('object', ObjectControl, ObjectPreview); -registerWidget('string', StringControl, StringPreview); -// registerWidget('text', TextControl, TextPreview); -// registerWidget('number', NumberControl, NumberPreview); -// registerWidget('select', SelectControl, SelectPreview); // registerWidget('relation', RelationControl, RelationPreview); +registerWidget('string', StringControl, StringPreview); +registerWidget('text', TextControl, TextPreview); +registerWidget('select', SelectControl, SelectPreview); registerEditorComponent(image); diff --git a/packages/netlify-cms-core/src/components/EditorWidgets/Number/NumberPreview.js b/packages/netlify-cms-core/src/components/EditorWidgets/Number/NumberPreview.js deleted file mode 100644 index e954d3ff..00000000 --- a/packages/netlify-cms-core/src/components/EditorWidgets/Number/NumberPreview.js +++ /dev/null @@ -1,10 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; - -export default function NumberPreview({ value }) { - return
{value}
; -} - -NumberPreview.propTypes = { - value: PropTypes.node, -}; diff --git a/packages/netlify-cms-core/src/components/EditorWidgets/Select/SelectPreview.js b/packages/netlify-cms-core/src/components/EditorWidgets/Select/SelectPreview.js deleted file mode 100644 index 9517e240..00000000 --- a/packages/netlify-cms-core/src/components/EditorWidgets/Select/SelectPreview.js +++ /dev/null @@ -1,10 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; - -export default function SelectPreview({ value }) { - return
{value ? value.toString() : null}
; -} - -SelectPreview.propTypes = { - value: PropTypes.string, -}; diff --git a/packages/netlify-cms-core/src/components/EditorWidgets/Text/TextPreview.js b/packages/netlify-cms-core/src/components/EditorWidgets/Text/TextPreview.js deleted file mode 100644 index a064e880..00000000 --- a/packages/netlify-cms-core/src/components/EditorWidgets/Text/TextPreview.js +++ /dev/null @@ -1,10 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; - -export default function TextPreview({ value }) { - return
{value}
; -} - -TextPreview.propTypes = { - value: PropTypes.node, -}; diff --git a/packages/netlify-cms-core/src/components/EditorWidgets/index.js b/packages/netlify-cms-core/src/components/EditorWidgets/index.js index 7b27cfa7..1a95caf1 100644 --- a/packages/netlify-cms-core/src/components/EditorWidgets/index.js +++ b/packages/netlify-cms-core/src/components/EditorWidgets/index.js @@ -1,17 +1,8 @@ import { registerWidget } from 'Lib/registry'; import UnknownControl from './Unknown/UnknownControl'; import UnknownPreview from './Unknown/UnknownPreview'; -import NumberControl from './Number/NumberControl'; -import NumberPreview from './Number/NumberPreview'; -import TextControl from './Text/TextControl'; -import TextPreview from './Text/TextPreview'; -import SelectControl from './Select/SelectControl'; -import SelectPreview from './Select/SelectPreview'; import RelationControl from './Relation/RelationControl'; import RelationPreview from './Relation/RelationPreview'; -registerWidget('text', TextControl, TextPreview); -registerWidget('number', NumberControl, NumberPreview); -registerWidget('select', SelectControl, SelectPreview); registerWidget('relation', RelationControl, RelationPreview); registerWidget('unknown', UnknownControl, UnknownPreview); diff --git a/packages/netlify-cms-widget-number/package.json b/packages/netlify-cms-widget-number/package.json new file mode 100644 index 00000000..c40f74c0 --- /dev/null +++ b/packages/netlify-cms-widget-number/package.json @@ -0,0 +1,27 @@ +{ + "name": "netlify-cms-widget-number", + "description": "Widget for editing numberic values in Netlify CMS.", + "version": "2.0.0-alpha.0", + "main": "dist/netlify-cms-widget-number.js", + "license": "MIT", + "keywords": [ + "netlify", + "netlify-cms", + "widget", + "number" + ], + "sideEffects": false, + "scripts": { + "watch": "webpack -w", + "build": "webpack" + }, + "devDependencies": { + "webpack": "^4.16.1", + "webpack-cli": "^3.1.0" + }, + "peerDependencies": { + "netlify-cms-ui-default": "^2.0.0-alpha.0", + "prop-types": "^15.5.10", + "react": "^16.4.1" + } +} diff --git a/packages/netlify-cms-core/src/components/EditorWidgets/Number/NumberControl.js b/packages/netlify-cms-widget-number/src/NumberControl.js similarity index 100% rename from packages/netlify-cms-core/src/components/EditorWidgets/Number/NumberControl.js rename to packages/netlify-cms-widget-number/src/NumberControl.js diff --git a/packages/netlify-cms-widget-number/src/NumberPreview.js b/packages/netlify-cms-widget-number/src/NumberPreview.js new file mode 100644 index 00000000..300a045f --- /dev/null +++ b/packages/netlify-cms-widget-number/src/NumberPreview.js @@ -0,0 +1,13 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { WidgetPreviewContainer } from 'netlify-cms-ui-default'; + +const NumberPreview = ({ value }) => ( + { value } +); + +NumberPreview.propTypes = { + value: PropTypes.node, +}; + +export default NumberPreview; diff --git a/packages/netlify-cms-widget-number/src/index.js b/packages/netlify-cms-widget-number/src/index.js new file mode 100644 index 00000000..c9aab310 --- /dev/null +++ b/packages/netlify-cms-widget-number/src/index.js @@ -0,0 +1,2 @@ +export NumberControl from './NumberControl'; +export NumberPreview from './NumberPreview'; diff --git a/packages/netlify-cms-widget-number/webpack.config.js b/packages/netlify-cms-widget-number/webpack.config.js new file mode 100644 index 00000000..42edd361 --- /dev/null +++ b/packages/netlify-cms-widget-number/webpack.config.js @@ -0,0 +1,3 @@ +const { getConfig } = require('../../scripts/webpack.js'); + +module.exports = getConfig(); diff --git a/packages/netlify-cms-widget-select/package.json b/packages/netlify-cms-widget-select/package.json new file mode 100644 index 00000000..7b8debc1 --- /dev/null +++ b/packages/netlify-cms-widget-select/package.json @@ -0,0 +1,31 @@ +{ + "name": "netlify-cms-widget-select", + "description": "Selectable values widget for Netlify CMS.", + "version": "2.0.0-alpha.0", + "main": "dist/netlify-cms-widget-select.js", + "license": "MIT", + "keywords": [ + "netlify", + "netlify-cms", + "widget", + "select", + "values", + "list" + ], + "sideEffects": false, + "scripts": { + "watch": "webpack -w", + "build": "webpack" + }, + "devDependencies": { + "webpack": "^4.16.1", + "webpack-cli": "^3.1.0" + }, + "peerDependencies": { + "immutable": "^3.7.6", + "netlify-cms-ui-default": "^2.0.0-alpha.0", + "prop-types": "^15.5.10", + "react": "^16.4.1", + "react-immutable-proptypes": "^2.1.0" + } +} diff --git a/packages/netlify-cms-core/src/components/EditorWidgets/Select/SelectControl.js b/packages/netlify-cms-widget-select/src/SelectControl.js similarity index 100% rename from packages/netlify-cms-core/src/components/EditorWidgets/Select/SelectControl.js rename to packages/netlify-cms-widget-select/src/SelectControl.js index 748b39f5..fbbe5bfd 100644 --- a/packages/netlify-cms-core/src/components/EditorWidgets/Select/SelectControl.js +++ b/packages/netlify-cms-widget-select/src/SelectControl.js @@ -1,5 +1,5 @@ -import PropTypes from 'prop-types'; import React from 'react'; +import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { Map } from 'immutable'; diff --git a/packages/netlify-cms-widget-select/src/SelectPreview.js b/packages/netlify-cms-widget-select/src/SelectPreview.js new file mode 100644 index 00000000..c4b5ab2f --- /dev/null +++ b/packages/netlify-cms-widget-select/src/SelectPreview.js @@ -0,0 +1,13 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import { WidgetPreviewContainer } from 'netlify-cms-ui-default'; + +const SelectPreview = ({ value }) => ( + {value ? value.toString() : null} +) + +SelectPreview.propTypes = { + value: PropTypes.string, +}; + +export default SelectPreview; diff --git a/packages/netlify-cms-widget-select/src/index.js b/packages/netlify-cms-widget-select/src/index.js new file mode 100644 index 00000000..d0c60def --- /dev/null +++ b/packages/netlify-cms-widget-select/src/index.js @@ -0,0 +1,2 @@ +export SelectControl from './SelectControl'; +export SelectPreview from './SelectPreview'; diff --git a/packages/netlify-cms-widget-select/webpack.config.js b/packages/netlify-cms-widget-select/webpack.config.js new file mode 100644 index 00000000..42edd361 --- /dev/null +++ b/packages/netlify-cms-widget-select/webpack.config.js @@ -0,0 +1,3 @@ +const { getConfig } = require('../../scripts/webpack.js'); + +module.exports = getConfig(); diff --git a/packages/netlify-cms-widget-text/package.json b/packages/netlify-cms-widget-text/package.json new file mode 100644 index 00000000..ad69352c --- /dev/null +++ b/packages/netlify-cms-widget-text/package.json @@ -0,0 +1,33 @@ +{ + "name": "netlify-cms-widget-text", + "description": "Widget for editing multiline plain string values in Netlify CMS.", + "version": "2.0.0-alpha.0", + "main": "dist/netlify-cms-widget-text.js", + "license": "MIT", + "keywords": [ + "netlify", + "netlify-cms", + "widget", + "string", + "text", + "textarea", + "mulitiline" + ], + "sideEffects": false, + "scripts": { + "watch": "webpack -w", + "build": "webpack" + }, + "dependencies": { + "react-textarea-autosize": "^5.2.0" + }, + "devDependencies": { + "webpack": "^4.16.1", + "webpack-cli": "^3.1.0" + }, + "peerDependencies": { + "netlify-cms-ui-default": "^2.0.0-alpha.0", + "prop-types": "^15.5.10", + "react": "^16.4.1" + } +} diff --git a/packages/netlify-cms-core/src/components/EditorWidgets/Text/TextControl.js b/packages/netlify-cms-widget-text/src/TextControl.js similarity index 90% rename from packages/netlify-cms-core/src/components/EditorWidgets/Text/TextControl.js rename to packages/netlify-cms-widget-text/src/TextControl.js index f7da7a09..1bfe7d10 100644 --- a/packages/netlify-cms-core/src/components/EditorWidgets/Text/TextControl.js +++ b/packages/netlify-cms-widget-text/src/TextControl.js @@ -1,5 +1,5 @@ -import PropTypes from 'prop-types'; import React from 'react'; +import PropTypes from 'prop-types'; import Textarea from 'react-textarea-autosize'; export default class TextControl extends React.Component { @@ -20,8 +20,8 @@ export default class TextControl extends React.Component { * Always update to ensure `react-textarea-autosize` properly calculates * height. Certain situations, such as this widget being nested in a list * item that gets rearranged, can leave the textarea in a minimal height - * state. Always updating should generally be low cost, but this should be - * optimized in the future. + * state. Always updating this particular widget should generally be low cost, + * but this should be optimized in the future. */ shouldComponentUpdate(nextProps) { return true; diff --git a/packages/netlify-cms-widget-text/src/TextPreview.js b/packages/netlify-cms-widget-text/src/TextPreview.js new file mode 100644 index 00000000..5e47b371 --- /dev/null +++ b/packages/netlify-cms-widget-text/src/TextPreview.js @@ -0,0 +1,13 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { WidgetPreviewContainer } from 'netlify-cms-ui-default'; + +const TextPreview = ({ value }) => ( + { value } +) + +TextPreview.propTypes = { + value: PropTypes.node, +}; + +export default TextPreview; diff --git a/packages/netlify-cms-widget-text/src/index.js b/packages/netlify-cms-widget-text/src/index.js new file mode 100644 index 00000000..54082cab --- /dev/null +++ b/packages/netlify-cms-widget-text/src/index.js @@ -0,0 +1,2 @@ +export TextControl from './TextControl'; +export TextPreview from './TextPreview'; diff --git a/packages/netlify-cms-widget-text/webpack.config.js b/packages/netlify-cms-widget-text/webpack.config.js new file mode 100644 index 00000000..42edd361 --- /dev/null +++ b/packages/netlify-cms-widget-text/webpack.config.js @@ -0,0 +1,3 @@ +const { getConfig } = require('../../scripts/webpack.js'); + +module.exports = getConfig();