Skip to content
Snippets Groups Projects
Commit 491880f7 authored by Jure's avatar Jure
Browse files

Merge branch 'remove_unmaintained_components' into 'master'

chore: remove unmaintained Draft-based components

See merge request pubsweet/pubsweet!434
parents 4f2bf5f6 b07198bb
No related branches found
No related tags found
No related merge requests found
Showing
with 46 additions and 347 deletions
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="0.3.7"></a>
## [0.3.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-draft@0.3.6...pubsweet-component-draft@0.3.7) (2018-04-03)
**Note:** Version bump only for package pubsweet-component-draft
<a name="0.3.6"></a>
## [0.3.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-draft@0.3.5...pubsweet-component-draft@0.3.6) (2018-03-19)
**Note:** Version bump only for package pubsweet-component-draft
<a name="0.3.5"></a>
## [0.3.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-draft@0.3.4...pubsweet-component-draft@0.3.5) (2018-03-05)
### Bug Fixes
* **components:** make styleguide work (mostly) ([d036681](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/d036681))
<a name="0.3.4"></a>
## [0.3.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-draft@0.3.3...pubsweet-component-draft@0.3.4) (2018-02-16)
**Note:** Version bump only for package pubsweet-component-draft
import React from 'react'
import PropTypes from 'prop-types'
import { Editor, EditorState, convertToRaw, convertFromRaw } from 'draft-js'
export default class Draft extends React.Component {
constructor(props) {
super(props)
let editorState
this.props.actions.getCollections().then(result =>
this.props.actions.getFragment(result.collections[0], {
id: this.props.id,
}),
)
if (props.fragment && props.fragment.source) {
const content = convertFromRaw(props.fragment.source)
editorState = EditorState.createWithContent(content)
} else {
editorState = EditorState.createEmpty()
}
this.state = { editorState }
this.onChange = this.onChange.bind(this)
}
componentWillReceiveProps(nextProps) {
let editorState
if (
nextProps.fragment &&
nextProps.fragment.source &&
!this.props.fragment
) {
const content = convertFromRaw(nextProps.fragment.source)
editorState = EditorState.createWithContent(content)
this.setState({ editorState })
}
}
onChange(editorState) {
this.setState({ editorState })
const fragment = Object.assign(this.props.fragment, {
source: convertToRaw(editorState.getCurrentContent()),
})
this.props.actions.updateFragment(this.props.blog, fragment)
}
render() {
const { editorState } = this.state
return <Editor editorState={editorState} onChange={this.onChange} />
}
}
Draft.propTypes = {
/** ID of fragment to edit */
id: PropTypes.string,
/** Collection that fragment belongs to */
blog: PropTypes.object,
/** Optional existing fragment */
fragment: PropTypes.object,
/** Bound action creators */
actions: PropTypes.object,
}
Draft.js text editor
```js
const dummy = () => new Promise(() => null)
;<Draft
id="1"
blog={{ id: '2' }}
fragment={{}}
actions={{ getCollections: dummy, updateFragment: dummy }}
/>
```
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Actions from 'pubsweet-client/src/actions'
import Draft from './Draft'
function mapStateToProps(state, props) {
return {
blog: state.collections[0],
id: props.match.params.id,
fragment: state.fragments[props.match.params.id],
}
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(Actions, dispatch),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Draft)
module.exports = {
frontend: {
components: [() => require('./DraftContainer')],
},
}
{
"name": "pubsweet-component-draft",
"version": "0.3.7",
"description": "Basic Draft.js component for PubSweet",
"main": "index.js",
"author": "Collaborative Knowledge Foundation",
"license": "MIT",
"dependencies": {
"draft-js": "^0.10.0",
"prop-types": "^15.5.10",
"react-redux": "^5.0.6",
"redux": "^3.7.2"
},
"peerDependencies": {
"pubsweet-client": ">=1.0.0",
"react": ">=15"
},
"repository": {
"type": "git",
"url": "https://gitlab.coko.foundation/pubsweet/pubsweet",
"path": "Draft.js"
}
}
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="0.2.4"></a>
## [0.2.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-medium-draft@0.2.3...pubsweet-component-medium-draft@0.2.4) (2018-04-03)
**Note:** Version bump only for package pubsweet-component-medium-draft
<a name="0.2.3"></a>
## [0.2.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-medium-draft@0.2.2...pubsweet-component-medium-draft@0.2.3) (2018-02-16)
**Note:** Version bump only for package pubsweet-component-medium-draft
import { ImageSideButton, Block, addNewBlock } from 'medium-draft'
export default function customImageSideButton(fileUpload) {
class CustomImageSideButton extends ImageSideButton {
onChange(e) {
const file = e.target.files[0]
if (file.type.indexOf('image/') === 0) {
// This is a post request to server endpoint with image as `image`
fileUpload(file).then(response => {
this.props.setEditorState(
addNewBlock(this.props.getEditorState(), Block.IMAGE, {
src: response.file,
}),
)
})
}
this.props.close()
}
}
return CustomImageSideButton
}
import React from 'react'
import PropTypes from 'prop-types'
import { convertToRaw } from 'draft-js'
import { Editor, createEditorState } from 'medium-draft'
import mediumDraftExporter from 'medium-draft/lib/exporter'
import 'medium-draft/lib/index.css'
import customImageSideButton from './CustomImageSideButton'
import './styles.scss'
export default class MediumDraft extends React.Component {
constructor(props) {
super(props)
let editorState
if (props.fragment && props.fragment.source) {
editorState = createEditorState(props.fragment.source)
} else {
editorState = createEditorState()
}
if (this.props.blog) {
this.props.actions.getCollections().then(result =>
this.props.actions.getFragment(this.props.blog, {
id: this.props.fragmentId,
}),
)
}
this.state = { editorState }
this.onChange = this.onChange.bind(this)
}
componentDidMount() {
this.editorElement.focus()
}
onChange(editorState) {
this.setState({ editorState })
const fragment = Object.assign(this.props.fragment, {
source: convertToRaw(editorState.getCurrentContent()),
presentation: mediumDraftExporter(editorState.getCurrentContent()),
})
this.props.actions.updateFragment(this.props.blog, fragment)
}
render() {
const { editorState } = this.state
return (
<Editor
editorState={editorState}
onChange={this.onChange}
ref={el => (this.editorElement = el)}
sideButtons={[
{
title: 'Image',
component: customImageSideButton(this.props.actions.fileUpload),
},
]}
/>
)
}
}
MediumDraft.propTypes = {
fragmentId: PropTypes.string.isRequired,
blog: PropTypes.object,
fragment: PropTypes.object,
actions: PropTypes.object,
}
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import Actions from 'pubsweet-client/src/actions'
import MediumDraft from './MediumDraft'
function mapStateToProps(state, props) {
const fragmentId = props.match.params.id
return {
fragmentId,
blog: state.collections[0],
id: fragmentId,
fragment: state.fragments[fragmentId],
}
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(Actions, dispatch),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(MediumDraft)
module.exports = {
frontend: {
components: [() => require('./MediumDraftContainer')],
},
}
{
"name": "pubsweet-component-medium-draft",
"version": "0.2.4",
"description": "Medium Draft component for PubSweet",
"main": "index.js",
"author": "Collaborative Knowledge Foundation",
"license": "MIT",
"dependencies": {
"draft-convert": "^1.4.8",
"font-awesome": "^4.7.0",
"medium-draft": "^0.5.2",
"prop-types": "^15.5.10",
"react-redux": "^5.0.6",
"redux": "^3.7.2"
},
"peerDependencies": {
"pubsweet-client": ">=1.0.0",
"react": ">=16"
},
"repository": {
"type": "git",
"url": "https://gitlab.coko.foundation/pubsweet/pubsweet",
"path": "MediumDraft"
}
}
$fa-font-path: '~font-awesome/fonts';
@import '~font-awesome/scss/font-awesome.scss';
.md-RichEditor-root {
margin-left: auto;
margin-right: auto;
@media (min-width: 768px) {
width: 750px;
}
@media (min-width: 992px) {
width: 970px;
}
@media (min-width: 1200px) {
width: 1170px;
}
}
......@@ -11729,11 +11729,57 @@ public-encrypt@^4.0.0:
parse-asn1 "^5.0.0"
randombytes "^2.0.1"
 
pubsweet-component-form-group@1.1.25:
version "1.1.25"
resolved "https://registry.yarnpkg.com/pubsweet-component-form-group/-/pubsweet-component-form-group-1.1.25.tgz#ba93e042483ce7097f799966322940d6b67f2b11"
integrity sha512-7QmaHh/DbGcOt5jEx7DfQiWwnL7+CHQWm9DLRC9yS7dZ5yFJGsyLpzerAUbFDBlUftcrufymKDbzICbBj0AaaA==
dependencies:
joi-browser "^13.4.0"
prop-types "^15.5.10"
pubsweet-server "^10.0.0"
pubsweet-component-login@1.1.17:
version "1.1.17"
resolved "https://registry.yarnpkg.com/pubsweet-component-login/-/pubsweet-component-login-1.1.17.tgz#8ea00b85e73a1068fbd6e1d7a4173ba3cfc17c42"
integrity sha512-1M5xBtUGi+nWoknzSYQ8C7RAo3XCPCJzgdOQaKi2Cl1iIKHZy0wsNXlK3gv/3dldJ47QLSL2E6sKnlwy2YijLQ==
dependencies:
"@pubsweet/ui" "^8.7.0"
prop-types "^15.5.10"
react-redux "^5.0.6"
react-router-dom "^4.2.2"
react-router-redux "^5.0.0-alpha.9"
recompose "^0.26.0"
redux-form "^7.0.3"
pubsweet-component-medium-draft@^0.2.3:
version "0.2.4"
resolved "https://registry.yarnpkg.com/pubsweet-component-medium-draft/-/pubsweet-component-medium-draft-0.2.4.tgz#9877c23538fe22915e6b6552608f905edbb70fc9"
integrity sha512-WwaCBdCHW7OtaxJ/Et+ke0xH6+XKjkgQ7TZqs2jv7QYXJ/psD+jVpXFVv5+RNY2wxZbhXWd0vC5ddeewORtwhA==
dependencies:
draft-convert "^1.4.8"
font-awesome "^4.7.0"
medium-draft "^0.5.2"
prop-types "^15.5.10"
react-redux "^5.0.6"
redux "^3.7.2"
pubsweet-component-pepper-theme@^0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/pubsweet-component-pepper-theme/-/pubsweet-component-pepper-theme-0.0.5.tgz#eb39aafbab8e1a737752b6c5ed7ef057ead414cc"
integrity sha512-b84iM59NMjAqKWbKs2/HSNrwFgb4/siOaXHqyfzs4Z+b+/rO1WthUGjJ4h8Uq3GeuTSPSG8QmdraDyPYHPDDQg==
 
pubsweet-component-posts-manager@1.0.40:
version "1.0.40"
resolved "https://registry.yarnpkg.com/pubsweet-component-posts-manager/-/pubsweet-component-posts-manager-1.0.40.tgz#ce757fde0ffbedafe441229b11ad4c97b0a72110"
integrity sha512-hqsltbexB1iw1/l7E/uHq3VlxA5hw+a1gkdpCdzZ5MBawVln/Db6Tme4zxXSkjjBC73NZh/QZ+ABgDI3aUBOiQ==
dependencies:
"@pubsweet/ui" "^8.7.0"
prop-types "^15.5.10"
pubsweet-component-form-group "^1.1.25"
react-redux "^5.0.6"
react-router-dom "^4.2.2"
redux "^3.7.2"
pubsweet-theme-plugin@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/pubsweet-theme-plugin/-/pubsweet-theme-plugin-0.0.3.tgz#1773543a95ed9f56eb8b14f13f24496e034d140b"
......
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