Skip to content
Permalink
Browse files

apply autolatex and mathjax

  • Loading branch information...
christianp committed Oct 9, 2019
1 parent 83d3e77 commit 4a19bd58de3b55e1ceed82281efa2d0f4a08795e
@@ -8,6 +8,7 @@ import { isRtl } from '../rtl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import Textarea from 'react-textarea-autosize';
import classNames from 'classnames';
import try_replace from '../features/compose/util/autolatex.js';

const textAtCursorMatchesToken = (str, caretPosition) => {
let word;
@@ -77,6 +78,10 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
this.props.onChange(e);
}

onInput = (e) => {
try_replace(e.target);
}

onKeyDown = (e) => {
const { suggestions, disabled } = this.props;
const { selectedSuggestion, suggestionsHidden } = this.state;
@@ -216,6 +221,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
value={value}
onChange={this.onChange}
onKeyDown={this.onKeyDown}
onInput={this.onInput}
onKeyUp={onKeyUp}
onFocus={this.onFocus}
onBlur={this.onBlur}
@@ -94,9 +94,15 @@ export default class StatusContent extends React.PureComponent {
}
}

_renderMathJax () {
const node = this.node;
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node]);
}

componentDidMount () {
this._updateStatusLinks();
this._updateStatusEmojis();
this._renderMathJax();
}

componentDidUpdate () {
@@ -17,6 +17,19 @@
%meta{ name: 'msapplication-config', content: '/browserconfig.xml' }/
%meta{ name: 'theme-color', content: '#282c37' }/
%meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }/
%script{ type: 'text/x-mathjax-config' }
\MathJax.Hub.Config({
\ extensions: ["tex2jax.js"],
\ jax: ["input/TeX", "output/CommonHTML"],
\ tex2jax: {
\ inlineMath: [ ["\\(","\\)"] ],
\ displayMath: [ ["\\[","\\]"] ],
\ processEscapes: true
\ },
\ "HTML-CSS": { availableFonts: ["TeX"] }
\});
%script{:src => "/MathJax/MathJax.js?config=TeX-AMS_CHTML,Safe"}
%title= content_for?(:page_title) ? safe_join([yield(:page_title).chomp.html_safe, title], ' - ') : title
@@ -15,5 +15,7 @@
= javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous'
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
= javascript_pack_tag 'public', integrity: true, crossorigin: 'anonymous'
%script{:src => "/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"}

%body.embed
= yield
@@ -35,7 +35,7 @@ def host_to_url(str)
p.worker_src :self, :blob, assets_host
else
p.connect_src :self, :data, :blob, assets_host, media_host, Rails.configuration.x.streaming_api_base_url
p.script_src :self, assets_host
p.script_src :self, assets_host, :unsafe_eval
p.worker_src :self, :blob, assets_host
end
end

0 comments on commit 4a19bd5

Please sign in to comment.
You can’t perform that action at this time.