aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-04-06 17:03:01 +0000
committerterminaldweller <thabogre@gmail.com>2022-04-06 17:03:01 +0000
commitd699414c285c0820a8994a6e876e10ada3f45773 (patch)
treed924eaf0650a74268b8d4413e17e808b7cac668d
parentno crawlers (diff)
downloadmdrtl-d699414c285c0820a8994a6e876e10ada3f45773.tar.gz
mdrtl-d699414c285c0820a8994a6e876e10ada3f45773.zip
wip
-rw-r--r--spring-front/README.md79
-rw-r--r--spring-front/src/components/Editor.js38
-rw-r--r--spring-front/src/index.css3
3 files changed, 33 insertions, 87 deletions
diff --git a/spring-front/README.md b/spring-front/README.md
index 58beeac..153ba71 100644
--- a/spring-front/README.md
+++ b/spring-front/README.md
@@ -1,70 +1,9 @@
-# Getting Started with Create React App
-
-This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
-
-## Available Scripts
-
-In the project directory, you can run:
-
-### `npm start`
-
-Runs the app in the development mode.\
-Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
-
-The page will reload when you make changes.\
-You may also see any lint errors in the console.
-
-### `npm test`
-
-Launches the test runner in the interactive watch mode.\
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
-
-### `npm run build`
-
-Builds the app for production to the `build` folder.\
-It correctly bundles React in production mode and optimizes the build for the best performance.
-
-The build is minified and the filenames include the hashes.\
-Your app is ready to be deployed!
-
-See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
-
-### `npm run eject`
-
-**Note: this is a one-way operation. Once you `eject`, you can't go back!**
-
-If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
-
-Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
-
-You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
-
-## Learn More
-
-You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
-
-To learn React, check out the [React documentation](https://reactjs.org/).
-
-### Code Splitting
-
-This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
-
-### Analyzing the Bundle Size
-
-This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
-
-### Making a Progressive Web App
-
-This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
-
-### Advanced Configuration
-
-This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
-
-### Deployment
-
-This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
-
-### `npm run build` fails to minify
-
-This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
+# mdrtl
+An RTL markdown editor. The front-end is usable on its own.<br/>
+A simple:<br/>
+```sh
+docker-compose up
+```
+should get things working.<br/>
+By default its served on port 7080 with a self-signed certificate for localhost.<br/>
+A live instance is available on [here](https://editor.terminaldweller.com) with the same certificate as mentioned above.<br/>
diff --git a/spring-front/src/components/Editor.js b/spring-front/src/components/Editor.js
index c02bdbe..30a11ec 100644
--- a/spring-front/src/components/Editor.js
+++ b/spring-front/src/components/Editor.js
@@ -6,6 +6,8 @@ import "highlight.js/styles/devibeans.css";
import markdown from "highlight.js/lib/languages/markdown.js";
import javascript from "highlight.js/lib/languages/javascript.js";
import python from "highlight.js/lib/languages/python.js";
+import C from "highlight.js/lib/languages/c.js";
+import bash from "highlight.js/lib/languages/bash.js";
import "../index.css";
import mit from "markdown-it";
import mithljs from "markdown-it-highlightjs";
@@ -16,15 +18,18 @@ import katex from "katex";
hljs.registerLanguage("markdown", markdown);
hljs.registerLanguage("javascript", javascript);
hljs.registerLanguage("python", python);
+hljs.registerLanguage("c", C);
+hljs.registerLanguage("bash", bash);
-mit({ html: true });
-mit().use(mittexmath, {
- engine: katex,
- delimiters: "gitlab",
- katexOptions: { macros: { "\\RR": "\\mathbb{R}" } },
-});
-mit().use(mitmmdtable);
-mit().use(mithljs, { inline: true, auto: false, code: false, hljs: hljs });
+const md = new mit({ html: true })
+ .enable(["table"])
+ .use(mittexmath, {
+ engine: katex,
+ delimiters: "gitlab",
+ katexOptions: { macros: { "\\RR": "\\mathbb{R}" } },
+ })
+ .use(mitmmdtable)
+ .use(mithljs, { inline: true, auto: true, code: true, hljs: hljs });
export default class Editor extends React.Component {
constructor(props) {
@@ -41,17 +46,16 @@ export default class Editor extends React.Component {
// TODO-use web worker instead
updateCodeSyntaxHighlighting() {
- // document.querySelectorAll("pre code").forEach((block) => {
- // console.log(block);
- // hljs.highlightElement(block);
- // });
- hljs.highlightAll();
+ document.querySelectorAll("pre code").forEach((block) => {
+ console.log(block);
+ hljs.highlightElement(block);
+ });
+ // hljs.highlightAll();
}
// TODO-use web worker instead
parseMarkdown(event) {
let element = document.getElementById("markdown-placeholder");
- let md = new mit();
let htm = md.render(event.target.value);
element.innerHTML = htm;
}
@@ -116,9 +120,9 @@ export default class Editor extends React.Component {
direction="rtl"
></textarea>
</div>
- <div className="split right">
- <div direction="rtl" id="markdown-placeholder"></div>
- </div>
+ <a className="split right">
+ <a direction="rtl" id="markdown-placeholder"></a>
+ </a>
</div>
);
}
diff --git a/spring-front/src/index.css b/spring-front/src/index.css
index 9715148..732a794 100644
--- a/spring-front/src/index.css
+++ b/spring-front/src/index.css
@@ -49,6 +49,7 @@ pre,textarea,code {
margin: 0px;
border: 0px;
padding: 0px;
+ overflow-y: scroll;
}
#editor, #highlight {
@@ -62,6 +63,7 @@ pre,textarea,code {
margin: 0px;
border: 0px;
padding: 0px;
+ overflow-y: scroll;
}
#editor {
@@ -82,4 +84,5 @@ pre,textarea,code {
direction: rtl;
overflow-wrap: break-word;
white-space: pre-wrap;
+ overflow-y: scroll;
}