Rich Text Editor (WIP) x2
This commit is contained in:
@@ -4,10 +4,8 @@ import {
|
||||
CompositeDecorator,
|
||||
RichUtils,
|
||||
convertToRaw,
|
||||
convertFromRaw,
|
||||
ContentState,
|
||||
} from 'draft-js'
|
||||
import { draftToMarkdown } from 'markdown-draft-js'
|
||||
import draftToMarkdown from '../features/ui/util/draft-to-markdown'
|
||||
import { urlRegex } from '../features/ui/util/url_regex'
|
||||
import classNames from 'classnames/bind'
|
||||
import RichTextEditorBar from './rich_text_editor_bar'
|
||||
@@ -134,7 +132,8 @@ class Composer extends PureComponent {
|
||||
|
||||
const rawObject = convertToRaw(content);
|
||||
const markdownString = draftToMarkdown(rawObject, {
|
||||
preserveNewlines: true,
|
||||
escapeMarkdownCharacters: false,
|
||||
preserveNewlines: false,
|
||||
remarkablePreset: 'commonmark',
|
||||
remarkableOptions: {
|
||||
disable: {
|
||||
@@ -147,6 +146,7 @@ class Composer extends PureComponent {
|
||||
});
|
||||
|
||||
console.log("text:", markdownString)
|
||||
// console.log("html:", html)
|
||||
|
||||
this.props.onChange(null, text, markdownString, selectionStart)
|
||||
}
|
||||
@@ -154,11 +154,12 @@ class Composer extends PureComponent {
|
||||
// **bold**
|
||||
// *italic*
|
||||
// __underline__
|
||||
// ~strikethrough~
|
||||
// # title
|
||||
// ~~strike~~
|
||||
// # header
|
||||
// > quote
|
||||
// `code`
|
||||
// ```code```
|
||||
// ```
|
||||
// code
|
||||
// ```
|
||||
|
||||
focus = () => {
|
||||
this.textbox.editor.focus()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { RichUtils } from 'draft-js'
|
||||
import { defineMessages, injectIntl } from 'react-intl'
|
||||
import classNames from 'classnames/bind'
|
||||
import { me } from '../initial_state'
|
||||
import { makeGetAccount } from '../selectors'
|
||||
@@ -70,10 +69,6 @@ const RTE_ITEMS = [
|
||||
},
|
||||
]
|
||||
|
||||
const messages = defineMessages({
|
||||
follow: { id: 'follow', defaultMessage: 'Follow' },
|
||||
})
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const getAccount = makeGetAccount()
|
||||
const account = getAccount(state, me)
|
||||
@@ -86,13 +81,11 @@ const mapStateToProps = (state) => {
|
||||
}
|
||||
|
||||
export default
|
||||
@injectIntl
|
||||
@connect(mapStateToProps)
|
||||
class RichTextEditorBar extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
editorState: PropTypes.object.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
isPro: PropTypes.bool.isRequired,
|
||||
rteControlsVisible: PropTypes.bool.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
@@ -127,7 +120,7 @@ class RichTextEditorBar extends PureComponent {
|
||||
/>
|
||||
))
|
||||
}
|
||||
<Button
|
||||
{/*<Button
|
||||
backgroundColor='none'
|
||||
color='secondary'
|
||||
onClick={this.handleOnTogglePopoutEditor}
|
||||
@@ -137,7 +130,7 @@ class RichTextEditorBar extends PureComponent {
|
||||
iconClassName={_s.inheritFill}
|
||||
iconSize='12px'
|
||||
radiusSmall
|
||||
/>
|
||||
/>*/}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { createSelector } from 'reselect';
|
||||
import sample from 'lodash.sample';
|
||||
// import sample from 'lodash.sample';
|
||||
import debounce from 'lodash.debounce'
|
||||
import { me, promotions } from '../initial_state';
|
||||
import { dequeueTimeline } from '../actions/timelines';
|
||||
@@ -44,7 +44,7 @@ const mapStateToProps = (state, { timelineId }) => {
|
||||
if (!timelineId) return {}
|
||||
|
||||
const getStatusIds = makeGetStatusIds();
|
||||
const promotion = promotions.length > 0 && sample(promotions.filter(p => p.timeline_id === timelineId));
|
||||
const promotion = false//promotions.length > 0 && sample(promotions.filter(p => p.timeline_id === timelineId));
|
||||
|
||||
const statusIds = getStatusIds(state, {
|
||||
type: timelineId.substring(0, 5) === 'group' ? 'group' : timelineId,
|
||||
|
||||
Reference in New Issue
Block a user