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

Apply style to page will mess with the footnote style #692

Closed
actforjason opened this issue Oct 23, 2022 · 9 comments · Fixed by #693 or #695
Closed

Apply style to page will mess with the footnote style #692

actforjason opened this issue Oct 23, 2022 · 9 comments · Fixed by #693 or #695
Assignees
Labels
bug Something isn't working released Available in a released installer

Comments

@actforjason
Copy link

Before
image
After
image

@actforjason actforjason added bug Something isn't working unread I have seen it or had time to refine it yet labels Oct 23, 2022
@stevencohn stevencohn removed the unread I have seen it or had time to refine it yet label Oct 23, 2022
@stevencohn stevencohn self-assigned this Oct 23, 2022
@stevencohn stevencohn linked a pull request Oct 23, 2022 that will close this issue
@stevencohn stevencohn added the next-release Addressed but not yet released label Oct 23, 2022
@actforjason
Copy link
Author

actforjason commented Oct 24, 2022

For latest version 5.3-Beta
The superscript and color of the footnote change after the page style is applied.
Sorry, I'm a little OCD.

image
image

@stevencohn stevencohn linked a pull request Oct 24, 2022 that will close this issue
@actforjason
Copy link
Author

actforjason commented Nov 3, 2022

There still be a little problem based on the latest commit #695. The footnote num and "刷新"(refresh) are blue, while after applying the style they become text color. I tried to modify the source code of OneMore but failed.

image
image

@stevencohn
Copy link
Owner

That cannot be fixed. See the comment here.

OneMore is not applying color to the hyperlink but OneNote is and I can't seem to prevent that.

@actforjason
Copy link
Author

actforjason commented Nov 3, 2022

I don't know much about this field, but I think it should work if put ApplyToHyperlinks() after OneNote Update onenote.UpdatePageContent(), currently ApplyToHyperlinks() seems to be before onenote.UpdatePageContent().

if (page.GetPageColor(out _, out _).GetBrightness() < 0.5)
{
// hyperlinks require some inline styling
ApplyToHyperlinks();
}

OneMore/OneMore/OneNote.cs

Lines 1008 to 1011 in 902cf77

await InvokeWithRetry(() =>
{
onenote.UpdatePageContent(xml, DateTime.MinValue, XMLSchema.xs2013, true);
});

@stevencohn
Copy link
Owner

ApplyToHyperlinks and most of the rest of that code just update an in-memory copy of the page XML. It's UpdatePageContent that actually sends that XML back to OneNote to be saved. So it must be the last function call.

@actforjason
Copy link
Author

Why can change the color of text through OneNote itself, page doesn't seem to reload, and it does work in its XML.

@stevencohn
Copy link
Owner

It's just the way Microsoft implement it. The OneNote UI seems to update the page differently than the Interop API that they've published for plugins like OneMore. It's all OneMore has available to use.

@actforjason
Copy link
Author

actforjason commented Nov 4, 2022

There seems to be a way here.
Change OneNote hyperlink color programmatically

The next workaround works:

  1. Add QuickStyleDef to the page with necessary font color.
  2. Set the "quickStyleIndex" attribute for hyperlink's parent element (one:OE) to the value of QuickStyleDef.Attribute("index") that we have added to the page.
  3. Wrap all other text in that one:OE element with {0}
  4. Insert the empty one:T element before the hyperlink

And the hyperlink text color will be like we defined it in QuickStyleDef.

@stevencohn
Copy link
Owner

No, quickstyles should be preserved for OneNote built-in styles and the OneMore custom styles. You're implying fabricating a quickstyle just to prevent a hyperlink from changing color but that quickstyle wouldn't be related to any style that the user could change via the UI. This is not a good solution.

Ostensibly, this is working as intended. It doesn't look 100% correct, but it's doing what it should do - at least as far as the Interop API allows. There's nothing left to do here.

@stevencohn stevencohn added released Available in a released installer and removed next-release Addressed but not yet released labels Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released Available in a released installer
Projects
None yet
2 participants