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

[Word] getting 'paragraph.listItem' is failed if deleted paragraph has list item on only Web Word #5335

Open
1 of 3 tasks
shinji-morimitsu opened this issue Jan 30, 2025 · 2 comments
Assignees
Labels
Area: Word Issue related to Word add-ins Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs

Comments

@shinji-morimitsu
Copy link

Provide required information needed to triage your issue

We are implementing an automatic text update program in Word AddIn.
We need to update the document with take care of the tracked change histories.
Only Web Word causes a failure to get list or listItem of paragraph, if the paragraph is deleted.

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: Office on the web
  • Host [Excel, Word, PowerPoint, etc.]: Word
  • Office version number: ______
  • Operating System: ______
  • Browser (if using Office on the web): Chromium Edge 132.0.2957.127

Expected behavior

Same behavior with Native Word.
paragraph.load('list') or paragraph.load('listItem') are success and they should have values before deleted.

output should be:

paragraph[0]: text:[1st item] listItem:[] level:[0] index:[0]
paragraph[1]: text:[2nd item] listItem:[] level:[0] index:[0]
paragraph[2]: not list item

Current behavior

paragraph.load('list') or paragraph.load('listItem') are failed on Web Word, if the paragraph is deleted in change history.

getting "listOrNullObject" failed: RichApi.Error
getting "listItemOrNullObject" RichApi.Error
n {name: "RichApi.Error", code: "GeneralException", traceMessages: Array[0], innerError: null, debugInfo: Object…}

Steps to reproduce

  1. run live example.


Link to live example(s)

$("#run").on("click", () => tryCatch(run));

async function run() {
  OfficeExtension.config.extendedErrorLogging = true;

  await Word.run(async context => {
    // clear paragraph
    context.document.changeTrackingMode = Word.ChangeTrackingMode.off;
    context.document.body.clear();
    await context.sync();
    console.log('clear document');
  });
  await Word.run(async context => {
    // setup text
    const paragraph1st = context.document.body.insertParagraph("1st item", Word.InsertLocation.start);
    const paragraph2nd = paragraph1st.insertParagraph("2nd item", Word.InsertLocation.after);
    const list = paragraph1st.startNewList();
    await context.sync();
    paragraph1st.load('listItem');
    await context.sync();

    paragraph2nd.attachToList(list.id, paragraph1st.listItem.level);
    await context.sync();

    console.log('setup texts');
  });

  await Word.run(async context => {
    context.document.changeTrackingMode = Word.ChangeTrackingMode.trackAll;

    // delete one of item
    const paragraph = context.document.body.paragraphs.getFirst();
    paragraph.delete();
    await context.sync();

    console.log('delete paragraph');
  });

  await Word.run(async context => {
    const paragraphs = context.document.body.paragraphs;

    // get list item info
    paragraphs.load('listOrNullObject');
    try {
      await context.sync();
    } catch (error) {
      console.error(`getting "listOrNullObject" failed: ${error.name}`);
    }
    paragraphs.load('listItemOrNullObject');
    try {
      await context.sync();
    } catch (error) {
      console.error(`getting "listItemOrNullObject" ${error.name}`);
    }

    paragraphs.load('text,isListItem,listItemOrNullObject');
    await context.sync();

    paragraphs.items.forEach((paragraph, index) => {
      if (paragraph.isListItem) {
        console.log(`paragraph[${index}]: text:[${paragraph.text}] listItem:[${paragraph.listItemOrNullObject.listString ?? 'null'}] level:[${paragraph.listItemOrNullObject.level ?? 'null'}] index:[${paragraph.listItemOrNullObject.siblingIndex ?? 'null'}]`);
      } else {
        console.log(`paragraph[${index}]: not list item`);
      }
    })
  });
}

// Default helper for invoking an action and handling errors.
async function tryCatch(callback) {
  try {
    await callback();
  } catch (error) {
    // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
    console.error(error);
  }
}

Provide additional details




Context

We are implementing an automatic text update program in Word AddIn.
We need to update the document with take care of the tracked change histories and item symbol.
Because the program should match carefully the text output from our engine to the list item in Word.

Useful logs

  • Console errors
  • Screenshots
  • Test file (if only happens on a particular file)

Image

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Area: Word Issue related to Word add-ins label Jan 30, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: attention 👋 Waiting on Microsoft to provide feedback label Jan 30, 2025
Copy link
Contributor

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

@shinji-morimitsu shinji-morimitsu changed the title [Word] getting 'paragraph.listItem' is failed for deleted paragraph on only Web Word [Word] getting 'paragraph.listItem' is failed if deleted paragraph has list item on only Web Word Feb 6, 2025
@guoms1 guoms1 added Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Feb 6, 2025
@guoms1
Copy link

guoms1 commented Feb 6, 2025

Hi, @shinji-morimitsu

Thank you for bringing this to our attention! I've been able to reproduce the issue on my end and will be forwarding it(#9756935) to the relevant team for further investigation.

We truly appreciate your patience and your effort in reporting this. Please let us know if you have any additional details that might help.

Best,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Word Issue related to Word add-ins Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs
Projects
None yet
Development

No branches or pull requests

2 participants