Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for font family and font size on fat-cursor. #1

Merged
merged 2 commits into from Dec 8, 2021

Conversation

lishid
Copy link
Contributor

@lishid lishid commented Dec 7, 2021

No description provided.

@nightwing
Copy link
Collaborator

@nightwing nightwing commented Dec 8, 2021

Thank you, but this seems to be still setting wrong size in some cases, e.g. at the first character of a token with larger font size. I wonder if there is a way to fix this without calling domAtPos twice. Maybe if domAtPos.node is an html element we should take domAtPos.node.childNodes[domAtPos.offset] instead?

@lishid
Copy link
Contributor Author

@lishid lishid commented Dec 8, 2021

I have noticed the same issue and I have filed a feature request here: https://discuss.codemirror.net/t/feature-request-domatpos-side-parameter/3793

And yeah you're right, we should probably take that into account!

@lishid
Copy link
Contributor Author

@lishid lishid commented Dec 8, 2021

Ok attached patch should fix the issue - also added fontWeight which I forgot.

let base = getBase(view);
let domAtPos = view.domAtPos(head);
let node = domAtPos ? domAtPos.node : view.contentDOM;
while (domAtPos && domAtPos.node instanceof HTMLElement) {
Copy link
Collaborator

@nightwing nightwing Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be if, as after one iteration offset is undefined.
Also i think codemirror returns offset for childNodes not children.

Copy link
Contributor Author

@lishid lishid Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops!

Copy link
Contributor Author

@lishid lishid Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using while because if you have multiple view plugins adding mark styles then it will result in multiple layers of nested spans.

@nightwing nightwing merged commit f38bbc9 into replit:master Dec 8, 2021
@nightwing
Copy link
Collaborator

@nightwing nightwing commented Dec 8, 2021

Looks good. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants