Insertion Behaviour
When a snippet is inserted manually in the Word add-in — by double-clicking it in the snippet bar or by drag and drop — primedocs decides from the cursor position and the text selection whether the snippet is placed in the current paragraph or in a new paragraph of its own. Anyone building snippets should know these rules to design snippets that land cleanly in the target document.
These rules apply to the Word add-in of the Desktop Client and to snippets carrying Word content (types WordContent and FormattedText). Plain text snippets are inserted directly at the cursor position without any paragraph adjustment. In the web add-in, a snippet is always inserted unchanged at the current selection.
Without a text selection
If no text is selected, placement depends on the cursor position within the paragraph:
| Cursor position | Behaviour |
|---|---|
| At the start of the paragraph (text follows) | Snippet is inserted in a new paragraph above |
| At the end of the paragraph (text precedes) | Snippet is inserted in a new paragraph below |
| In the middle of the text (text before and after) | Snippet is inserted in the same paragraph at the cursor position |
| Empty paragraph | Snippet is inserted into the empty paragraph (no additional paragraph) |
The newly created paragraph adopts the paragraph formatting defined by the current paragraph style's "style for following paragraph".
With a text selection
If text is selected, the snippet is inserted into the same paragraph and replaces the selection. What matters is whether the selection includes the start or the end of the paragraph:
- Selection from the start of the paragraph (one or more characters): the part after the selection is appended to the last paragraph of the snippet.
- Selection up to the paragraph mark (one or more characters): the part before the selection is appended to the first paragraph of the snippet.
- Selection within the paragraph only (neither start nor end): same behaviour as without a text selection at that position — inserted in the same paragraph.
- Entire paragraph selected: same behaviour as for an empty paragraph.
Drag and drop
With drag and drop, primedocs always behaves as in the text-selected case: a placeholder text is dropped at the target position, selected, and then replaced with the snippet content. As a result, the snippet lands in the same paragraph — even when dropped at the start or end of a paragraph. To place a snippet in a new paragraph of its own, inserting by double-click with the appropriate cursor position is more reliable.
If a snippet ends with an empty paragraph mark, inserting it produces an extra empty paragraph. Remove such superfluous paragraph marks when creating the snippet to get a clean insertion result.