Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch editor #3862

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/components/elements/PostCategoryBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class PostCategoryBanner extends React.Component {
Posting to {community ? 'Community: ' : ''}
<span className="smallLabel">{label}</span>
</small>
{this.props.editorButton}
</div>
{/*
<div className="categoryName">
Expand Down
2 changes: 2 additions & 0 deletions src/app/components/elements/PostCategoryBanner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

margin: .5em 0 1em;
.postTo {
display: flex;
justify-content: space-between;
small {
font-size: 100%;
color: #666;
Expand Down
16 changes: 12 additions & 4 deletions src/app/components/elements/ReplyEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ class ReplyEditor extends React.Component {
username={username}
onCancel={this.shiftTagInput.bind(this)}
onUndo={this.unshiftTagInput.bind(this)}
editorButton={this.props.editorButton}
/>
)}
<div className="column small-12">
Expand Down Expand Up @@ -753,10 +754,17 @@ class ReplyEditor extends React.Component {
isEdit={isEdit}
tabIndex={3}
/>
<div className="error">
{(tags.touched || tags.value) &&
tags.error}&nbsp;
</div>
{(tags.touched || tags.value) &&
tags.error ? (
<div className="error">
{(tags.touched || tags.value) &&
tags.error}&nbsp;
</div>
) : (
<div className="tap_input_tips">
{tt('g.tag_tips')}
</div>
)}
</span>
)}
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/elements/ReplyEditor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,8 @@
.Dropdown__root___1B9ta {
color: black!important;
}

.tap_input_tips {
color: #06D6A9;
margin-bottom: 10px;
}
17 changes: 13 additions & 4 deletions src/app/components/elements/ReplyEditorNew.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ class ReplyEditorNew extends React.Component {
username={username}
onCancel={this.shiftTagInput.bind(this)}
onUndo={this.unshiftTagInput.bind(this)}
editorButton={this.props.editorButton}
/>
)}
<div className="column small-12">
Expand Down Expand Up @@ -677,10 +678,17 @@ class ReplyEditorNew extends React.Component {
isEdit={isEdit}
tabIndex={3}
/>
<div className="error">
{(tags.touched || tags.value) &&
tags.error}&nbsp;
</div>
{(tags.touched || tags.value) &&
tags.error ? (
<div className="error">
{(tags.touched || tags.value) &&
tags.error}&nbsp;
</div>
) : (
<div className="tap_input_tips">
{tt('g.tag_tips')}
</div>
)}
</span>
)}
</div>
Expand Down Expand Up @@ -863,6 +871,7 @@ export default formId =>
if (isStory && jsonMetadata && jsonMetadata.tags) {
tags = OrderedSet([category, ...jsonMetadata.tags]).join(' ');
}
console.log(tags);
let isNSFWCommunity = false;
isNSFWCommunity = state.global.getIn([
'community',
Expand Down
49 changes: 44 additions & 5 deletions src/app/components/pages/SubmitPost.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import ReplyEditor from 'app/components/elements/ReplyEditor';
import { SUBMIT_FORM_ID } from 'shared/constants';
import Callout from 'app/components/elements/Callout';
import * as appActions from 'app/redux/AppReducer';
import tt from 'counterpart';

const formId = SUBMIT_FORM_ID;
const SubmitReplyEditor = ReplyEditor(formId);
const SubmitReplyEditorNew = ReplyEditorNew(formId);

function _redirect_url(operations) {
try {
Expand All @@ -24,24 +26,61 @@ function _redirect_url(operations) {
class SubmitPost extends React.Component {
constructor() {
super();
this.state = {
editorNew: false,
};
this.success = operations => {
localStorage.removeItem('replyEditorData-' + formId);
browserHistory.push(_redirect_url(operations));
};
}

switchEditor() {
this.setState({
editorNew: !this.state.editorNew,
});
}

componentWillMount() {
this.props.setRouteTag();
}
render() {
if (!this.props.username) {
return <Callout>Log in to make a post.</Callout>;
}

const SwitchButton = (
<span
style={{
background: '#06D6A9',
color: '#fff',
fontSize: '14px',
borderRadius: '8px',
padding: '8px 10px',
cursor: 'pointer',
}}
onClick={this.switchEditor.bind(this)}
>{`${
this.state.editorNew
? tt('g.switch_old_editor')
: tt('g.switch_new_editor')
}`}</span>
);
return (
<SubmitReplyEditor
type="submit_story"
successCallback={this.success}
/>
<div>
{this.state.editorNew ? (
<SubmitReplyEditorNew
type="submit_story"
successCallback={this.success}
editorButton={SwitchButton}
/>
) : (
<SubmitReplyEditor
type="submit_story"
successCallback={this.success}
editorButton={SwitchButton}
/>
)}
</div>
);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,11 @@
"many_followers": "%(count)s Followers",
"many_posts": "%(count)s Posts",
"search_history": "History",
"announcement": "Announcement"
"announcement": "Announcement",
"switch_new_editor": "Switch to new editor",
"switch_old_editor": "Switch to old editor",
"tag_tips":
"Tags must only contain lower case letters, numbers, and hyphens. They must be no more than 24 characters which start with a letter and end with a letter or a number."
},
"navigation": {
"about": "About Steemit, Inc.",
Expand Down
6 changes: 5 additions & 1 deletion src/app/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@
"many_followers": "%(count)s个关注者",
"many_posts": "%(count)s个帖子",
"search_history": "搜索历史",
"announcement": "公告"
"announcement": "公告",
"switch_new_editor": "切换新版编辑器",
"switch_old_editor": "切换旧版编辑器",
"tag_tips":
"标签只能包含小写字母,数字和破折号。长度不能超过24个字符,请以字母开头,以字母或数字结尾。"
},
"navigation": {
"about": "关于",
Expand Down