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