mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Add tooltip for missing constituenta
This commit is contained in:
parent
2d3403bb84
commit
24d5d723d4
|
@ -28,10 +28,10 @@ function findAliasAt(pos: number, state: EditorState) {
|
|||
const globalsHoverTooltip = (items: IConstituenta[]) => {
|
||||
return hoverTooltip((view, pos) => {
|
||||
const { alias, start, end } = findAliasAt(pos, view.state);
|
||||
const cst = items.find(cst => cst.alias === alias);
|
||||
if (!cst) {
|
||||
if (!alias) {
|
||||
return null;
|
||||
}
|
||||
const cst = items.find(cst => cst.alias === alias);
|
||||
return {
|
||||
pos: start,
|
||||
end: end,
|
||||
|
|
|
@ -124,7 +124,7 @@ export function findContainedNodes(start: number, finish: number, tree: Tree, fi
|
|||
/**
|
||||
* Create DOM tooltip for {@link Constituenta}.
|
||||
*/
|
||||
export function domTooltipConstituenta(cst: IConstituenta) {
|
||||
export function domTooltipConstituenta(cst?: IConstituenta) {
|
||||
const dom = document.createElement('div');
|
||||
dom.className = clsx(
|
||||
'z-tooltip',
|
||||
|
@ -135,6 +135,7 @@ export function domTooltipConstituenta(cst: IConstituenta) {
|
|||
'text-sm'
|
||||
);
|
||||
|
||||
if (cst) {
|
||||
const alias = document.createElement('p');
|
||||
alias.innerHTML = `<b>${cst.alias}:</b> ${labelCstTypification(cst)}`;
|
||||
dom.appendChild(alias);
|
||||
|
@ -162,6 +163,11 @@ export function domTooltipConstituenta(cst: IConstituenta) {
|
|||
convention.innerHTML = `<b>Конвенция:</b> ${cst.convention}`;
|
||||
dom.appendChild(convention);
|
||||
}
|
||||
} else {
|
||||
const text = document.createElement('p');
|
||||
text.innerText = 'Конституента не определена';
|
||||
dom.appendChild(text);
|
||||
}
|
||||
return { dom: dom };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user