Comments (6)
@Anya1304 thanks for providing more details, seesm I can reproduce this error. This has been logged in our internal system and we will take a look at this and do some investigation. I see you opened another case 4463, will you please close this one and let's use 4417 to track the issue?
from office-js.
Hi @JHJ-MS Could you please help take a look this issue? Thanks.
from office-js.
hi @Anya1304, thanks for reaching out. I am afraid we need to confirm more details with you. When you say "What we expect is that when a document is opened using context.document.insertFileFromBase64, only the styles specific to that particular document should be applied.", can you explain more about "styles specific to that particular document" mean? We know that a document has both built-in styles such as "Heading 1", "Heading 2"... and customized styles. do you only want to import the built in styles?
In case if you don't want the styles from the base64 document at all, does set "importStyles: false" will meet your needs?
from office-js.
Hi @jipyua,
Sorry for the confusion earlier. When I mentioned "styles specific to this particular document", I meant that only styles unique to a particular document should appear in the Styles Gallery when that document is opened.
We need to import custom styles , so { importStyles : true }
is essential for us.
Let me clarify the problem again:
The issue arises when I open multiple documents consecutively. Instead of only displaying the styles relevant to the currently opened document, the "Styles gallery" accumulates all the styles from each document I've opened (both built-in and custom). This means that if I've opened 100 documents, I will end up seeing a lot of styles, including those from previous documents, cluttering the gallery.
We've looked into resolving this by removing the custom styles and hiding the built-in ones before opening a new document. This approach has poor performance and after switching through several documents, an error is thrown. The more styles documents have, the faster the error appears. (as shown in video and screenshot below)
I created a snippet in the ScriptLab that contains this logic. Hope this helps to solve the problem!
snippet.txt
https://github.com/OfficeDev/office-js/assets/55894856/1e83bb1a-66a3-45dd-937d-aa4e7ef1fdd8
from office-js.
hi @Anya1304 thanks for the clarification, it's more clear now! By running the provided code snippet, I didn't see the execption in the video and the base64 files can be imported correctly. From the provided code, you are deleting all accumulated non-builtin styles (which are custom styles) everytime insert a base64 file, does it mean you just want to import the builtin styles from the base64 document? So far the document.insertFileFromBase64() API doesn't provide the functionality to differentiate the two. We track Office Add-in feature requests on our Microsoft 365 Developer Platform Ideas Forum. Please add your request there. Feature requests will be considered when we go through our planning process. Please let us know if you have other feedbacks or suggestions. Thanks.
if (!style.builtIn) {
style.delete();
}
from office-js.
Hi @jipyua. We need to import both custom and built-in styles and display only the styles relevant to the currently open document in the Styles Gallery.
The code snippet provided above does exactly what we want! It removes the custom styles, removes the built-in styles from the Styles Gallery, and imports a new document with the new styles, so the only styles from the new base64 will appear in the Styles Gallery
But the error does not occur immediately. It may take several switches between documents to see the error. I can't create the files to speed up the error, but this error ALWAYS occurs.
I've made another snippet with multiple documents. If you switch between them a few times, you will definitely see the error.
To reproduce it, just switch between the documents until the error occurs (may take about 8-15 switches to see the error)
error.mp4
from office-js.
Related Issues (20)
- body.clear() not working for content controls HOT 3
- How to make slide active Or How to insert image using index HOT 4
- Addin sample not showing in new look outlook and browsers. HOT 5
- Identifying Usage of New Outlook in Office-js Add-ins HOT 1
- Not able to sideload outlook addin. in macbook there is no option to add the manifest file HOT 5
- Inserting Signature with the OnMessageSend event duplicates the signature
- The identity API is not supported for this add-in in online Word HOT 2
- Excel Online: calculation state can get stuck in Pending state when workbook contains charts HOT 3
- IP Address Range Needed for Microsoft Office Add-in Validation Process
- Office API messageParent Outlook on android doesn't work
- NAA: Unable to acquire access token for event-based activation (onMessageSend) HOT 2
- Outlook addin using Bootstrap modal or offcanvas bleeds through on Mac version of Outlook. Classic and New Outlook for Mac. HOT 2
- [Word API] Document.compare: ability to specify Original and Revised document?
- Outlook NAA issue: "Something went wrong. [7q6cl]" Error HOT 5
- Web Outlook provides improper attachment data if attachment is still uploading to the email HOT 2
- [Question] Is it safe to use `CustomFunctions.delayinitialization()`
- New Outlook - emails stuck in outlook at queued or draft status HOT 3
- context.application.createDocument works only first time HOT 1
- WorkBook level Define name is getting corrupted while reopening excel using base64
- In Outlook, getAllInternetHeadersAsync works on an item in the Inbox, but not the sent folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from office-js.