Developing HTML functionalities within the OneNote Add-in API

I have developed my own OneNote Add-in using Nodejs, but I am encountering two issues that I have been unable to resolve despite extensive research.

The add-in I created adds a new outline to a OneNote page, which includes an HTML table with one column and multiple rows. My goal is to set the background color of specific rows within the table. I have attempted various methods, such as:

  • Using the bgcolor attribute for TR: <tr bgcolor='red'>
  • Applying the bgcolor attribute to TD: <td bgcolor='red'>
  • Setting the style attribute for TR:
    <tr style='background-color:red'>
  • Applying the style attribute to TD:
    <td style='background-color:red'>
  • Utilizing a separate CSS file
  • Using the Hex value for the color (red) #FF0000
  • Exporting a OneNote 2016 page as "Single File Web Page (*.mht)", inspecting the contents and trying to replicate them manually
  • Attempting to view source on the OneNote web version of my page in order to inspect a table row with a background color setting (however, the content is deeply buried)
  • Trying to programmatically add HTML content to the page, though Microsoft's OneNote API does not offer clear guidance on inserting a table

Despite all efforts, nothing seems to work. Additionally, I wish to use &nbsp in one of the table cells to preserve white space, but neither this nor the <pre> tag function as expected. OneNote simply disregards my markup, except for specifying the thickness of the table border with <table border=1>.

For reference, I adapted code from the following sample: Build your first OneNote task pane add-in

The above sample enabled me to develop the following: taskpane.js in my GitHub repository

Answer №1

In search of the answer...

After posing my question, I stumbled upon this resource:
OneNote API HTML tag support

It seems that Microsoft does not provide support for bgcolor, background CSS for tables/tr/td, or CSS in general when it comes to the OneNote API. Surprisingly, the <pre> tag and &nbsp are also missing from the list.

Answer №2

Hey there,

Although this post is a bit dated, I wanted to share my recent discovery as not many others have posed the same question. I finally stumbled upon a solution.

You can apply regular inline styling however make sure to use backslashes for quotes within the ""var html =..."" line.

Here's an example:

var html = "<p style=\"color: red;font-family:Arial;text-align:left;background-color:pink;\"> This paragraph showcases red, Arial text</p><table><tr><td style=\"background-color: #FFC0CB;\">A rosy pink table cell</td></tr></table>"

Hopefully, I'll be able to figure out how to change the whole page color dynamically soon...

Best regards, Chris

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The dimensions on Next.js pages exceed those of the viewport by a significant margin

I have recently encountered a perplexing issue where the dimensions of my webpage appear to be 2.7 times larger than the viewport, even when there is no content or styles applied. The strange part is that it seems as though the page has been scaled up, eve ...

Using CSS to encompass a group of words within a circular shape

I am attempting to encircle multiple words within one circle, but currently each word is enclosed in its own circle. Below is the code I am currently using. HTML <div class="numberCircle"> <span>Circle all words</span> </div> ...

Struggling to properly line up the baselines of navigation list items that are styled as circular elements using CSS

I have transformed my navigation menu into a series of CSS circles with text inside. The issue I am facing is that the text spills out unevenly based on the amount of content in each circle. To address this, I used a JavaScript solution to center-align the ...

Which should be used for front-end development: underscore.js or async.js with browserify?

For those in the back-end node.js development world, there's a fantastic library called async. If you're a front-end developer, you're probably familiar with the amazing library known as underscore. Interestingly, both of these libraries o ...

Issue with storing a SQL time(7) field in a database using Node.js

I am currently utilizing the nodemssql package to interact with a SQL Server Azure database. Field time(7) > RecurrenceType.columns.add('StartTime', mssql.Time(7)); > RecurrenceType.columns.add('EndTime', mssql.Time(7)); ...

Having trouble with Angular 2 and localhost/null error while attempting to make an http.get request?

In my Angular 2 webpage, I am using the OnInit function to execute a method that looks like this (with generic names used): getAllObjects(): Promise<object[]>{ return this.http.get(this.getAllObjectsUrl).toPromise().then(response => response. ...

Unable to retrieve data from PHP using AJAX request

My project consists of 3 interconnected files: index.php, functions.js, and compute.php In index.php, there is a div that triggers a function in functions.js called compute(), which sends an AJAX request to perform a task in compute.php The code in index ...

Effectively handle multiple connections from nodejs to postgres using the pg library

I need to run a script that performs multiple queries using the pg library for managing connections. However, I am facing an issue where my program stops working when the connection pool is full and does not queue future queries. I have tried setting the p ...

The initial selection in the First DropDown does not activate the function of the second DropDown

I am facing an issue with my MVC application that involves using AngularJS for two DropDowns. The first DropDown successfully populates with data from the DB. However, when a user selects an option from the first DropDown, the second one should update acco ...

Achieving Perfect Alignment in Bootstrap Containers

My form is not aligned in the center of my page. Below is my HTML file and the resulting output. How can I center my view? https://i.sstatic.net/mqXr8.png Here is the code snippet from my HTML: <div class="container"> <div class='row justi ...

Retrieve the JQuery element using its ID or class identifier

I need some assistance with retrieving the innerHTML of element number 5 in a JQUERY Object. Can someone provide guidance on how to achieve this? Your help is greatly appreciated. ...

Tips for incorporating drop-down arrow states into a Bootstrap 4 accordion with Angular or CSS

Is there a simple way to implement an arrow (>) to show the aria-expanded="true" or aria-expanded="false" states in the Bootstrap 4 accordion using either Angular2 or plain CSS? I have gone through several tutorials and attempted numerous methods, but ...

Could CSS transitions stack on top of each other?

My current approach involves using CSS to create sliding menus. With JavaScript, I simply apply a class to trigger the CSS animations. The menu consists of 4 columns with list items in desktop mode, but collapses into only headings in mobile mode. These he ...

When I click the button, I would like the value of the button to be displayed in a textbox

I'm currently working on an interactive virtual keyboard project and need help with a function that will display the pressed button values in a text box located next to the keyboard. Here is the code snippet I've come up with so far: <script ...

Accessing JavaScript results in PHP

Hello everyone! I am working on creating a dropdown menu for selecting time using JavaScript to get the computer's current time. My goal is to have an output that automatically selects the option in the dropdown if it matches the computer's time. ...

What could be the reason for the d-flex class in bootstraps preventing my div from expanding to 100% width?

I have a div where I need to display two elements next to each other: a search input field and the corresponding submit button. My attempt so far was to achieve this using the following code: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn. ...

Tips for transmitting data from a form to a server

I need assistance with sending form data to my backend server for a small website project. Although I have most of the backend work completed, I am struggling to figure out how to send the form data to the server. My goal is to send the data to a localhost ...

Nested asynchronous mapping in Node.js involving multiple HTTP requests

Currently, I am attempting to iterate through an array of URLs and retrieve responses from a specific set of URLs. The goal is for the outer loop to only proceed after all inner requests have been completed, resulting in the desired outcome as shown below: ...

The output of the Node.js crypto.pbkdf2 function may not match the result obtained from CryptoJS.PBKDF

Currently, I am utilizing PBKDF2 on both the frontend with CryptoJS and the backend with Node.js. Despite using the identical salt, algorithm, number of iterations, and password, the derived keys are turning out to be different. Below is the code snippet ...

Elevating the table and row dimensions in Bootstrap

I'm currently working with Bootstrap 3 and I'm having trouble adjusting the height of my table and row. I've tried setting properties like line-height, but nothing seems to work. How can I increase the height? <style> div#descrip ...