Birch UI v0.1
Pricing

Editing dialogsDocument

Every dialog and pane of Birch UI Document Editor with its command, shortcut and ribbon control, what it changes in the document and what is written to DOCX.

Open .md

The editor has a dialog for each group of settings that does not fit on the ribbon. Each one opens from a ribbon control, from a command and, where Word has one, from the same shortcut. A dialog is loaded the first time it is opened, so none of them is part of the editor's start-up code.

What every dialog and pane has in common#

All dialogs are built from one frame, so they behave the same way:

  • The header shows an icon for the subject of the dialog and its title. The footer is divided from the body, with the buttons at the end: Cancel (or Close) first and the one primary button last. A dialog never has more than one primary button.
  • Focus starts in the first control of the body: the first field, or the selected preset where a dialog starts with presets. A tab strip is skipped, and so is a list that is still empty. A confirmation that discards work, such as Start a new document?, starts on Cancel instead.
  • Enter in a text field, a number field or a drop-down list runs the primary action. It does not in a multi-line field, and the Symbol dialog stays open so that several symbols can be inserted.
  • Escape cancels. Focus then returns to the control that opened the dialog: the ribbon button when it was opened with the keyboard, the document when it was opened with the mouse, a menu that has closed or a shortcut.
  • Tab stays inside the dialog.

Side panes (Styles, Navigation, Find and replace, Reveal formatting, Revisions, Version history) have a header with an icon, the title and a Close button whose tooltip names Esc. Opening a pane puts focus in its first control, and closing it returns focus to the ribbon button that opened it, or to the document.

A list with nothing in it says so with an icon, one sentence and at most one action: New comment in the comments panel, Make this paragraph a heading in the Navigation pane, Save this version now in Version history, Turn on track changes in the Revisions pane and Clear search where a search found nothing. The list boxes inside dialogs (tab stops, bookmarks, AutoCorrect entries) show a one-line hint while they are empty.

All dialogs#

Dialog Command Shortcut Ribbon
Font fontDialog Ctrl+D Home, Font, Font settings…
Paragraph paragraphDialog Home, Paragraph, Paragraph settings…
Tabs tabsDialog double-click a tab stop on the ruler Layout, Paragraph, Tabs…, or Tabs… in the Paragraph dialog
Paste special pasteSpecialDialog Ctrl+Alt+V Home, Clipboard, Paste menu, Paste special…
Borders and shading bordersDialog Home, Paragraph, Borders menu; Layout, Page background, Page borders
Page setup pageSetupDialog Layout, Page setup, Page setup
Columns columnsDialog Layout, Page setup, Columns menu, More columns…
Footnote and endnote options noteOptionsDialog References, Footnotes, Note options
Insert link hyperlinkDialog Ctrl+K Insert, Links, Link
Define new multilevel list multilevelDialog Home, Paragraph, Multilevel list menu
Define new number format numberFormatDialog Home, Paragraph, Numbered list menu
List library listLibrary Home, Paragraph, list menus
AutoCorrect options autocorrectDialog Review, Proofing, AutoCorrect options…
Reveal formatting (pane) revealFormatting Shift+F1 Home, Font, Reveal formatting
Document properties documentPropertiesDialog Review, Proofing, Document properties…
Word count wordCountDialog Ctrl+Shift+G Review, Proofing, Word count
Symbol, Date and time, Drop cap, Watermark symbolDialog, dateTimeDialog, dropCap, watermarkDialog Insert and Layout tabs
Keyboard shortcuts keyboardShortcuts Ctrl+/ File, Keyboard shortcuts; see Keyboard shortcuts

The table, picture, bookmark, cross-reference, caption, table of contents, content control, protection, compare and combine dialogs are described on the pages of their features.

How the dialogs behave#

  • A dialog is modal: focus moves into it, Tab and Shift+Tab stay inside it, Escape or Cancel closes it without changing anything, and focus returns to where it was. Enter in a text or number field presses OK.
  • Tabs inside a dialog follow the tabs pattern: Left and Right move between them, Home and End jump to the first and last.
  • Every control has a label. A value that cannot be used is marked with aria-invalid and receives focus; the dialog stays open.
  • OK makes one change to the document that Ctrl+Z undoes in one step. The Borders and shading dialog makes two steps when you change paragraph and page borders at once.
  • exec('…Dialog') returns true as soon as the dialog applies and false when it does not, for example in a read-only document. The dialog appears when its code has arrived; pressing Escape before that cancels it.
TypeScript
if (editor.canExec('fontDialog')) editor.exec('fontDialog');

Font#

Font, style, size and colour, underline style and colour, strikethrough, double strikethrough, superscript, subscript, small caps, all caps and hidden text on the Font tab; scale, character spacing, position and kerning on the Advanced tab. The preview shows the selected text with the settings applied. Only what you change in the dialog is changed in the selection, so a selection that is partly bold stays partly bold when you set small caps.

