11/// <reference no-default-lib="true"/>
22/// <reference lib="esnext"/>
33/// <reference lib="dom" />
4- import { isNone , isNumber , isString } from "../../is .ts" ;
4+ import { isNumber , isString , isUndefined } from "../../deps/unknownutil .ts" ;
55import { ensureArray } from "../../ensure.ts" ;
66import { getCachedLines } from "./getCachedLines.ts" ;
77import { takeInternalLines } from "./takeInternalLines.ts" ;
@@ -18,7 +18,7 @@ import * as Text from "../../text.ts";
1818export const getLineId = < T extends HTMLElement > (
1919 value ?: number | string | T ,
2020) : string | undefined => {
21- if ( isNone ( value ) ) return undefined ;
21+ if ( isUndefined ( value ) ) return undefined ;
2222
2323 // 行番号のとき
2424 if ( isNumber ( value ) ) return getBaseLine ( value ) ?. id ;
@@ -43,7 +43,7 @@ export const getLineId = <T extends HTMLElement>(
4343export const getLineNo = < T extends HTMLElement > (
4444 value ?: number | string | T ,
4545) : number | undefined => {
46- if ( isNone ( value ) ) return undefined ;
46+ if ( isUndefined ( value ) ) return undefined ;
4747
4848 // 行番号のとき
4949 if ( isNumber ( value ) ) return value ;
@@ -55,7 +55,7 @@ export const getLineNo = <T extends HTMLElement>(
5555export const getLine = < T extends HTMLElement > (
5656 value ?: number | string | T ,
5757) : Line | undefined => {
58- if ( isNone ( value ) ) return undefined ;
58+ if ( isUndefined ( value ) ) return undefined ;
5959
6060 // 行番号のとき
6161 if ( isNumber ( value ) ) return getLines ( ) [ value ] ;
@@ -67,7 +67,7 @@ export const getLine = <T extends HTMLElement>(
6767export const getBaseLine = < T extends HTMLElement > (
6868 value ?: number | string | T ,
6969) : BaseLine | undefined => {
70- if ( isNone ( value ) ) return undefined ;
70+ if ( isUndefined ( value ) ) return undefined ;
7171
7272 // 行番号のとき
7373 if ( isNumber ( value ) ) return takeInternalLines ( ) [ value ] ;
@@ -82,9 +82,9 @@ export const getLineDOM = <T extends HTMLElement>(
8282 if ( isLineDOM ( value ) ) return value ;
8383
8484 const id = getLineId ( value ) ;
85- if ( isNone ( id ) ) return id ;
85+ if ( isUndefined ( id ) ) return id ;
8686 const line = document . getElementById ( `L${ id } ` ) ;
87- if ( isNone ( line ) ) return undefined ;
87+ if ( isUndefined ( line ) ) return undefined ;
8888 return line as HTMLDivElement ;
8989} ;
9090export const isLineDOM = ( dom : unknown ) : dom is HTMLDivElement =>
@@ -101,7 +101,7 @@ export const getLines = (): readonly Line[] => {
101101export const getText = < T extends HTMLElement > (
102102 value ?: number | string | T ,
103103) : string | undefined => {
104- if ( isNone ( value ) ) return undefined ;
104+ if ( isUndefined ( value ) ) return undefined ;
105105
106106 // 数字と文字列は行として扱う
107107 if ( isNumber ( value ) || isString ( value ) ) return getBaseLine ( value ) ?. text ;
@@ -121,7 +121,7 @@ export const getText = <T extends HTMLElement>(
121121 //中に含まれている文字の列番号を全て取得し、それに対応する文字列を返す
122122 const chars = [ ] as number [ ] ;
123123 const line = getBaseLine ( value ) ;
124- if ( isNone ( line ) ) return ;
124+ if ( isUndefined ( line ) ) return ;
125125 for ( const dom of getChars ( value ) ) {
126126 chars . push ( getIndex ( dom ) ) ;
127127 }
@@ -130,30 +130,30 @@ export const getText = <T extends HTMLElement>(
130130
131131export const getExternalLink = ( dom : HTMLElement ) : HTMLElement | undefined => {
132132 const link = dom . closest ( ".link" ) ;
133- if ( isNone ( link ) ) return undefined ;
133+ if ( isUndefined ( link ) ) return undefined ;
134134 return link as HTMLElement ;
135135} ;
136136export const getInternalLink = ( dom : HTMLElement ) : HTMLElement | undefined => {
137137 const link = dom . closest ( ".page-link" ) ;
138- if ( isNone ( link ) ) return undefined ;
138+ if ( isUndefined ( link ) ) return undefined ;
139139 return link as HTMLElement ;
140140} ;
141141export const getLink = ( dom : HTMLElement ) => {
142142 const link = dom . closest ( ".link, .page-link" ) ;
143- if ( isNone ( link ) ) return undefined ;
143+ if ( isUndefined ( link ) ) return undefined ;
144144 return link as HTMLElement ;
145145} ;
146146
147147export const getFormula = ( dom : HTMLElement ) : HTMLElement | undefined => {
148148 const formula = dom . closest ( ".formula" ) ;
149- if ( isNone ( formula ) ) return undefined ;
149+ if ( isUndefined ( formula ) ) return undefined ;
150150 return formula as HTMLElement ;
151151} ;
152152export const getNextLine = < T extends HTMLElement > (
153153 value ?: number | string | T ,
154154) : Line | undefined => {
155155 const index = getLineNo ( value ) ;
156- if ( isNone ( index ) ) return undefined ;
156+ if ( isUndefined ( index ) ) return undefined ;
157157
158158 return getLine ( index + 1 ) ;
159159} ;
@@ -162,26 +162,26 @@ export const getPrevLine = <T extends HTMLElement>(
162162 value ?: number | string | T ,
163163) : Line | undefined => {
164164 const index = getLineNo ( value ) ;
165- if ( isNone ( index ) ) return undefined ;
165+ if ( isUndefined ( index ) ) return undefined ;
166166
167167 return getLine ( index - 1 ) ;
168168} ;
169169
170170export const getHeadLineDOM = ( ) : HTMLDivElement | undefined => {
171171 const line = lines ( ) ?. firstElementChild ;
172- if ( isNone ( line ) ) return undefined ;
172+ if ( isUndefined ( line ) ) return undefined ;
173173 return line as HTMLDivElement ;
174174} ;
175175export const getTailLineDOM = ( ) : HTMLDivElement | undefined => {
176176 const line = lines ( ) ?. lastElementChild ;
177- if ( isNone ( line ) ) return undefined ;
177+ if ( isUndefined ( line ) ) return undefined ;
178178 return line as HTMLDivElement ;
179179} ;
180180export const getIndentCount = < T extends HTMLElement > (
181181 value ?: number | string | T ,
182182) : number | undefined => {
183183 const text = getText ( value ) ;
184- if ( isNone ( text ) ) return undefined ;
184+ if ( isUndefined ( text ) ) return undefined ;
185185 return Text . getIndentCount ( text ) ;
186186} ;
187187/** 指定した行の配下にある行の数を返す
@@ -192,7 +192,7 @@ export const getIndentLineCount = <T extends HTMLElement>(
192192 value ?: number | string | T ,
193193) : number | undefined => {
194194 const index = getLineNo ( value ) ;
195- if ( isNone ( index ) ) return ;
195+ if ( isUndefined ( index ) ) return ;
196196 return Text . getIndentLineCount ( index , getLines ( ) ) ;
197197} ;
198198
@@ -213,7 +213,7 @@ export const getIndex = (dom: HTMLSpanElement): number => {
213213 if ( ! isCharDOM ( dom ) ) throw Error ( "A char DOM is required." ) ;
214214
215215 const index = dom . className . match ( / c - ( \d + ) / ) ?. [ 1 ] ;
216- if ( isNone ( index ) ) throw Error ( '.char-index must have ".c-{\\d}"' ) ;
216+ if ( isUndefined ( index ) ) throw Error ( '.char-index must have ".c-{\\d}"' ) ;
217217 return parseInt ( index ) ;
218218} ;
219219export const getHeadCharDOM = (
@@ -245,7 +245,7 @@ export const getDOMFromPoint = (
245245 const char = targets . find ( ( target ) => isCharDOM ( target ) ) ;
246246 const line = targets . find ( ( target ) => isLineDOM ( target ) ) ;
247247 return {
248- char : isNone ( char ) ? undefined : char as HTMLSpanElement ,
249- line : isNone ( line ) ? undefined : line as HTMLDivElement ,
248+ char : isUndefined ( char ) ? undefined : char as HTMLSpanElement ,
249+ line : isUndefined ( line ) ? undefined : line as HTMLDivElement ,
250250 } ;
251251} ;
0 commit comments