File tree Expand file tree Collapse file tree 6 files changed +11
-11
lines changed Expand file tree Collapse file tree 6 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,8 @@ export const holdDown = async (
5353 target : element ,
5454 clientX : options . X ,
5555 clientY : options . Y ,
56- pageX : options . X + window . scrollX ,
57- pageY : options . Y + window . scrollY ,
56+ pageX : options . X + globalThis . scrollX ,
57+ pageY : options . Y + globalThis . scrollY ,
5858 } ) ;
5959 const mouseOptions = {
6060 button : options . button ?? 0 ,
Original file line number Diff line number Diff line change 11import { extractCodeFiles } from "./extractCodeFiles.ts" ;
22import { Line } from "../../deps/scrapbox.ts" ;
33import { assertSnapshot } from "../../deps/testing.ts" ;
4- import sample from "./sample-lines1.json" assert { type : "json" } ;
4+ import sample from "./sample-lines1.json" with { type : "json" } ;
55
66Deno . test ( "extractCodeFiles" , async ( t ) => {
77 await assertSnapshot (
Original file line number Diff line number Diff line change 44
55export const isHeightViewable = ( element : HTMLElement ) : boolean => {
66 const { top, bottom } = element . getBoundingClientRect ( ) ;
7- return top >= 0 && bottom <= window . innerHeight ;
7+ return top >= 0 && bottom <= globalThis . innerHeight ;
88} ;
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ const getVisibleLineCount = (): number => {
161161 if ( clientHeight === undefined ) {
162162 throw Error ( "Could not find .line:last-of-type" ) ;
163163 }
164- return Math . round ( window . innerHeight / clientHeight ) ;
164+ return Math . round ( globalThis . innerHeight / clientHeight ) ;
165165} ;
166166
167167/** 半ページ上にスクロールする
Original file line number Diff line number Diff line change @@ -58,14 +58,14 @@ export const open = (
5858 options ?. newTab !== false &&
5959 ( options ?. newTab === true || project !== scrapbox . Project . name )
6060 ) {
61- window . open ( url ) ;
61+ globalThis . open ( url ) ;
6262 return ;
6363 }
6464 if (
6565 options ?. reload !== false &&
6666 ( options ?. reload === true || project !== scrapbox . Project . name )
6767 ) {
68- window . open ( url , "_self" ) ;
68+ globalThis . open ( url , "_self" ) ;
6969 return ;
7070 }
7171
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import { BaseOptions } from "./util.ts";
33
44// scrapbox.io内なら`window._csrf`にCSRF tokenが入っている
55declare global {
6- interface Window {
7- _csrf ?: string ;
8- }
6+ // globalThisに変数を宣言するには、`var`を使うしかない
7+ // deno-lint-ignore no-var
8+ var _csrf : string | undefined ;
99}
1010
1111/** HTTP headerのCookieに入れる文字列を作る
@@ -21,7 +21,7 @@ export const cookie = (sid: string): string => `connect.sid=${sid}`;
2121export const getCSRFToken = async (
2222 init ?: BaseOptions ,
2323) : Promise < string > => {
24- if ( window . _csrf ) return window . _csrf ;
24+ if ( globalThis . _csrf ) return globalThis . _csrf ;
2525
2626 const user = await getProfile ( init ) ;
2727 return user . csrfToken ;
You can’t perform that action at this time.
0 commit comments