Skip to content
Merged
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
7 changes: 4 additions & 3 deletions browser/dom/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { textInput } from "./dom.ts";
import { isArray } from "@core/unknownutil/is/array";
import { isNumber } from "@core/unknownutil/is/number";
import { isString } from "@core/unknownutil/is/string";
import { delay } from "@std/async/delay";
import type { Scrapbox } from "@cosense/types/userscript";
declare const scrapbox: Scrapbox;

export const undo = (count = 1): void => {
for (const _ of range(0, count)) {
Expand Down Expand Up @@ -157,7 +158,7 @@ export const downBlocks = (count = 1): void => {
}
};

export const insertText = async (text: string): Promise<void> => {
export const insertText = (text: string): Promise<void> => {
const cursor = textInput();
if (!cursor) {
throw Error("#text-input is not ditected.");
Expand All @@ -167,5 +168,5 @@ export const insertText = async (text: string): Promise<void> => {

const event = new InputEvent("input", { bubbles: true });
cursor.dispatchEvent(event);
await delay(1); // 1ms delay to ensure event processing completes
return scrapbox.Page.waitForSave();
};