The CreateNumbering method can only create fixed numbering types. I want to implement a function that initializes the numbering according to the current paragraph numbering type, similar to the built-in start new list function.
Hello @jinwen
Please elaborate on this. What exact operation are you describing? If possible, share step-by-step scenario.
For example, there is a numbered list from 1 to 5 in the document. I want to renumber the paragraphs starting from number 3.
Please elaborate on this. What exactly “renumber” refers to? Since there is numbered list, I assume its either making it 1, 2, 1, 2, 3 (5 total) or 1, 2, 2.1, 2.2, 2.3 (5 in total).
I want to make a renumbering plugin. Let me give you an example. The existing paragraphs are numbered 1, 2, 3, 4, 5. Put the cursor on the paragraph numbered 3 and click the renumbering plugin. The numbering sequence is adjusted to 1, 2, 1, 2, 3.
Thanks. I will check if such possibility is available. Please await my feedback.
Generally speaking, there is no direct method. However, you can reset the numbering of current paragraph with methods GetCurrentParagraph and SetNumbering, something like that:
(function()
{
let doc = Api.GetDocument();
let para = doc.GetCurrentParagraph();
let numLvl = para.GetNumbering();
let num = numLvl.GetNumbering();
let newNum = Api.FromJSON(num.ToJSON());
let curLvlIdx = numLvl.GetLevelIndex();
para.SetNumbering(newNum.GetLevel(curLvlIdx));
})();
This is macro sample that you can test out before creating button for your plugin and defining callCommand()
to perform this action.
UPD: Respective method for starting new list as via context button will be added in one of the future releases.