Revize 4bc99591
Přidáno uživatelem Lukáš Vlček před asi 2 roky(ů)
webapp/contexts/TagCategoryContext.tsx | ||
---|---|---|
1 |
import React, { createContext, useEffect, useState } from 'react'; |
|
1 |
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2 | 2 |
import { SubTagInfo, TagCategoryInfo, TagInfo } from '../api'; |
3 | 3 |
import { tagController } from '../controllers'; |
4 |
import { LoggedUserContext } from './LoggedUserContext'; |
|
5 |
import Annotation from '../pages/annotation/[id]'; |
|
6 |
import { AnnotationContext } from './AnnotationContext'; |
|
4 | 7 |
|
5 | 8 |
/** |
6 | 9 |
* Interface of a tag context provider. |
... | ... | |
78 | 81 |
* @returns Prepared html of the provider. |
79 | 82 |
*/ |
80 | 83 |
const TagCategoryProvider = (props: { children: React.ReactNode }) => { |
84 |
const { markSelectedText } = useContext(AnnotationContext); |
|
85 |
|
|
81 | 86 |
/** |
82 | 87 |
* Tags managed by the context. |
83 | 88 |
*/ |
... | ... | |
99 | 104 |
const selectTag = (tag: TagInfo, subTag: SubTagInfo | null) => { |
100 | 105 |
setSelectedTag(tag); |
101 | 106 |
setSelectedSubTag(subTag); |
107 |
|
|
108 |
if (!tag.id) { |
|
109 |
console.log('invalid selection'); |
|
110 |
return; |
|
111 |
} |
|
112 |
|
|
113 |
markSelectedText(tag.id, subTag?.id ?? null, null); |
|
102 | 114 |
}; |
103 | 115 |
|
104 | 116 |
/** |
Také k dispozici: Unified diff
Adding tag/subtag to selected text