Coder Social home page Coder Social logo

Comments (6)

jipyua avatar jipyua commented on August 10, 2024 1

@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.

shanshanzheng-dev avatar shanshanzheng-dev commented on August 10, 2024

Hi @JHJ-MS Could you please help take a look this issue? Thanks.

from office-js.

jipyua avatar jipyua commented on August 10, 2024

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.

Anya1304 avatar Anya1304 commented on August 10, 2024

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
photo_2024-05-10_12-45-15

from office-js.

jipyua avatar jipyua commented on August 10, 2024

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.

Anya1304 avatar Anya1304 commented on August 10, 2024

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)

snippet.txt

error.mp4

from office-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.