Run format.

This commit is contained in:
Tom Alexander 2024-01-21 21:11:38 -05:00
parent 8c3dd2cee3
commit 0d0a99c73b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 97 additions and 89 deletions

View File

@ -1,10 +1,8 @@
import React, { useState } from 'react'; import React, { useState } from "react";
import './Editor.css'; import "./Editor.css";
import {Highlight} from './highlight'; import { Highlight } from "./highlight";
function Editor({ function Editor({ defaultValue = "I have a text value." }) {
defaultValue = "I have a text value."
}) {
function handleChange(event: React.ChangeEvent<HTMLTextAreaElement>) { function handleChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
console.log(event.target.value); console.log(event.target.value);
setValue(event.target.value); setValue(event.target.value);
@ -27,13 +25,17 @@ function Editor({
} }
if (highlights.length === 0) { if (highlights.length === 0) {
addHighlight(1,5); addHighlight(1, 5);
} }
return ( return (
<div className="Editor"> <div className="Editor">
<div className="Editor-textwrapper"> <div className="Editor-textwrapper">
<textarea onChange={handleChange} className="Editor-textarea" value={value} /> <textarea
onChange={handleChange}
className="Editor-textarea"
value={value}
/>
<div className="Editor-underlay">{value}</div> <div className="Editor-underlay">{value}</div>
</div> </div>
<div className="Editor-ast"></div> <div className="Editor-ast"></div>

View File

@ -1,11 +1,11 @@
class Highlight { class Highlight {
start: number; start: number;
end: number; end: number;
constructor(start: number, end: number) { constructor(start: number, end: number) {
this.start = start; this.start = start;
this.end = end; this.end = end;
} }
} }
export { Highlight }; export { Highlight };

View File

@ -1,9 +1,17 @@
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import init, { parse_org } from "../../organic/target/wasm32-unknown-unknown/js/wasm"; import init, {
import Editor from './Editor'; parse_org,
} from "../../organic/target/wasm32-unknown-unknown/js/wasm";
import Editor from "./Editor";
init().then(() => { init().then(() => {
console.log(parse_org("foo")); console.log(parse_org("foo"));
ReactDOM.render(<><h1>Hello, world!</h1><Editor /></>, document.getElementById("root")); ReactDOM.render(
<>
<h1>Hello, world!</h1>
<Editor />
</>,
document.getElementById("root"),
);
}); });

View File

@ -11,9 +11,7 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"noImplicitAny": true, "noImplicitAny": true,
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true,
}, },
"include": [ "include": ["src"],
"src"
]
} }

View File

@ -2,83 +2,83 @@ const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path"); const path = require("path");
const CSSModuleLoader = { const CSSModuleLoader = {
loader: 'css-loader', loader: "css-loader",
options: { options: {
modules: true, modules: true,
importLoaders: 2, importLoaders: 2,
sourceMap: true, sourceMap: true,
} },
}; };
const CSSLoader = { const CSSLoader = {
loader: 'css-loader', loader: "css-loader",
options: { options: {
modules: "global", modules: "global",
importLoaders: 2, importLoaders: 2,
sourceMap: true, sourceMap: true,
} },
}; };
const PostCSSLoader = { const PostCSSLoader = {
loader: 'postcss-loader', loader: "postcss-loader",
options: { options: {
sourceMap: true, sourceMap: true,
} },
}; };
const styleLoader = 'style-loader'; const styleLoader = "style-loader";
module.exports = { module.exports = {
entry: "./src/index.tsx", entry: "./src/index.tsx",
output: { output: {
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, "dist"),
filename: "bundle.[hash].js", filename: "bundle.[hash].js",
}, },
devServer: { devServer: {
compress: true, compress: true,
port: 8080, port: 8080,
hot: true, hot: true,
static: "./dist", static: "./dist",
historyApiFallback: true, historyApiFallback: true,
open: true, open: true,
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.(js|jsx)$/, test: /\.(js|jsx)$/,
exclude: /node_modules/, exclude: /node_modules/,
use: { use: {
loader: "babel-loader", loader: "babel-loader",
}, },
}, },
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
exclude: /node_modules/, exclude: /node_modules/,
use: {loader: 'ts-loader'}, use: { loader: "ts-loader" },
}, },
{ {
test: /\.(sa|sc|c)ss$/, test: /\.(sa|sc|c)ss$/,
exclude: /\.module\.(sa|sc|c)ss$/, exclude: /\.module\.(sa|sc|c)ss$/,
use: [styleLoader, CSSLoader, PostCSSLoader] use: [styleLoader, CSSLoader, PostCSSLoader],
}, },
{ {
test: /\.module\.(sa|sc|c)ss$/, test: /\.module\.(sa|sc|c)ss$/,
use: [styleLoader, CSSModuleLoader, PostCSSLoader] use: [styleLoader, CSSModuleLoader, PostCSSLoader],
} },
],
},
plugins: [
new HtmlWebpackPlugin({
template: __dirname + "/public/index.html",
filename: "index.html",
}),
], ],
mode: "development", },
devtool: "inline-source-map", plugins: [
experiments: { new HtmlWebpackPlugin({
asyncWebAssembly: true template: __dirname + "/public/index.html",
}, filename: "index.html",
resolve: { }),
extensions: ['.tsx', '.ts', '.js'], ],
}, mode: "development",
devtool: "inline-source-map",
experiments: {
asyncWebAssembly: true,
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
}; };