File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ <h1>ASCII Unicode Conversion Map Editor</h1>
105105 import { parse } from 'opentype'
106106 const ASCII_START = 33 ;
107107 const ASCII_END = 256 ;
108+ const append = ( data , line ) => {
109+ if ( data === "" ) return line + '\n' ;
110+ if ( data . slice ( - 1 ) === '\n' ) return data + line + '\n' ;
111+ return data + '\n' + line + '\n' ;
112+ }
108113 createApp ( {
109114 setup ( ) {
110115 const asciiChars = [ ] ;
@@ -134,18 +139,23 @@ <h1>ASCII Unicode Conversion Map Editor</h1>
134139 }
135140 } ,
136141 changeMapping ( char , value ) {
142+ let modified = false ;
137143 this . mapValue = this . mapValue
138144 . split ( '\n' )
139145 . map ( line => {
140146 if ( line . startsWith ( '#' ) ) return line ;
141147 let [ lhs , rhs ] = line . split ( '=' ) . map ( w => w . trim ( ) )
142148 if ( lhs === char ) {
149+ modified = true ;
143150 return `${ lhs } =${ value } `
144151 } else {
145152 return line
146153 }
147154 } )
148155 . join ( '\n' )
156+ if ( ! modified ) {
157+ this . mapValue = append ( this . mapValue , `${ char } =${ value } ` )
158+ }
149159 } ,
150160 getCharCode ( text ) {
151161 if ( ! text ) return "" ;
You can’t perform that action at this time.
0 commit comments