fix: editor tab key

This commit is contained in:
trisua 2025-07-20 18:29:43 -04:00
parent 59b8c8cac6
commit a33ee961fe
5 changed files with 24 additions and 11 deletions

View file

@ -84,8 +84,10 @@ globalThis.init_editor = () => {
highlightFormatting: false, highlightFormatting: false,
fencedCodeBlockHighlighting: false, fencedCodeBlockHighlighting: false,
xml: false, xml: false,
smartIndent: true, smartIndent: false,
indentUnit: 4, indentUnit: 4,
tabSize: 4,
indentWithTabs: false,
placeholder: "", placeholder: "",
extraKeys: { extraKeys: {
Home: "goLineLeft", Home: "goLineLeft",
@ -93,6 +95,7 @@ globalThis.init_editor = () => {
Enter: (cm) => { Enter: (cm) => {
cm.replaceSelection("\n"); cm.replaceSelection("\n");
}, },
Tab: "insertSoftTab",
}, },
}); });

View file

@ -158,6 +158,7 @@ video {
/* button */ /* button */
.button { .button {
--h: 35.2px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
@ -169,7 +170,9 @@ video {
outline: none; outline: none;
border: none; border: none;
width: max-content; width: max-content;
height: max-content; height: var(--h);
min-height: var(--h);
max-height: var(--h);
transition: background 0.15s; transition: background 0.15s;
text-decoration: none !important; text-decoration: none !important;
user-select: none; user-select: none;
@ -190,6 +193,7 @@ video {
/* input */ /* input */
input { input {
--h: 35.2px;
padding: var(--pad-2) var(--pad-4); padding: var(--pad-2) var(--pad-4);
background: var(--color-raised); background: var(--color-raised);
color: var(--color-text); color: var(--color-text);
@ -197,6 +201,9 @@ input {
border: none; border: none;
width: max-content; width: max-content;
transition: background 0.15s; transition: background 0.15s;
height: var(--h);
min-height: var(--h);
max-height: var(--h);
} }
input:focus { input:focus {
@ -373,8 +380,9 @@ img {
blockquote { blockquote {
padding-left: 1rem; padding-left: 1rem;
border-left: solid 5px var(--color-super-lowered); border-left: solid 5px var(--color-green);
font-style: italic; color: var(--color-green);
opacity: 75%;
} }
/* codemirror/hljs */ /* codemirror/hljs */

View file

@ -1,4 +1,5 @@
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
mod markdown;
mod model; mod model;
mod routes; mod routes;
@ -19,12 +20,10 @@ pub(crate) type InnerState = (DataClient, Tera, String);
pub(crate) type State = Arc<RwLock<InnerState>>; pub(crate) type State = Arc<RwLock<InnerState>>;
fn render_markdown(value: &Value, _: &HashMap<String, Value>) -> tera::Result<Value> { fn render_markdown(value: &Value, _: &HashMap<String, Value>) -> tera::Result<Value> {
Ok( Ok(markdown::render_markdown(value.as_str().unwrap())
tetratto_shared::markdown::render_markdown(value.as_str().unwrap(), false) .replace("\\@", "@")
.replace("\\@", "@") .replace("%5C@", "@")
.replace("%5C@", "@") .into())
.into(),
)
} }
fn remove_script_tags(value: &Value, _: &HashMap<String, Value>) -> tera::Result<Value> { fn remove_script_tags(value: &Value, _: &HashMap<String, Value>) -> tera::Result<Value> {

3
src/markdown.rs Normal file
View file

@ -0,0 +1,3 @@
pub fn render_markdown(input: &str) -> String {
tetratto_shared::markdown::render_markdown(input, false)
}

View file

@ -175,7 +175,7 @@ struct RenderMarkdown {
} }
async fn render_request(Json(req): Json<RenderMarkdown>) -> impl IntoResponse { async fn render_request(Json(req): Json<RenderMarkdown>) -> impl IntoResponse {
tetratto_shared::markdown::render_markdown(&req.content, false) crate::markdown::render_markdown(&req.content)
} }
#[derive(Deserialize)] #[derive(Deserialize)]