@@ -13,7 +13,6 @@ import {
1313 PinFilledIcon ,
1414 PinIcon ,
1515 ShareIcon ,
16- TagIcon ,
1716 TrashIcon ,
1817 UnarchiveIcon ,
1918 XIcon ,
@@ -63,9 +62,6 @@ export function NoteEditor({
6362 const [ body , setBody ] = useState ( "" ) ;
6463 const [ pinned , setPinned ] = useState ( false ) ;
6564 const [ archived , setArchived ] = useState ( false ) ;
66- const [ tags , setTags ] = useState < string [ ] > ( [ ] ) ;
67- const [ tagInput , setTagInput ] = useState ( "" ) ;
68- const [ tagOpen , setTagOpen ] = useState ( false ) ;
6965 const [ dirty , setDirty ] = useState ( false ) ;
7066 const [ uploading , setUploading ] = useState ( false ) ;
7167 const [ previewOpen , setPreviewOpen ] = useState ( false ) ;
@@ -95,16 +91,12 @@ export function NoteEditor({
9591 setPinned ( target . note . pinned ) ;
9692 setArchived ( target . note . archived ) ;
9793 setHighlight ( Boolean ( target . note . highlight ) ) ;
98- setTags ( target . note . tags ?? [ ] ) ;
9994 } else {
10095 setBody ( "" ) ;
10196 setPinned ( false ) ;
10297 setArchived ( false ) ;
10398 setHighlight ( false ) ;
104- setTags ( [ ] ) ;
10599 }
106- setTagInput ( "" ) ;
107- setTagOpen ( false ) ;
108100 setDirty ( false ) ;
109101 setHistoryOpen ( false ) ;
110102 setVersions ( [ ] ) ;
@@ -134,7 +126,7 @@ export function NoteEditor({
134126 if ( ! target || ! dirty ) return ;
135127 if ( target . mode === "edit" ) {
136128 const timer = window . setTimeout ( ( ) => {
137- onUpdate ( target . note . id , { body, pinned, archived, highlight, tags } ) ;
129+ onUpdate ( target . note . id , { body, pinned, archived, highlight } ) ;
138130 setDirty ( false ) ;
139131 } , 550 ) ;
140132 return ( ) => window . clearTimeout ( timer ) ;
@@ -143,7 +135,7 @@ export function NoteEditor({
143135 if ( createdIdRef . current ) {
144136 const id = createdIdRef . current ;
145137 const timer = window . setTimeout ( ( ) => {
146- onUpdate ( id , { body, pinned, archived, highlight, tags } ) ;
138+ onUpdate ( id , { body, pinned, archived, highlight } ) ;
147139 setDirty ( false ) ;
148140 } , 550 ) ;
149141 return ( ) => window . clearTimeout ( timer ) ;
@@ -152,7 +144,7 @@ export function NoteEditor({
152144 const timer = window . setTimeout ( async ( ) => {
153145 if ( createdIdRef . current || creatingRef . current ) return ;
154146 creatingRef . current = true ;
155- const note = await onCreate ( { body, pinned, archived, highlight, tags } ) ;
147+ const note = await onCreate ( { body, pinned, archived, highlight } ) ;
156148 creatingRef . current = false ;
157149 if ( note ) {
158150 createdIdRef . current = note . id ;
@@ -161,7 +153,7 @@ export function NoteEditor({
161153 } , 550 ) ;
162154 return ( ) => window . clearTimeout ( timer ) ;
163155 }
164- } , [ archived , body , dirty , highlight , onCreate , onUpdate , pinned , tags , target ] ) ;
156+ } , [ archived , body , dirty , highlight , onCreate , onUpdate , pinned , target ] ) ;
165157
166158 function markBody ( value : string ) {
167159 setBody ( value ) ;
@@ -178,19 +170,6 @@ export function NoteEditor({
178170 setDirty ( true ) ;
179171 }
180172
181- function addTag ( tag : string ) {
182- const t = tag . trim ( ) . toLowerCase ( ) ;
183- if ( ! t || tags . includes ( t ) ) return ;
184- setTags ( ( prev ) => [ ...prev , t ] ) ;
185- setTagInput ( "" ) ;
186- setDirty ( true ) ;
187- }
188-
189- function removeTag ( tag : string ) {
190- setTags ( ( prev ) => prev . filter ( ( t ) => t !== tag ) ) ;
191- setDirty ( true ) ;
192- }
193-
194173 async function loadHistory ( ) {
195174 if ( ! target || target . mode !== "edit" ) return ;
196175 try {
@@ -270,18 +249,18 @@ export function NoteEditor({
270249
271250 function flushEdit ( ) {
272251 if ( ! target || target . mode !== "edit" ) return ;
273- onUpdate ( target . note . id , { body, pinned, archived, highlight, tags } ) ;
252+ onUpdate ( target . note . id , { body, pinned, archived, highlight } ) ;
274253 setDirty ( false ) ;
275254 }
276255
277256 function close ( ) {
278257 if ( ! target ) return ;
279258 if ( target . mode === "new" ) {
280259 if ( createdIdRef . current ) {
281- onUpdate ( createdIdRef . current , { body, pinned, archived, highlight, tags } ) ;
260+ onUpdate ( createdIdRef . current , { body, pinned, archived, highlight } ) ;
282261 } else if ( body . trim ( ) && ! creatingRef . current ) {
283262 creatingRef . current = true ;
284- onCreate ( { body, pinned, archived, highlight, tags } ) ;
263+ onCreate ( { body, pinned, archived, highlight } ) ;
285264 }
286265 } else {
287266 flushEdit ( ) ;
@@ -310,15 +289,6 @@ export function NoteEditor({
310289 ) }
311290 { ! isTrashed ? (
312291 < >
313- < button
314- type = "button"
315- onClick = { ( ) => setTagOpen ( ( v ) => ! v ) }
316- className = { iconToggle ( tags . length > 0 || tagOpen ) }
317- title = "Tags"
318- aria-label = "Tags"
319- >
320- < TagIcon className = "h-4 w-4" />
321- </ button >
322292 < button
323293 type = "button"
324294 onClick = { ( ) => { setHighlight ( ( v ) => ! v ) ; setDirty ( true ) ; } }
@@ -494,61 +464,6 @@ export function NoteEditor({
494464 < >
495465 { ! historyOpen && header }
496466
497- { ( tags . length > 0 || tagOpen ) && (
498- < div className = "flex w-full max-w-3xl flex-wrap items-center gap-1.5 px-6 py-2" >
499- { tags . map ( ( tag ) => (
500- < span
501- key = { tag }
502- className = "inline-flex items-center gap-1 rounded-full bg-[var(--color-surface-hover)] px-2 py-0.5 text-xs text-[var(--color-text)]"
503- >
504- { tag }
505- < button
506- type = "button"
507- onClick = { ( ) => removeTag ( tag ) }
508- className = "ml-0.5 text-[var(--color-muted)] hover:text-[var(--color-text)]"
509- aria-label = { `Remove tag ${ tag } ` }
510- >
511- < XIcon className = "h-2.5 w-2.5" />
512- </ button >
513- </ span >
514- ) ) }
515- { tagOpen && (
516- < input
517- autoFocus
518- value = { tagInput }
519- onChange = { ( e ) => setTagInput ( e . target . value ) }
520- onKeyDown = { ( e ) => {
521- if ( e . key === "Enter" || e . key === "," ) {
522- e . preventDefault ( ) ;
523- addTag ( tagInput ) ;
524- }
525- if ( e . key === "Backspace" && ! tagInput && tags . length > 0 ) {
526- removeTag ( tags [ tags . length - 1 ] ) ;
527- }
528- if ( e . key === "Escape" ) {
529- setTagOpen ( false ) ;
530- setTagInput ( "" ) ;
531- }
532- } }
533- onBlur = { ( ) => {
534- if ( tagInput . trim ( ) ) addTag ( tagInput ) ;
535- setTagOpen ( false ) ;
536- } }
537- placeholder = "Add tag..."
538- name = "note-tag"
539- autoComplete = "off"
540- autoCorrect = "off"
541- autoCapitalize = "off"
542- data-1p-ignore
543- data-lpignore = "true"
544- data-bwignore
545- data-form-type = "other"
546- className = "min-w-[80px] flex-1 border-0 bg-transparent text-xs text-[var(--color-text)] placeholder:text-[var(--color-muted)] focus:outline-none"
547- />
548- ) }
549- </ div >
550- ) }
551-
552467 { historyOpen ? (
553468 < VersionHistory
554469 versions = { versions }
0 commit comments