add markdown converter

This commit is contained in:
tykayn 2020-12-31 16:48:13 +01:00 committed by Baptiste Lemoine
parent 01f4fc4c43
commit e4df081141
3 changed files with 16 additions and 1 deletions

View File

@ -20,6 +20,8 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import { length } from 'stringz';
import { countableText } from '../util/counter';
import Icon from 'mastodon/components/icon';
import snarkdown from 'snarkdown';
// import elephantUIPlane from '../../../images/elephant_ui_plane.svg';
// import { mascot } from '../../initial_state';
@ -191,6 +193,12 @@ class ComposeForm extends ImmutablePureComponent {
this.props.onPickEmoji(position, data, needsSpace);
};
convertMarkdown(){
let md = '_this_ is **easy** to `use`.';
let html = snarkdown(md);
console.log(html);
};
render () {
const { intl, onPaste, showSearch } = this.props;
const disabled = this.props.isSubmitting;
@ -202,6 +210,7 @@ class ComposeForm extends ImmutablePureComponent {
} else {
publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish);
}
this.convertMarkdown();
return (
<div className='compose-form'>

View File

@ -125,8 +125,8 @@
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-object-fit-images": "^1.1.2",
"promise.prototype.finally": "^3.1.2",
"postcss-preset-env": "^6.7.0",
"promise.prototype.finally": "^3.1.2",
"prop-types": "^15.5.10",
"punycode": "^2.1.0",
"react": "^16.14.0",
@ -159,6 +159,7 @@
"rimraf": "^3.0.2",
"sass": "^1.30.0",
"sass-loader": "^10.1.0",
"snarkdown": "^2.0.0",
"stacktrace-js": "^2.0.2",
"stringz": "^2.1.0",
"substring-trie": "^1.0.2",

View File

@ -10313,6 +10313,11 @@ snapdragon@^0.8.1:
source-map-resolve "^0.5.0"
use "^3.1.0"
snarkdown@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/snarkdown/-/snarkdown-2.0.0.tgz#b1feb4db91b9f94a8ebbd7a50f3e99aee18b1e03"
integrity sha512-MgL/7k/AZdXCTJiNgrO7chgDqaB9FGM/1Tvlcenenb7div6obaDATzs16JhFyHHBGodHT3B7RzRc5qk8pFhg3A==
sockjs-client@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.4.0.tgz#c9f2568e19c8fd8173b4997ea3420e0bb306c7d5"