From bd45f8c31146f24038138e52ba0f62a1f0642087 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Fri, 6 Oct 2023 19:46:03 -0700 Subject: [PATCH] fix linting errors --- .../flavours/glitch/actions/compose.js | 6 +- .../glitch/components/autosuggest_input.jsx | 4 +- ...suggest_latex.js => autosuggest_latex.jsx} | 9 +-- .../components/autosuggest_textarea.jsx | 6 +- .../glitch/components/status_content.jsx | 8 ++- .../glitch/components/status_expand_button.js | 71 ------------------- .../components/status_expand_button.jsx | 71 +++++++++++++++++++ .../compose/components/compose_form.jsx | 2 +- .../containers/latex_dropdown_container.js | 4 +- .../compose/util/autolatex/autolatex.js | 46 +++++++----- .../features/compose/util/autolatex/data.js | 8 +-- .../features/compose/util/autolatex/index.js | 2 +- .../glitch/styles/components/status.scss | 1 - app/javascript/mastodon/actions/compose.js | 7 +- ...suggest_latex.js => autosuggest_latex.jsx} | 9 +-- .../components/autosuggest_textarea.jsx | 4 +- .../mastodon/components/status_content.jsx | 5 +- .../containers/latex_dropdown_container.js | 4 +- .../compose/util/autolatex/autolatex.js | 46 +++++++----- .../features/compose/util/autolatex/data.js | 8 +-- .../features/compose/util/autolatex/index.js | 2 +- .../styles/mastodon/components.scss | 8 ++- app/services/bootstrap_timeline_service.rb | 2 +- app/views/layouts/application.html.haml | 3 - app/views/layouts/embedded.html.haml | 2 - 25 files changed, 183 insertions(+), 155 deletions(-) rename app/javascript/flavours/glitch/components/{autosuggest_latex.js => autosuggest_latex.jsx} (77%) delete mode 100644 app/javascript/flavours/glitch/components/status_expand_button.js create mode 100644 app/javascript/flavours/glitch/components/status_expand_button.jsx rename app/javascript/mastodon/components/{autosuggest_latex.js => autosuggest_latex.jsx} (77%) diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index 036c33882f31f7..f5f68f10faa20c 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -9,12 +9,14 @@ import { tagHistory } from 'flavours/glitch/settings'; import { recoverHashtags } from 'flavours/glitch/utils/hashtag'; import resizeImage from 'flavours/glitch/utils/resize_image'; +import { tex_to_unicode } from '../features/compose/util/autolatex/autolatex'; + import { showAlert, showAlertForError } from './alerts'; import { useEmoji } from './emojis'; import { importFetchedAccounts, importFetchedStatus } from './importer'; import { openModal } from './modal'; import { updateTimeline } from './timelines'; -import { tex_to_unicode } from '../features/compose/util/autolatex/autolatex.js'; + /** @type {AbortController | undefined} */ let fetchComposeSuggestionsAccountsController; @@ -570,7 +572,7 @@ const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => const fetchComposeSuggestionsLatex = (dispatch, getState, token) => { const start_delimiter = token.slice(0,2); const end_delimiter = {'\\(': '\\)', '\\[': '\\]'}[start_delimiter]; - let expression = token.slice(2).replace(/\\[\)\]]?$/,''); + let expression = token.slice(2).replace(/\\[)\]]?$/,''); let brace = 0; for(let i=0;i; key = suggestion.id; } else if (suggestion.type === 'latex') { - inner = ; + inner = ; key = 'latex' + suggestion.expression; } diff --git a/app/javascript/flavours/glitch/components/autosuggest_latex.js b/app/javascript/flavours/glitch/components/autosuggest_latex.jsx similarity index 77% rename from app/javascript/flavours/glitch/components/autosuggest_latex.js rename to app/javascript/flavours/glitch/components/autosuggest_latex.jsx index 02fe0605ef749d..ef65d493895089 100644 --- a/app/javascript/flavours/glitch/components/autosuggest_latex.js +++ b/app/javascript/flavours/glitch/components/autosuggest_latex.jsx @@ -1,7 +1,5 @@ -import React from 'react'; import PropTypes from 'prop-types'; - -const assetHost = process.env.CDN_HOST || ''; +import React from 'react'; export default class AutosuggestLatex extends React.PureComponent { @@ -15,6 +13,9 @@ export default class AutosuggestLatex extends React.PureComponent { componentDidMount() { try { + // Loaded in script tag on page. not great but we couldn't figure out + // How to use MathJax as a module + // eslint-disable-next-line no-undef MathJax.typeset([this.node]); } catch(e) { console.error(e); @@ -28,7 +29,7 @@ export default class AutosuggestLatex extends React.PureComponent { return (
\({latex.expression}\) -
+
Convert to unicode
); diff --git a/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx b/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx index cfd6b359d172b5..7b4c2777d438b8 100644 --- a/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx +++ b/app/javascript/flavours/glitch/components/autosuggest_textarea.jsx @@ -18,9 +18,9 @@ const textAtCursorMatchesToken = (str, caretPosition) => { let left; let right; - left = str.slice(0, caretPosition).search(/\\[\(\[](?:(?!\\[\)\]]).)*(?:\\[\)\]])?$/); + left = str.slice(0, caretPosition).search(/\\[([](?:(?!\\[)]]).)*(?:\\[)\]])?$/); if (left >= 0) { - right = str.slice(caretPosition).search(/\\[\)\]]/); + right = str.slice(caretPosition).search(/\\[)\]]/); if (right < 0) { word = str.slice(left); } else { @@ -205,7 +205,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { inner = ; key = suggestion.id; } else if (suggestion.type === 'latex') { - inner = ; + inner = ; key = suggestion.expression; } diff --git a/app/javascript/flavours/glitch/components/status_content.jsx b/app/javascript/flavours/glitch/components/status_content.jsx index 4da4dcc18cb1bf..ff31a38baa621f 100644 --- a/app/javascript/flavours/glitch/components/status_content.jsx +++ b/app/javascript/flavours/glitch/components/status_content.jsx @@ -8,12 +8,11 @@ import classnames from 'classnames'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; -import { Icon } from 'flavours/glitch/components/icon'; import { autoPlayGif, languages as preloadedLanguages } from 'flavours/glitch/initial_state'; import { decode as decodeIDNA } from 'flavours/glitch/utils/idna'; -import StatusExpandButton from './status_expand_button'; import Permalink from './permalink'; +import StatusExpandButton from './status_expand_button'; const textMatchesTarget = (text, origin, host) => { return (text === origin || text === host @@ -239,11 +238,14 @@ class StatusContent extends PureComponent { _renderMathJax() { const {status} = this.props; const contentHtml = status.get('contentHtml'); - if(this.last_contentHtml == contentHtml) { + if(this.last_contentHtml === contentHtml) { return; } this.last_contentHtml = contentHtml; try { + // Loaded in script tag on page. not great but we couldn't figure out + // How to use MathJax as a module + // eslint-disable-next-line no-undef MathJax.typeset([this.contentsNode]); } catch(e) { console.error(e); diff --git a/app/javascript/flavours/glitch/components/status_expand_button.js b/app/javascript/flavours/glitch/components/status_expand_button.js deleted file mode 100644 index 3f5d8638640147..00000000000000 --- a/app/javascript/flavours/glitch/components/status_expand_button.js +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -import { useState, useEffect } from 'react'; -import PropTypes from 'prop-types'; -import { FormattedMessage } from 'react-intl'; -import Icon from './icon'; - - -const StatusExpandButton=( - { - hidden, - handleSpoilerClick, - mediaIcons, - }, -)=>{ - const makeToggleText = () => { - let newText; - if (hidden) { - newText = [ - , - ]; - if (mediaIcons) { - mediaIcons.forEach((mediaIcon, idx) => { - newText.push( -