The same settings are available from code:

TypeScript
editor.setFontFormat({
  fontFamily: 'Georgia',
  fontSize: 14,
  underline: 'double',
  underlineColor: '#1f6feb',
  smallCaps: true,
  spacing: 1.5,
  position: -2,
});

const format = editor.getFontFormat();
if (format.hidden) editor.exec('fontFormat', { hidden: false });
FontFormat Values DOCX
fontFamily, fontSize, bold, italic, color text, points, booleans, #rrggbb; null removes w:rFonts, w:sz, w:b, w:i, w:color
underline, underlineColor 'none', 'single', 'words', 'double', 'thick', 'dotted', 'dash', 'dotDash', 'wave' w:u w:val w:color
strike, doubleStrike one excludes the other w:strike, w:dstrike
superscript, subscript one excludes the other w:vertAlign
smallCaps, allCaps, hidden booleans w:smallCaps, w:caps, w:vanish
spacing points; positive expands, negative condenses w:spacing
scale per cent, 1 to 600 w:w
position points; positive raises, negative lowers w:position
kerning smallest font size in points that is kerned, or null w:kern

Ctrl+Shift+D, Ctrl+Shift+K and Ctrl+Shift+H switch double underline, small caps and hidden text. Hidden text is not drawn; Show formatting marks shows it with a dotted underline.

Paragraph and tabs#

The Indents and spacing tab holds alignment, outline level, left and right indent, first-line or hanging indent, space before and after, line spacing (single, 1.5 lines, double, at least, exactly, multiple) and Don't add space between paragraphs of the same style. The Line and page breaks tab holds widow/orphan control, keep with next, keep lines together and page break before. The outline level puts a paragraph of any style into the navigation pane and the table of contents.

TypeScript
editor.setParagraphFormat({
  align: 'justify',
  outlineLevel: 2,
  indentLeft: 36,
  indentFirstLine: -18,
  lineRule: 'exact',
  lineHeightPt: 16,
  contextualSpacing: true,
  keepWithNext: true,
});

Tabs… opens the Tabs dialog for the same paragraphs: position, alignment (left, centre, right, decimal, bar), leader, Set, Clear and Clear all, and the default tab stops of the document. The default is a document setting (w:defaultTabStop); exec('defaultTabStop', points) sets it from code.

Paste special#

After a paste from another application a Paste options button appears at the end of the pasted content. It switches the result between Keep source formatting, Merge formatting, Keep text only and Picture, and its last button opens the Paste special dialog. The options stay available until the document changes again.

Ctrl+Alt+V opens the dialog directly. Right after a paste it switches the format of that paste. Otherwise it reads the clipboard and pastes it in the format you choose; the browser asks for permission the first time, and when it refuses, the dialog says so and tells you to paste with Ctrl+V and use the paste options.

Picture inserts a copied picture as it is. Copied text is drawn as a picture in the font of the document; its formatting is not kept.

TypeScript
editor.pasteHtml('<p><b>Net 30</b> payment terms</p>', 'mergeFormatting');
editor.exec('pasteMode', 'textOnly');

With formatting copied by Ctrl+Alt+C and text selected, Ctrl+Alt+V pastes that formatting instead, as before.

Borders and shading#

Borders sets the paragraph border: none, box, shadow or custom sides, with style, colour and width. Shading sets the fill behind the paragraph. Page border draws a border around every page of the section or of the whole document. exec('bordersDialog', 'page') opens the dialog on that tab.

Page setup#

Margins (top, bottom, left, right, gutter, mirror margins) and orientation, Paper (preset sizes or a custom width and height) and Layout (section start, different first page, different odd and even pages, header and footer distance, vertical alignment). Apply to chooses the whole document, this section, or this point forward, which starts a new section at the cursor.

Columns#

Presets for one, two and three columns and for a narrow left or right column, the number of columns, width and spacing for each column or equal widths, a line between columns, and the same Apply to choices as Page setup.

TypeScript
editor.exec('columns', { count: 2, gap: 24, separator: true });

Footnote and endnote options#

Where footnotes go (bottom of the page or below the text) and where endnotes go (end of the section or end of the document), the number format, the first number, and whether numbering continues, restarts in each section or restarts on each page. See Footnotes and references.

The Insert link dialog links the selection, or inserts new link text, to one of three targets:

  • Web page: an address. northwind.example/rates becomes https://northwind.example/rates; script addresses are refused.
  • Email address: an address and a subject, stored as a mailto: link.
  • Place in this document: a heading or a bookmark. Linking to a heading puts a hidden bookmark around it, as Word does.

ScreenTip is the text shown when the pointer rests on the link. With the cursor in a link the dialog edits it, and Remove link takes the link away and keeps the text.

