File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 33/// <reference lib="dom" />
44import { isNone , isNumber , isString } from "../../is.ts" ;
55import { ensureArray } from "../../ensure.ts" ;
6+ import { getCachedLines } from "./getCachedLines.ts" ;
67import type { Line , Scrapbox } from "../../deps/scrapbox.ts" ;
78import { lines } from "./dom.ts" ;
89import * as Text from "../../text.ts" ;
@@ -83,9 +84,10 @@ export const isLineDOM = (dom: unknown): dom is HTMLDivElement =>
8384
8485export const getLineCount = ( ) : number => getLines ( ) . length ;
8586
86- export const getLines = ( ) : Line [ ] => {
87- ensureArray ( scrapbox . Page . lines , "scrapbox.Page.lines" ) ;
88- return scrapbox . Page . lines ;
87+ export const getLines = ( ) : readonly Line [ ] => {
88+ const lines = getCachedLines ( ) ;
89+ ensureArray < Line > ( lines , "scrapbox.Page.lines" ) ;
90+ return lines ;
8991} ;
9092
9193export const getText = < T extends HTMLElement > (
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export const getIndentCount = (text: string): number =>
1010 */
1111export function getIndentLineCount (
1212 index : number ,
13- lines : string [ ] | { text : string } [ ] ,
13+ lines : readonly string [ ] | readonly { text : string } [ ] ,
1414) : number {
1515 const base = getIndentCount ( getText ( index , lines ) ) ;
1616 let count = 0 ;
@@ -23,7 +23,10 @@ export function getIndentLineCount(
2323 return count ;
2424}
2525
26- function getText ( index : number , lines : string [ ] | { text : string } [ ] ) {
26+ function getText (
27+ index : number ,
28+ lines : readonly string [ ] | readonly { text : string } [ ] ,
29+ ) {
2730 const line = lines [ index ] ;
2831 return isString ( line ) ? line : line . text ;
2932}
You can’t perform that action at this time.
0 commit comments