diff --git a/build/configure/src/web.rs b/build/configure/src/web.rs index 52e096177..755dc405c 100644 --- a/build/configure/src/web.rs +++ b/build/configure/src/web.rs @@ -394,7 +394,7 @@ fn build_and_check_editor(build: &mut Build) -> Result<()> { } fn build_and_check_reviewer(build: &mut Build) -> Result<()> { - let reviewer_deps = inputs![":ts:lib", glob!("ts/reviewer/**"),]; + let reviewer_deps = inputs![":ts:lib", glob!("ts/{reviewer,image-occlusion}/**"),]; build.add( "ts:reviewer:reviewer.js", EsbuildScript { diff --git a/rslib/src/image_occlusion/imageocclusion.rs b/rslib/src/image_occlusion/imageocclusion.rs index f2c3b41ee..c1e7da551 100644 --- a/rslib/src/image_occlusion/imageocclusion.rs +++ b/rslib/src/image_occlusion/imageocclusion.rs @@ -3,10 +3,11 @@ use std::fmt::Write; -// split following -// text = "rect:399.01,99.52,167.09,33.78:fill=#0a2cee:stroke=1" -// with -// result = "data-shape="rect" data-left="399.01" data-top="99.52" data-width="167.09" data-height="33.78" data-fill="\#0a2cee" data-stroke="1"" +// convert text like +// rect:left=.2325:top=.3261:width=.202:height=.0975 +// to something like +// result = "data-shape="rect" data-left="399.01" data-top="99.52" +// data-width="167.09" data-height="33.78" pub fn get_image_cloze_data(text: &str) -> String { let mut result = String::new(); let parts: Vec<&str> = text.split(':').collect(); @@ -57,18 +58,18 @@ pub fn get_image_cloze_data(text: &str) -> String { let mut point_str = String::new(); for point_pair in values[1].split(' ') { let Some((x, y)) = point_pair.split_once(',') else { continue }; - write!(&mut point_str, "[{},{}],", x, y).unwrap(); + write!(&mut point_str, "{},{} ", x, y).unwrap(); } - // remove the trailing comma + // remove the trailing space point_str.pop(); if !point_str.is_empty() { - result.push_str(&format!("data-points=\"[{}]\" ", point_str)); + result.push_str(&format!("data-points=\"{point_str}\" ")); } } } - "hideinactive" => { + "oi" => { if !values[1].is_empty() { - result.push_str(&format!("data-hideinactive=\"{}\" ", values[1])); + result.push_str(&format!("data-occludeInactive=\"{}\" ", values[1])); } } _ => {} @@ -102,6 +103,6 @@ fn test_get_image_cloze_data() { ); assert_eq!( get_image_cloze_data("polygon:points=0,0 10,10 20,0"), - r#"data-shape="polygon" data-points="[[0,0],[10,10],[20,0]]" "#, + r#"data-shape="polygon" data-points="0,0 10,10 20,0" "#, ); } diff --git a/ts/image-occlusion/ImageOcclusionPage.svelte b/ts/image-occlusion/ImageOcclusionPage.svelte index 93ed9c20a..21a26a938 100644 --- a/ts/image-occlusion/ImageOcclusionPage.svelte +++ b/ts/image-occlusion/ImageOcclusionPage.svelte @@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import * as tr from "@tslib/ftl"; import Container from "../components/Container.svelte"; - import { addOrUpdateNote } from "./generate"; + import { addOrUpdateNote } from "./add-or-update-note"; import type { IOMode } from "./lib"; import MasksEditor from "./MaskEditor.svelte"; import Notes from "./Notes.svelte"; @@ -15,11 +15,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export let mode: IOMode; async function hideAllGuessOne(): Promise { - addOrUpdateNote(mode, false); + addOrUpdateNote(mode, true); } async function hideOneGuessOne(): Promise { - addOrUpdateNote(mode, true); + addOrUpdateNote(mode, false); } const items = [ @@ -50,8 +50,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html + +