TypeScript
editor.setHyperlink({ href: 'mailto:[email protected]?subject=Invoice%20query', title: 'Write to accounts' });
editor.setHyperlink({ href: 'https://northwind.example/rates', text: 'rate card' });
editor.setHyperlink(null);

Lists#

Define new multilevel list sets, for each of up to six levels: the number format (text with %1, %2, … for the numbers of the levels), the number style, the first number, after which level numbering restarts or that it never restarts, legal style numbering (every number in the label is shown in digits), a paragraph style applied to the items of the level, the alignment of the number, where the number and the text start, and what follows the number (a tab, a space or nothing). Modify the current list… opens the same dialog for the list at the cursor. Define new number format is the one-level form.

TypeScript
const id = editor.defineMultilevelList({
  name: 'Schedule clauses',
  levels: [
    { numberStyle: 'upperRoman', format: 'Article %1', indent: 54, start: 3, follow: 'space' },
    { numberStyle: 'decimal', format: '%1.%2', indent: 36, legal: true, restartAfter: 0, align: 'right' },
  ],
});
editor.exec('applyMultilevelList', id);

The definition is saved with the document. In DOCX it is an abstract numbering with w:start, w:numFmt, w:lvlRestart, w:isLgl, w:pStyle, w:suff, w:lvlText, w:lvlJc and w:ind for each level, and it is read back as the same list.

Modify the current list… in the same menu also works inside a list that came from a Word file. The dialog then opens as Change list levels with the levels of Word's numbering definition; the name and the number of levels are fixed. On OK the levels are written into that definition: the numbers in the text change at once, and when the file is saved only the changed levels of the numbering part are rewritten. Levels seven to nine, the font and formatting of the numbers, tab stops of the levels and everything else in the part stay as Word wrote them.

TypeScript
const levels = editor.getListLevels(); // null when the cursor is not in a list from a Word file
if (levels) {
  levels[1] = { ...levels[1], numberStyle: 'upperRoman', format: '%1.%2' };
  editor.setListLevels(levels);
}

AutoCorrect options#

A table of replace text as you type entries, the abbreviations after which the next word is not capitalised, and a switch for each automatic correction: capital first letter of sentences and of table cells, smart quotes, dashes, ordinals, fractions, symbols, links and automatic lists.

The settings belong to the person, not to the document. Give the editor a place to keep them:

TypeScript
import { createDocumentEditor } from '@birchui/document';

const stored = createDocumentEditor(host, {
  autocorrectStorage: {
    load: () => JSON.parse(localStorage.getItem('editor.autocorrect') ?? 'null'),
    save: (settings) => localStorage.setItem('editor.autocorrect', JSON.stringify(settings)),
  },
});
stored.on('autocorrectChange', ({ options: settings }) => notify(settings));

load and save may return promises, so the settings can live in your own account store. The editor never sends them anywhere itself. Without autocorrectStorage the settings last until the editor is destroyed. getAutocorrectOptions() and setAutocorrectOptions(options) read and change them from code.

Reveal formatting#

Shift+F1 opens a pane that describes the selection: its paragraph style, the paragraph formatting applied on top of the style, its character style, and the character formatting applied on top. Each section has a Clear button. The pane follows the selection.

Command Shortcut Effect
clearCharacterFormatting Ctrl+Space Removes font, size, colour and effects from the selection
clearParagraphFormatting Removes alignment, indents, spacing, borders and tab stops; keeps the style
clearCharacterStyle Removes the character style of imported text
applyStyle with 'Normal' Removes the paragraph style

Document properties#

Summary edits the title, subject, author, manager, company, category, keywords and comments. Statistics shows when the document was created and last saved, by whom, its revision number and the page, paragraph, line, word and character counts. Custom adds, changes and removes custom properties of type text, number, or yes or no.

TypeScript
editor.setDocumentProperties({
  title: 'Supply agreement',
  company: 'Northwind Traders Ltd',
  custom: { 'Matter number': 'NW-2291', Confidential: true },
});
const { title, custom } = editor.getDocumentProperties();
notify(title, custom);

A property set to null is removed. The properties are part of the document JSON and are written to docProps/core.xml, docProps/app.xml (company and manager) and docProps/custom.xml.

Click and type#

In the page layout, a double-click in the empty area below the last paragraph of a page puts the cursor there: empty paragraphs are added down to the clicked line. The third of the page width you click in sets the new paragraph: the left third leaves it left-aligned, with a first-line indent at the last default tab stop before the click; the middle third centres it; the right third right-aligns it. A double-click in the empty space to the right of a short line adds tab characters up to the last tab stop before the click and puts the cursor there; it does nothing in a centred, right-aligned, justified or right-to-left paragraph. Each is one undo step. Click and type is off while the editor is read-only, in form mode or protected, and on pages with columns. Pass clickAndType: false to turn it off.

↑ ↓ to move, Enter to open, Esc to close