Commit 6d1eebdf authored by alain's avatar alain 🐙
Browse files

implement wysiwyg editor and other cms work

parent f3d22b34
......@@ -11,6 +11,16 @@
"attributes": {
"title": {
"type": "string"
},
"colofon": {
"type": "component",
"repeatable": true,
"component": "content.colofon-item"
},
"rows": {
"type": "component",
"repeatable": true,
"component": "content.row"
}
}
}
......@@ -11,6 +11,31 @@
"attributes": {
"title": {
"type": "string"
},
"description": {
"type": "richtext"
},
"link": {
"type": "string"
},
"logo": {
"model": "file",
"via": "related",
"allowedTypes": [
"images",
"files",
"videos"
],
"plugin": "upload",
"required": false
},
"domains": {
"collection": "domain",
"via": "alternative"
},
"use_cases": {
"collection": "use-case",
"via": "alternative"
}
}
}
......@@ -16,6 +16,10 @@
},
"description": {
"type": "richtext"
},
"alternative": {
"via": "domains",
"model": "alternative"
}
}
}
{
"routes": [
{
"method": "GET",
"path": "/header",
"handler": "header.find",
"config": {
"policies": []
}
},
{
"method": "PUT",
"path": "/header",
"handler": "header.update",
"config": {
"policies": []
}
},
{
"method": "DELETE",
"path": "/header",
"handler": "header.delete",
"config": {
"policies": []
}
}
]
}
......@@ -5,12 +5,4 @@
* to customize this model
*/
module.exports = {
lifecycles: {
async afterUpdate() {
if(process.env.NODE_ENV === 'production') {
strapi.services.util.build()
}
},
},
};
module.exports = {};
{
"kind": "singleType",
"collectionName": "headers",
"info": {
"name": "Header"
},
"options": {
"increments": true,
"timestamps": true
},
"attributes": {
"title": {
"type": "string",
"required": true
},
"subtitle": {
"type": "string"
},
"primary_navigation": {
"type": "component",
"repeatable": true,
"component": "header.menu-item"
},
"secondary_navigation": {
"type": "component",
"repeatable": true,
"component": "header.menu-item"
}
}
}
{
"routes": [
{
"method": "GET",
"path": "/menu-items",
"handler": "menu-item.find",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/menu-items/count",
"handler": "menu-item.count",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/menu-items/:id",
"handler": "menu-item.findOne",
"config": {
"policies": []
}
},
{
"method": "POST",
"path": "/menu-items",
"handler": "menu-item.create",
"config": {
"policies": []
}
},
{
"method": "PUT",
"path": "/menu-items/:id",
"handler": "menu-item.update",
"config": {
"policies": []
}
},
{
"method": "DELETE",
"path": "/menu-items/:id",
"handler": "menu-item.delete",
"config": {
"policies": []
}
}
]
}
......@@ -16,6 +16,10 @@
},
"description": {
"type": "richtext"
},
"alternative": {
"via": "use_cases",
"model": "alternative"
}
}
}
{
"collectionName": "components_content_colofon_items",
"info": {
"name": "colofon item",
"icon": "child"
},
"options": {},
"attributes": {
"title": {
"type": "string"
},
"logo": {
"model": "file",
"via": "related",
"allowedTypes": [
"images",
"files",
"videos"
],
"plugin": "upload",
"required": false
},
"link": {
"type": "string"
}
}
}
{
"collectionName": "components_content_columns",
"info": {
"name": "column",
"icon": "align-justify"
},
"options": {},
"attributes": {
"content": {
"type": "richtext"
}
}
}
......@@ -6,10 +6,12 @@
},
"options": {},
"attributes": {
"text": {
"type": "richtext"
"columns": {
"type": "component",
"repeatable": true,
"component": "content.column"
},
"Headers": {
"headers": {
"type": "component",
"repeatable": true,
"component": "content.header"
......
{
"kind": "collectionType",
"collectionName": "menu_items",
"collectionName": "components_header_menu_items",
"info": {
"name": "Menu item"
},
"options": {
"increments": true,
"timestamps": true
"name": "menu_item",
"icon": "bars"
},
"options": {},
"attributes": {
"title": {
"type": "string"
......@@ -17,13 +14,6 @@
},
"link": {
"type": "string"
},
"type": {
"type": "enumeration",
"enum": [
"primary",
"secondary"
]
}
}
}
import React from 'react';
import PropTypes from 'prop-types';
import CKEditor from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
import styled from 'styled-components';
const Wrapper = styled.div`
.ck-editor__main {
min-height: 200px;
> div {
min-height: 200px;
}
}
`;
const config = {
toolbar: ["undo", "redo", "|", "heading", "|", "bold", "italic", "link", "bulletedList", "numberedList", "|", "indent", "outdent", "|", "blockQuote", "insertTable"],
heading: {
options: [
{ model: "paragraph", title: "Paragraph", class: "ck-heading_paragraph" },
{ model: "heading1", view: "h1", title: "Heading 1", class: "ck-heading_heading1" },
{ model: "heading2", view: "h2", title: "Heading 2", class: "ck-heading_heading2" },
{ model: "heading3", view: "h3", title: "Heading 3", class: "ck-heading_heading3" },
{ model: "heading4", view: "h4", title: "Heading 4", class: "ck-heading_heading4" },
{ model: "small", view: "small", title: "Small", class: "ck-heading_small" }
]
}
}
const Editor = ({ onChange, name, value }) => {
console.log(<CKEditor/>);
return (
<Wrapper>
<CKEditor
editor={ClassicEditor}
config={config}
data={value}
onChange={(event, editor) => {
const data = editor.getData();
onChange({ target: { name, value: data } });
}}
/>
</Wrapper>
);
};
Editor.propTypes = {
onChange: PropTypes.func.isRequired,
name: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
};
export default Editor;
\ No newline at end of file
import React from 'react';
import PropTypes from 'prop-types';
import { isEmpty } from 'lodash';
import { Label, InputDescription, InputErrors } from 'strapi-helper-plugin';
import Editor from '../CKEditor';
const WysiwygWithErrors = ({
inputDescription,
errors,
label,
name,
noErrorsDescription,
onChange,
value,
}) => {
let spacer = !isEmpty(inputDescription) ? (
<div style={{ height: '.4rem' }} />
) : (
<div />
);
if (!noErrorsDescription && !isEmpty(errors)) {
spacer = <div />;
}
return (
<div
className="col-12"
style={{
marginBottom: '1.6rem',
fontSize: '1.3rem',
fontFamily: 'Lato',
}}
>
<Label htmlFor={name} message={label} style={{ marginBottom: 10 }} />
<Editor name={name} onChange={onChange} value={value} />
<InputDescription
message={inputDescription}
style={!isEmpty(inputDescription) ? { marginTop: '1.4rem' } : {}}
/>
<InputErrors
errors={(!noErrorsDescription && errors) || []}
name={name}
/>
{spacer}
</div>
);
};
WysiwygWithErrors.defaultProps = {
errors: [],
label: '',
noErrorsDescription: false,
};
WysiwygWithErrors.propTypes = {
errors: PropTypes.array,
inputDescription: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
PropTypes.shape({
id: PropTypes.string,
params: PropTypes.object,
}),
]),
label: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
PropTypes.shape({
id: PropTypes.string,
params: PropTypes.object,
}),
]),
name: PropTypes.string.isRequired,
noErrorsDescription: PropTypes.bool,
onChange: PropTypes.func.isRequired,
value: PropTypes.string.isRequired,
};
export default WysiwygWithErrors;
\ No newline at end of file
......@@ -4,13 +4,15 @@
"version": "0.1.0",
"description": "Strapi backend for publicstack.net",
"scripts": {
"develop": "strapi develop",
"develop": "NODE_ENV=development strapi develop",
"start": "NODE_ENV=production strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"@ckeditor/ckeditor5-build-classic": "^21.0.0",
"@ckeditor/ckeditor5-react": "^2.1.0",
"knex": "<0.20.0",
"sqlite3": "latest",
"strapi": "3.0.6",
......
......@@ -1042,6 +1042,18 @@
dependencies:
yup "^0.27.0"
"@ckeditor/ckeditor5-build-classic@^21.0.0":
version "21.0.0"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-build-classic/-/ckeditor5-build-classic-21.0.0.tgz#f34624fa28edbc4de917eee326db7de1f09c9c63"
integrity sha512-IYPXmc5Np7SzJVJbGNZk3OZEHnZ/WylbN1aFyfYdKMch9Be8mrCB9QQOqfsAEKD4SjXujYvn1jL0mM/EPZ8ECw==
"@ckeditor/ckeditor5-react@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-react/-/ckeditor5-react-2.1.0.tgz#f612546a5a328899a436d71b72ffd632600049e8"
integrity sha512-rlHjRKhwP9tNK0Yj2UJShL14mRfxLPgJ+Pv6zTv/Mvmd4wrwGnJf+5ybOAGK92S02hP1cXH+9km+PRO1b4V+ng==
dependencies:
prop-types "^15.6.1"
"@emotion/cache@^10.0.27", "@emotion/cache@^10.0.9":
version "10.0.29"
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-10.0.29.tgz#87e7e64f412c060102d589fe7c6dc042e6f9d1e0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment