Repository navigation
Charts are drawn: those of a workbook from its cells, those of Word documents and slides from the values saved in them, flat and 3D, in the look the file gives them. The pages of a document are cut as Word cuts them, between the lines of a paragraph and the rows of a table. Markdown shows TeX math as equations and code in the colors of its language; source files open in a code view. For hosts: every text of the UI from one table that can be translated, components of your own in the bars and dialogs, a viewer without its chrome driven by a controller, font files, numbers typed in a locale. And the fixes of a third QA pass: data loss, focus, undo, collaboration.
Charts
- A chart was a box saying "Chart". It is drawn, as a picture over the cells: bar and column (clustered, stacked, 100%, upright or horizontal), line (markers, smoothing), area, pie and doughnut (exploded slices, the angle of the first slice, a ring per series), scatter, bubble, radar, stock (high-low lines, up-down bars), surface (seen from above as a contour chart, or as a wireframe), and combinations of them on primary and secondary axes.
- 3D charts in the view the file gives (tipped, turned, with right-angle axes or in perspective), inside their walls and floor: columns and bars as boxes, cylinders, cones and pyramids, lines as ribbons, areas as slabs, pies as thick tilted disks, surfaces as shaded meshes or wireframes.
- The values are the cells': a chart follows edits and recalculation, and reads a sheet that is not shown yet. Hidden rows and columns are left out where the chart says so (
plotVisOnly), empty cells are gaps, zeros or bridged (dispBlanksAs). A defined name, another workbook or a reference that cannot be read falls back to the values saved in the chart. - Charts in Word documents and on slides are drawn the same way, from the values saved in their chart part. A chart on a slide is still selected and moved as before.
- Axes as Excel sets them: automatic bounds and steps (5% left past the values, steps of 1, 2 or 5: values 1…4 give 0…4.5 by 0.5), a fixed minimum, maximum or unit (also one of them alone), reversed and logarithmic axes, date axes (a band per day, month or year), the place where the axes cross, gridlines, tick and data labels in their number formats, category labels wrapped at spaces or tilted where they do not fit.
- The look of the file: fills as colors, gradients and the preset patterns; line colors, widths and dashes; markers; size, weight and color of the title, the axes, the legend and the data labels; the built-in chart styles (their palettes, tinted plot areas and dark backgrounds, not bevels and shadows); the title (Excel's automatic one, or one taken from a cell), the legend, a plot area placed by hand.
- Limits, so that a crafted file cannot hold the page (a workbook of 4 KB gave a picture of 296 MB): a chart reads up to 255 series and 250,000 points, the charts of a sheet, a document or a presentation 1,000,000 points together; a chart's picture is up to 8 MB, the pictures of a page 16 MB together; a 3D chart is drawn with up to 20,000 marks. A chart past one of these, or one that cannot be read, shows its placeholder. Of more than 2,000 data labels or 20,000 markers, every k-th point shows its own.
- Not drawn yet: the chartex kinds (waterfall, treemap, funnel …: they keep the placeholder), data tables, trendlines, error bars, the data labels of 3D bars.
Documents: pages
- A paragraph that does not fit the rest of a page goes on at the top of the next one, split between two lines; a table between two rows, its header rows repeated on each following page. Both were moved whole to the next page. A merged cell cut by the page end goes on as an empty cell.
- Keep rules choose the cut: widow / orphan control (on unless the file turns it off), keep with next, keep lines together, read from the paragraph, its style and the document defaults.
- Editing goes over the page end: click, type, select, delete, find and the arrow keys; typing that moves the cut keeps the caret where the typing is, also with an input method. The header rows repeated on the following pages are copies, edited on the first page.
- Blocks are split across text columns too. Print waits until every cut is measured.
- Not split: a paragraph in a table cell, and a row (a single line or row taller than the page still makes its page longer).
- Reading where the lines are takes time, and the pages are other pages: the sample of 20,000 paragraphs has 2012 pages where it had 2073, cut in about 3 s.
Documents: tab stops and fixes
- Tab stops are followed: left, center, right and decimal stops with their leaders (dots, dashes, a line), from the paragraph and its styles, and absolute position tabs (
w:ptab): the three parts of a header, the page numbers of a table of contents. In the view, the editor, print and the web page export. A tab typed goes to the next stop. The stops of the file are kept; they cannot be set or moved in the editor yet. - A Markdown file of 50 MB failed with "Maximum call stack size exceeded", and the end of a document taller than the browser lets an element be (21,112 pages) could not be scrolled to. Both open, and the last page is reached, searched, edited and saved. Such a document scrolls like any other: the wheel, Page Down, the arrow keys and the caret move the pages pixel for pixel; the thumb of the scrollbar, Home and End go to their place in the document.
- Typing next to a text box anchored in the paragraph keeps the caret in the paragraph (it went into the box).
- A paragraph written again keeps its comment reference (
.doc), the bookmarks inside a link, a content control or a tracked insertion, and every object of a run that holds several. Footnote and endnote references are no longer doubled. - Tab on an item of a list that defines one level keeps its marker.
- The list button in a table inserted or rebuilt in this session shows the list and takes it away again (#27). What the worker answers during an input method composition is applied when the composition ends (#28). The answers to edits that overlap go to the paragraphs they are for, and the toolbar is not left disabled after the last one (#26, #29).
- Word 97 and RTF paragraphs without widow control keep it off.
Fonts
- The host can supply font files (
fonts: URLs or bytes; the library ships none). A document is measured and paginated once the fonts it uses are loaded, so lines and pages break as with the fonts it names. A font declared as a fallback serves the fonts named before it: Carlito for Calibri, Caladea for Cambria, Liberation for Arial, Times New Roman and Courier New. - A file is fetched only when a shown document uses its family. One that fails is reported (
onError, the console) and the next font of the list is used; one that takes more than 3 s is not waited for: the document is laid out without it, and again when it arrives, the text in view and the caret staying where they are. - A web font of the page that arrived late left the pages with the heights of the font before it: they are measured again. A spreadsheet fits its numbers to their columns again. Print has the fonts of the host.
- Fonts come from the host only: the fonts embedded in a document are not read, and a crafted document cannot have one fetched.
Markdown and source code
- TeX math:
$…$and$$…$$are drawn as equations (the browser's MathML: selectable, read by screen readers, printed). They are recognized as pandoc does, soIt costs $5 and $10,\$and code are left alone. The document stays editable around a formula, which is one object of the text (the caret steps over it, Delete removes it, Undo brings it back), and each formula is saved as it was written. Download as Word gives real Word equations. A command that is not known shows as written and the rest is drawn; a formula that cannot be read shows its source. Not read:\(…\),\[…\],```mathblocks, macros. - Syntax highlighting: a code block is colored by the language of its fence (JavaScript / TypeScript / JSX, JSON, Python, CSS, HTML / XML, YAML, shell, SQL, Go, Rust, Java, C / C++ / C#, Markdown, diff, TOML and more). It stays editable (Enter is a new line of the block, indented as the one before) and is saved with its language and its code as it is. The colors are drawn, never stored: opening a file does not change it, and a Word file made from it holds none.
- Source files (
main.ts,script.py,config.json…, or any text withlanguage) open in a code view with line numbers, in light and dark; Edit makes it editable, and it is saved as plain text in its own name, in its CRLF line breaks if it had them; a file that was not edited is saved as its own bytes (encoding, byte order mark). - Saving writes again only the parts that changed.
__inside a word, bold links and GitHub alerts are kept as written. A quote whose lines go on without>is no longer written again whole when one of its lines is edited.
Spreadsheets
- Numbers typed in a locale (#17): with
locale="de-DE",1,5and1.234,5typed into a cell, the font size box, the margins of Page setup or the size in Header & footer are numbers. The whole entry is a number or none (a prefix is never read), and the separator of the other convention is refused, not guessed. What is saved is the number, the same in every locale; formulas are not localized. Withoutlocaleeverything is read as before, and the browser's language is never used. - Every copy of a dynamic array formula pasted into a larger selection, or filled with the handle, fills its cells; only the first did (#35).
- A column header selects its column only, next to merged cells too: Delete cleared the whole table. The menu of a row header offers rows, that of a column header columns. A workbook opens on the sheet it was saved on.
- A formula that ends where something must follow is kept as the text typed.
DATE,EDATEandEOMONTHgive Excel's serials around 29/02/1900, the day that does not exist. A pattern of theREGEX…functions that would never end is refused as#VALUE!. - Undo and Redo are off when there is no step to take; deleting a sheet asks first; a column widened by what was typed grows again; typing while the sheet is still loading says so instead of doing nothing.
- Fitting a column after an edit no longer fails with "Document closed" when another file is opened at that moment.
Presentations
- Text typed in a shape or a table cell is an undo step in the same history as shape and slide edits, once the text is left; the Redo button follows it.
- Hidden slides and OLE pictures are right when the deck opens.
- A new text box takes what is typed next. After a click on a thumbnail the slides have the keyboard. Text being typed is kept when another slide is picked in the list.
Collaboration
- Documents: what two people do to one paragraph at the same moment is both kept. Text typed in a paragraph someone else splits, joins or restyles goes to the half it was typed in; text typed inside a range someone else formats or deletes stays; undo and redo leave what someone else typed in the same paragraph.
- Spreadsheets: a sort carries the order it made (up to 20,000 rows), so a cell typed at the same moment goes with its row, and a formula typed reads the cells of its row there. The cell being edited and the selection follow the rows and columns someone else inserts, deletes or sorts; when the cell is deleted the typing is given up, with a message.
- Presentations: a slide someone else adds does not end the text being typed in another slide.
- A message that is not well formed no longer brings down the hub or the server.
Viewer, browsers, converters
- Dialogs keep the focus inside and give it back when closed. Ctrl/⌘+S saves from anywhere in the viewer (a sheet tab, a thumbnail). File → Open of a broken file keeps the edited document.
- A file read from a URL whose answer ends before its range (Chromium ends one at 2 GiB) is asked for again from there: a CSV over 2 GiB was cut without an error.
- On Bun 1.3 a file whose ZIP holds a stored entry, every
.odtfor one, failed to open: there the stream of a part of a Blob runs on to the end of the file, and the checksum of the entry covered the rest. A stream is cut at the length asked for, whatever the runtime sends (#49). - Firefox: cells of a table dragged over are a selection, select all in a text box replaces its text when typing. The browser tests run in Firefox with
E2E_BROWSER=firefox(342 of 375 pass). Browsers says what is needed (Chrome / Edge 103, Safari 16.4, Firefox 113) and what is known to differ. - Keynote 2018 packages open; Graphviz record labels; PlantUML actor aliases, and an error that says so for the PlantUML kinds that are not drawn.
Your own UI
- Texts: every text of the bars, menus, dialogs and status lines comes from one typed table,
Strings.stringsreplaces any of them, key by key;locale(a BCP 47 tag) formats numbers and dates. English is in the bundle; German is an import of its own:import { de } from '@p10node/office-engine/locales/de'. See UI texts. - Components:
componentsputs theButton,Select,Separator,DialogandToastof your design system into the toolbars and dialogs; one left out keeps the built-in one. See Your own components. - Headless mode:
headlessleaves the document alone, and a controller (createViewerController(),useViewerState()) carries its state (editing, dirty, undo / redo, zoom, page, outline, status, the formatting at the selection) and its commands (setEditing,save,undo,zoomIn,goto,print,fileAction,format…) to controls of your own.format(command)is one formatting API for documents, cells and slide text; the selection is kept while a control of the host has the focus. See Headless mode. - Ready-made controls for a layout of your own around a headless viewer:
ZoomBar,StatusText,OutlineList,SheetTabs,FormatBar, each driven by the controller alone.
Contributed
#6 (translatable UI texts), #7 (replaceable components), #8 (headless mode and the controller), #9 (formatting through the controller), #10 (ready-made controls), #12 and #51 (charts: workbooks, 3D, Word and slides), #31 (large Markdown files, the end of very long documents) and #34 (column fit after the document is closed), with follow-ups here: the limits of charts, and the fixes of the review. Thank you.
Compatibility: themes and icons
These came with v0.14.0 and v0.15.0 and were not in their notes.
ThememeansThemeMode | ThemeOptions. A host that needs only the mode ('light' | 'dark' | 'auto') for its own state, parameters and records should useThemeMode.FileMenuItem.icontakes anIconName, not any string. Annotate a variable holding an icon name asIconName, so that it is not widened tostring.ICON_NAMESlists the supported icon names as stable public keys. Keys may be added; the existing ones are not renamed.- CSS declarations using
color-mix()have fallbacks from the tokens for the visible selection, hover and connection states. That is not full support of older browsers.
import type { FileMenuItem, IconName, ThemeMode } from '@p10node/office-engine'
const mode: ThemeMode = 'auto'
const icon: IconName = 'save'
const item: FileMenuItem = { label: 'Save a copy', icon, onClick: saveCopy }For integrators
- New props of
DocViewer:locale,strings,components,fonts,language,controller,headless.<office-viewer>has the attributesheadless,language,localeandfonts(a JSON list of fonts by URL) and the propertiesstrings,fonts(bytes too) andcontroller;mount()takes the same options and returns itscontroller. - New exports:
createViewerController,useViewerState,ZoomBar,StatusText,OutlineList,SheetTabs,FormatBar,OfficeUIProvider,UIComponentsProvider,StringsProvider,useStrings,resolveStrings,en,Icon, and the typesViewerController,ViewerState,ViewerOutline,OutlineItem,TextFormat,FormatCommand,UIComponents,ButtonProps,SelectProps,DialogProps,DialogAction,ToastProps,DropOption,Strings,StringsOverride,Locale,FontSource. From/core:highlight,highlightLines,languageOf. A new entry:@p10node/office-engine/locales/de. - Views mounted without
DocViewerget icons, components, texts and locale fromOfficeUIProvider. A container of host controls takesuseThemeRoot(theme, style, { host: true }). New theme tokens:srcFunction,srcType, andcodeComment…codeTypefor code on the page. - Use one controller per mounted viewer. Its commands obey
allowSave,allowDownloadandallowOpenalso when the File menu is hidden;fileMenu={false}turns off the Open and Print shortcuts too. - Worker: the open parameter
language;info.importedmay be'code', withinfo.language;plain.originalgives the bytes of a source file as opened.xlsx.settakes{ locale }, and the result of a spreadsheet edit carrieshistory(the undo / redo steps there are).pptx.history, andstepofpptx.setText.OpenOptions.signalgives up a load and ends its worker;DocumentClient.closed. - Models: a chart on a slide is an element
{ t: 'chart', box, model }, and the chart of a Word document is carried by its inline. A paragraph may havetabs,keepLines,widowControlandcode(the language of a code block); a formula is arefinline withmath({ tex, delim }). - What changes without a prop: documents have other page counts (pages cut between lines, widow / orphan control). In Markdown
$…$is math ($HOME/$USERtoo, as in pandoc). A paragraph style named "Source Code" (pandoc's) is a code block. A file with the extension or MIME type of a source file opens in the code view and is saved as itself. An emptied margin in Page setup is refused instead of becoming 0 cm. - Collaboration: a cell edit carries the
localeits numbers were typed in, a sort the order it made. Every client of a room needs this version, and so does a server that replays the log withcompact: an older one reads a number typed in a locale with a decimal point, and does not know the order a sort carries. @p10node/markdown:math(on by default) draws TeX as MathML,highlight(off by default) colors code blocks as<span class="hl-…">. 66 KB gzipped, was 39 KB.- Size: the worker is 1.67 MB (521 KB gzipped), 135 KB more; the viewer chunk 664 KB (195 KB gzipped), 142 KB more; German is 24 KB (8 KB gzipped), loaded only where it is imported.
- The embed entry can be imported without a DOM.
- Not done: paragraphs split inside table cells; tab stops set in the editor; embedded fonts; equations of Word files drawn (they are still their linear text) and a visual equation editor; the chartex chart kinds. No new dependency.
What's Changed
- fix(xlsx): fitting a column after an edit stops once the document is closed by @mkroemer in #34
- fix(xlsx): every copy of a dynamic array formula pasted or filled as a block spills by @pierreneter in #36
- fix(docx): conversion answers applied to the right paragraphs, during IME, and in new tables by @pierreneter in #38
- fix: numbers typed are read in the viewer's locale, whole or not at all by @pierreneter in #37
- feat: the host supplies font files, and documents are laid out once they are loaded by @pierreneter in #39
- feat: syntax highlighting for Markdown code blocks and source files by @pierreneter in #41
- feat(markdown):
$…$ and$$…$$ TeX math drawn as equations, kept as written when saved by @pierreneter in #40 - feat(docx): tables and paragraphs split across pages, header rows repeated, keep rules by @pierreneter in #42
- feat(viewer): translatable UI texts: strings table, locale and strings props by @mkroemer in #6
- feat(viewer): replaceable UI components for toolbars and dialogs by @mkroemer in #7
- feat(viewer): headless mode and a controller for host-drawn controls by @mkroemer in #8
- feat(viewer): formatting state and commands through the controller by @mkroemer in #9
- feat(viewer): ready-made controls for a headless viewer by @mkroemer in #10
- fix(markdown): avoid import stack overflow and keep final pages reachable by @mkroemer in #31
- feat(xlsx): charts drawn as SVG, their values from the cells, in the file's look by @mkroemer in #12
- feat(charts): 3D charts, Word and PowerPoint charts, closer to Excel (follow-up to #12) by @mkroemer in #51
- fix(core): part of a Blob read as a stream ends where it was asked to, on any runtime by @pierreneter in #52
- fix(docx): past the scroll cap, the pages move once and as far as the scroll by @pierreneter in #53
New Contributors
- @pierreneter made their first contribution in #36
Full Changelog: v0.17.0...v0.18.0