Skip to content

Formatted text prototype#26228

Merged
CraigMacomber merged 10 commits intomicrosoft:mainfrom
CraigMacomber:formattedText
Jan 20, 2026
Merged

Formatted text prototype#26228
CraigMacomber merged 10 commits intomicrosoft:mainfrom
CraigMacomber:formattedText

Conversation

@CraigMacomber
Copy link
Copy Markdown
Contributor

Description

Minimal prototype for formatted text with inline objects.
This is targeting matching what Quill needs for formatting, see #26217

Reviewer Guidance

The review process is outlined on this wiki page.

@CraigMacomber CraigMacomber changed the title Formatted text Formatted text prototype Jan 15, 2026
@CraigMacomber CraigMacomber marked this pull request as ready for review January 15, 2026 22:56
@CraigMacomber CraigMacomber requested a review from a team as a code owner January 15, 2026 22:56
Copilot AI review requested due to automatic review settings January 15, 2026 22:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a formatted text prototype that extends the existing basic text functionality with support for character-level formatting and inline objects. It is designed to match Quill's formatting requirements.

Changes:

  • Added new FormattedTextAsTree namespace with support for character formatting (bold, italic, underline, font, size) and line formatting (HTML tags like h1-h5, li)
  • Exported charactersFromString function from textDomain.ts for reuse in formatted text implementation
  • Added comprehensive test coverage including schema compatibility tests and functional tests for formatting operations

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/dds/tree/src/text/textDomainFormatted.ts New file implementing formatted text with character/line formatting and inline objects support
packages/dds/tree/src/text/textDomain.ts Exported charactersFromString function for reuse
packages/dds/tree/src/text/index.ts Exported FormattedTextAsTree namespace
packages/dds/tree/src/index.ts Re-exported FormattedTextAsTree from public API
packages/dds/tree/src/test/text/textDomainFormatted.spec.ts Added comprehensive tests for formatted text functionality
packages/dds/tree/src/test/text/textDomain.spec.ts Added schema compatibility test for basic text
packages/dds/tree/src/test/domain-schema-compatibility-snapshots/text/2.81.0.json Schema snapshot for basic text compatibility
packages/dds/tree/src/test/domain-schema-compatibility-snapshots/formattedText/2.81.0.json Schema snapshot for formatted text compatibility

});
}

public charactersFormatted(): Iterable<FormattedTextAsTree.StringAtom> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "formattedCharacters"? Both because it's more like natural English, and because this phrasing could be confused for a shorthand of "are characters formatted".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have multiple related members on an interface which are different versions of the same thing (in this the inherited characters and charactersFormatted) I like for them to start with the same string and have the disambiguater at the end as it helps discoverability a lot (for example if someone is using characters it makes it clear there is an alternative which has formatting information).

SharedObjectCore's reSubmitCore vs reSubmitSquashed are examples of this as is our exportConcise and exportVerbose APIs.

If we want to better align with English, maybe we could do charactersWithFormatting?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like charactersWithFormatting

Comment on lines +165 to +166
* Using larger atoms and splitting them as needed is NOT a recommended approach, since this will result in poor merge behavior for concurrent edits.
* Instead atoms should always be the smallest unit of text which will be independently selected, moved or formatted.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great callout! Thanks!

Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
@CraigMacomber CraigMacomber merged commit ff594f8 into microsoft:main Jan 20, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants