Skip to content
Merged

Dev2 #141

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ Changelog

* No changes.

Version 0.1.61 -- 2026-Jul-11
-----------------------------

* Fix unexpected scrolling when server updates are applied to a doc block that
exceeds the screen height.
* Fix errors due to incorrect TypeScript typecasts.
* Correctly update the delimiter when a doc block is updated.

Version 0.1.60 -- 2026-Jul-08
-----------------------------

Expand Down
16 changes: 8 additions & 8 deletions builder/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ fn quick_copy_dir<P: AsRef<Path>>(src: P, dest: P, files: Option<P>) -> io::Resu
"-c",
format!(
"rsync --archive --delete {} {}",
&src_combined.to_str().unwrap(),
&dest.to_str().unwrap()
src_combined.to_str().unwrap(),
dest.to_str().unwrap()
)
.as_str(),
]);
}

// Print the command, in case this produces and error or takes a while.
println!("{:#?}", &copy_process);
println!("{:#?}", copy_process);

// Check for errors.
let exit_code = copy_process
Expand Down Expand Up @@ -542,7 +542,13 @@ fn run_until_fail() -> io::Result<()> {
unsafe {
env::set_var("RUST_BACKTRACE", "1");
}
let tests = ["overall_1", "overall_2", "overall_3", "overall_4"];
let tests = [
"overall_1",
"overall_2",
"overall_3",
"overall_4",
"overall_5",
];
let mut iteration = 0;
loop {
iteration += 1;
Expand Down
6 changes: 3 additions & 3 deletions client/package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
url: 'https://github.com/bjones1/CodeChat_editor',
},
type: 'module',
version: '0.1.60',
version: '0.1.61',
dependencies: {
'@codemirror/commands': '^6.10.4',
'@codemirror/lang-cpp': '^6.0.3',
Expand Down Expand Up @@ -80,7 +80,7 @@
'@types/dom-navigation': '^1.0.7',
'@types/js-beautify': '^1.14.3',
'@types/mocha': '^10.0.10',
'@types/node': '^24.13.2',
'@types/node': '^24.13.3',
'@types/toastify-js': '^1.12.4',
'@typescript-eslint/eslint-plugin': '^8.63.0',
'@typescript-eslint/parser': '^8.63.0',
Expand All @@ -93,7 +93,7 @@
globals: '^17.7.0',
mocha: '^11.7.6',
'npm-check-updates': '^22.2.9',
prettier: '^3.9.4',
prettier: '^3.9.5',
typescript: '^6.0.3',
'typescript-eslint': '^8.63.0',
},
Expand Down
50 changes: 25 additions & 25 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 16 additions & 19 deletions client/src/CodeChatEditor.mts
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ const _open_lp = async (
// variable.
current_metadata = codechat_for_web["metadata"];
const source = codechat_for_web["source"];
const codechat_body = document.getElementById(
"CodeChat-body",
) as HTMLDivElement;
const codechat_body = document.getElementById("CodeChat-body");
assert(codechat_body instanceof HTMLDivElement);
if (is_doc_only()) {
// Per the
// [docs](https://docs.mathjax.org/en/latest/web/typeset.html#updating-previously-typeset-content),
Expand Down Expand Up @@ -439,9 +438,8 @@ const save_lp = async (
let code_mirror_diffable: CodeMirrorDiffable = {};
if (is_doc_only()) {
// Untypeset all math before saving the document.
const codechat_body = document.getElementById(
"CodeChat-body",
) as HTMLDivElement;
const codechat_body = document.getElementById("CodeChat-body");
assert(codechat_body instanceof HTMLDivElement);
mathJaxUnTypeset(codechat_body);
// Use a try/finally to ensure that the document is retypeset even
// if errors occur.
Expand Down Expand Up @@ -496,15 +494,13 @@ export const saveSelection = () => {
let current_node = sel.anchorNode;
// Continue until we find the div which contains the doc block
// contents: either it's not an element (such as a div), ...
current_node.nodeType !== Node.ELEMENT_NODE ||
!(current_node instanceof Element) ||
// or it's not the doc block contents div.
(!(current_node as Element).classList.contains(
"CodeChat-doc-contents",
) &&
(!current_node.classList.contains("CodeChat-doc-contents") &&
// Sometimes, the parent of a custom node (`wc-mermaid`) skips
// the TinyMCE div and returns the overall div. I don't know
// why.
!(current_node as Element).classList.contains("CodeChat-doc"));
!current_node.classList.contains("CodeChat-doc"));
current_node = current_node.parentNode!
) {
// Store the index of this node in its' parent list of child
Expand Down Expand Up @@ -538,15 +534,15 @@ export const restoreSelection = ({
// Copy the selection over to TinyMCE by indexing the selection path to find
// the selected node.
if (selection_path.length && typeof selection_offset === "number") {
let selection_node = tinymce_instance()!.getContentAreaContainer();
let selection_node: Node =
tinymce_instance()!.getContentAreaContainer();
// Avoid mutating `selection_path` by making a copy of it.
const selection_path_copy = [...selection_path];
while (selection_path_copy.length) {
const new_selection_node = selection_node.childNodes[
selection_path_copy.shift()!
] as HTMLElement;
const new_selection_node =
selection_node.childNodes[selection_path_copy.shift()!];
// If we get lost during the descent, then stop just before that.
if (new_selection_node === undefined) {
if (!(new_selection_node instanceof Node)) {
break;
}
selection_node = new_selection_node;
Expand Down Expand Up @@ -748,9 +744,10 @@ export const on_error = (event: Event) => {
on_dom_content_loaded(async () => {
// Intercept links in this document to save before following the link.
window.navigation.addEventListener("navigate", on_navigate);
const ccb = document.getElementById("CodeChat-sidebar") as
HTMLIFrameElement | undefined;
ccb?.contentWindow?.navigation.addEventListener("navigate", on_navigate);
const ccb = document.getElementById("CodeChat-sidebar");
if (ccb instanceof HTMLIFrameElement) {
ccb.contentWindow?.navigation.addEventListener("navigate", on_navigate);
}
document.addEventListener("click", on_click);
// Provide basic error reporting for uncaught errors.
window.addEventListener("unhandledrejection", on_error);
Expand Down
16 changes: 8 additions & 8 deletions client/src/CodeChatEditorFramework.mts
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ const set_content = async (
if (client === undefined) {
// See if this is the [simple viewer](#Client-simple-viewer). Otherwise,
// it's just the bare document to replace.
const contentsElement =
root_iframe!.contentDocument?.getElementById("CodeChat-contents");
const cw =
(
root_iframe!.contentDocument?.getElementById(
"CodeChat-contents",
) as HTMLIFrameElement | undefined
)?.contentWindow ?? root_iframe!.contentWindow!;
(contentsElement instanceof HTMLIFrameElement
? contentsElement.contentWindow
: undefined) ?? root_iframe!.contentWindow!;
cw.document.open();
assert("Plain" in contents.source);
cw.document.write(contents.source.Plain.doc);
Expand Down Expand Up @@ -489,9 +489,9 @@ export const page_init = (
webSocketComm = new WebSocketComm(
`${protocol}//${window.location.host}/${ws_pathname}`,
);
root_iframe = document.getElementById(
"CodeChat-iframe",
)! as HTMLIFrameElement;
const iframe_element = document.getElementById("CodeChat-iframe");
assert(iframe_element instanceof HTMLIFrameElement);
root_iframe = iframe_element;
window.CodeChatEditorFramework = {
webSocketComm,
};
Expand Down
Loading
Loading