Home › Forums › General XMetaL Discussion › Structure view: how to set the initial collapse level? › Reply To: Structure view: how to set the initial collapse level?
Reply to: Structure view: how to set the initial collapse level?
January 5, 2016 at 1:11 amI'm still not exactly sure what you want, but I will take a guess that adding another loop will be enough. In this example the nodes in the Structure View at a specific level as well as nodes within that level will be collapsed. The user will then need to expand multiple levels to see the inner content. That seems annoying to me, so I'm not sure that is what you really want.
If that sounds right please try the following.
[code=structureViewDefaultCollapse.mcr]
ActiveDocument.FormattingUpdating = false;
var origSelection = ActiveDocument.Range;
for(var j=0;j
var xpath = “//*[count(ancestor::*) = ” + ancestors + “]”;
var nodes = ActiveDocument.documentElement.getNodesByXPath(xpath);
for(var i=0;i
Selection.SVCollapsedContainer = true;
}
}
origSelection.Select();
ActiveDocument.FormattingUpdating = true;
]]>
[/code]