Skip to content

Commit

Permalink
add latex rendering to link title and fix selection rect
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3orblade committed Feb 3, 2025
1 parent 51fefab commit d1f5c6f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/ts/component/selection/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const SelectionProvider = observer(forwardRef<SelectionRefProps, Props>((props,
const { children } = props;
const length = list.length;
const rectRef = useRef(null);
const allowRect = useRef(true);

const rebind = () => {
unbind();
Expand Down Expand Up @@ -308,10 +309,10 @@ const SelectionProvider = observer(forwardRef<SelectionRefProps, Props>((props,
const y1 = y.current + oy;
const rect = getRect(x1, y1, dx, dy);

if (range.current) {
el.hide();
} else {
if (allowRect.current) {
el.show().css({ transform: `translate3d(${rect.x}px, ${rect.y}px, 0px)`, width: rect.width, height: rect.height });
} else {
el.hide();
};
};

Expand Down Expand Up @@ -416,18 +417,22 @@ const SelectionProvider = observer(forwardRef<SelectionRefProps, Props>((props,
if (!rc) {
focus.set(focusedId.current, { from: range.current.start, to: range.current.end });
focus.apply();

allowRect.current = false;
};
};
} else {
const { focused, range } = focus.state;
const { focused, range: fr } = focus.state;

if (focused && range.to) {
if (focused && fr.to) {
focus.clear(false);
};

keyboard.setFocus(false);
window.getSelection().empty();
window.focus();

allowRect.current = true;
};

renderSelection();
Expand Down Expand Up @@ -456,6 +461,7 @@ const SelectionProvider = observer(forwardRef<SelectionRefProps, Props>((props,
nodes.current = [];
range.current = null;
containerOffset.current = null;
allowRect.current = true;
};

const set = (type: I.SelectType, list: string[]) => {
Expand Down

0 comments on commit d1f5c6f

Please sign in to comment.