Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .changeset/apply-markdown-edit.md

This file was deleted.

33 changes: 0 additions & 33 deletions .changeset/gate-default-renderers-on-schema.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/guard-unparsable-image-src.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/inline-carrier-in-table-cells.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/remove-placeholder-on-remote-insert-after-unset.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/root-unset-rematerialization.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/skip-empty-block-output.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/unique-minted-keys.md

This file was deleted.

14 changes: 14 additions & 0 deletions packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 8.1.4

### Patch Changes

- [#3257](https://github.com/portabletext/editor/pull/3257) [`df4b4ac`](https://github.com/portabletext/editor/commit/df4b4aca74bda080f21a7b0272d1cb024d24a495) Thanks [@christianhg](https://github.com/christianhg)! - fix: remove the local placeholder on a remote root `insert` after a self-emitted `unset`

After clearing the field under a value-mirroring host, a collaborator's block arriving through `patches` no longer leaves an extra empty block in the editor; the editor shows only the collaborator's content. One additional change: an empty block that a host genuinely persisted in the window after the editor's own `unset` is now removed from the editor when a remote root `insert` arrives, until the next value sync restores it; distinguishing it from the editor's own placeholder takes provenance metadata, which is follow-up work.

- [#3253](https://github.com/portabletext/editor/pull/3253) [`a4bea35`](https://github.com/portabletext/editor/commit/a4bea35a8f0c668b83502c0fd0da0cf9f8e2693e) Thanks [@christianhg](https://github.com/christianhg)! - fix: re-materialize the field before patches emitted while it is unset

A behavior replacing the whole value in one action set (a root `unset` followed by an `insert`) previously emitted a patch stream that patch-applying stores could not apply: an `insert` into a field the preceding `unset` had removed. Consumers saw `Cannot apply deep operations on primitive values`.

One narrow behavioral fix rides along: clearing the editor through a behavior-raised root `unset` now re-materializes the field on the next edit under a value-mirroring host, the same way clearing it with the keyboard already did.

## 8.1.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@portabletext/editor",
"version": "8.1.3",
"version": "8.1.4",
"description": "Portable Text Editor made in React",
"keywords": [
"collaborative",
Expand Down
79 changes: 79 additions & 0 deletions packages/markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,84 @@
# @portabletext/markdown

## 2.2.0

### Minor Changes

- [#3242](https://github.com/portabletext/editor/pull/3242) [`e4abe23`](https://github.com/portabletext/editor/commit/e4abe233743736ec15e3bbf3fcb118182beaf49d) Thanks [@christianhg](https://github.com/christianhg)! - feat: add `applyMarkdownEdit` for key-preserving markdown edits

Edit Portable Text as markdown without losing identity: serialize a stored value, let anything edit the markdown, and convert it back with the stored `_key`s restored to everything the edit did not replace.

```ts
import {
applyMarkdownEdit,
portableTextToMarkdown,
} from '@portabletext/markdown'

const markdown = portableTextToMarkdown(storedPortableText, {schema})
// ... the markdown gets edited ...
const edited = applyMarkdownEdit(storedPortableText, editedMarkdown, {
schema, // governs both conversion directions
serialize: {}, // must match the options that produced the markdown
})
```

Keys follow the edit the way they would in an editor: unchanged and moved blocks keep their keys, rewriting a block in place keeps its key like typing over it, a split keeps the key on the first fragment, a merge on the first block, and a typo fix lands as a text change on the same span, annotation keys included. What markdown cannot express comes back on adopted content: custom fields and styles, decorators without syntax, empty paragraphs. When evidence runs out, a block gets a fresh key rather than a wrong one, and a `json:object` payload's own key never re-keys stored content.

The options bag is the exported `ApplyMarkdownEditOptions`: one top-level `schema` governs both conversion directions, and `deserialize`/`serialize` take the two converters' remaining options, with new keys coming from `deserialize.keyGenerator`. The README's `applyMarkdownEdit` section carries the full contract: what keeps its key, what gets restored, when keys reset, and the concurrent-edit rule.

- [#3255](https://github.com/portabletext/editor/pull/3255) [`02e2d49`](https://github.com/portabletext/editor/commit/02e2d4918e7c0a55e974f90e414a3b53aaf3b199) Thanks [@christianhg](https://github.com/christianhg)! - feat: gate the default markdown renderers on the schema in `portableTextToMarkdown`

`portableTextToMarkdown` now accepts an optional `schema`. When set, each built-in type renderer (`callout`, `code`, `horizontal-rule`, `html`, `image`, `table`) runs only when the schema declares that type at the matching position (`blockObjects` for a block, `inlineObjects` for an inline object); an undeclared type falls back to `unknownType`, whose default output is a `json:object` fence (or tagged code span, inline) that reparses back to the same value under the same schema. Renderers you pass in `types` are never gated. The gate checks the type name only, so declare each type with its fields: `markdownToPortableText` cannot rebuild a value from a fieldless declaration. Omit `schema` and every default renderer stays active, as before.

```ts
import {compileSchema, defineSchema} from '@portabletext/schema'
import {portableTextToMarkdown} from '@portabletext/markdown'

const schema = compileSchema(
defineSchema({
blockObjects: [
{
name: 'code',
fields: [
{name: 'code', type: 'string'},
{name: 'language', type: 'string'},
],
},
],
}),
)

portableTextToMarkdown(blocks, {schema})
// a `code` block renders as a fenced code block; a `table` block
// (undeclared) renders as a `json:object` fence instead
```

Pass the same schema to `markdownToPortableText` to keep the round trip consistent.

### Patch Changes

- [#3265](https://github.com/portabletext/editor/pull/3265) [`3b2d278`](https://github.com/portabletext/editor/commit/3b2d27847eb5139b2d50dc9f3d962167342c2b91) Thanks [@christianhg](https://github.com/christianhg)! - fix: serialize images the parser would refuse as `json:object` fences

An `image` whose `src` a Markdown parser would refuse (a `data:` URI outside `png`/`gif`/`jpeg`/`webp`, or a `javascript:`/`vbscript:`/`file:` URI) previously serialized as `![alt](src)` anyway; reparsing that markdown turned the image into literal text instead of an image object, destroying it. Such an image now serializes as a `json:object` fence (or, inline, a tagged code span), which reparses back to the identical image value. Images with an accepted `src` are unaffected.

- [#3255](https://github.com/portabletext/editor/pull/3255) [`d39146e`](https://github.com/portabletext/editor/commit/d39146ee48a23bad4a6c312863e76ff389a1bc2c) Thanks [@christianhg](https://github.com/christianhg)! - fix: use the inline `json:object` carrier for objects inside table cells

In `portableTextToMarkdown`, an object inside a table cell that renders through the `json:object` carrier now uses the carrier's single-line inline form instead of a block fence squashed with `<br>`.

In `markdownToPortableText`, a carrier object standing alone in a table cell is placed by the schema: it comes back at block position in the cell (`cell.value`), unless the schema declares the type inline-only, in which case it stays an inline child of the cell's text block. The same placement rule now governs standalone images, so under a schema without a block-level `image`, an image alone in a cell stays inline (reported as `image-block-to-inline`) instead of being lifted to block position.

Together the two sides make objects in table cells survive the serialize-edit-reparse round trip.

- [#3264](https://github.com/portabletext/editor/pull/3264) [`deccf84`](https://github.com/portabletext/editor/commit/deccf846fb41efbcae9b6dccafbfd6cd101930a1) Thanks [@christianhg](https://github.com/christianhg)! - fix: emit no blank lines for empty text blocks

A block that renders to the empty string (an empty or whitespace-only text block, or a custom renderer returning `''`) no longer leaves blank lines in `portableTextToMarkdown`'s output: `[h1 'foo', empty block, 'bar']` now serializes to `# foo\n\nbar` instead of `# foo\n\n\n\nbar`. A dropped block never survived reparsing anyway, and a custom `blockSpacing` callback now sees the pair of blocks that actually end up adjacent, never an invisible one. Two spacing consequences show in rendered HTML: two blockquotes separated only by an empty block now join into one quote with a paragraph break, and a list whose blank lines came only from empty blocks goes tight, since a skipped block no longer counts toward looseness.

The same filter runs inside containers: callout and structured-blockquote content joins skip empty blocks, so no more blank quote-prefixed lines. In list items, the marker line goes to the first block that renders output, with two exceptions that keep the markdown reparseable: a multi-line block (a code fence, a table) keeps its later lines indented inside the item instead of escaping the list at column 0, and a nested list or, on a task item, any non-text block stays indented below a bare marker, because after `- [x] ` (or fused with `- `) it would reparse as plain words.

- [#3242](https://github.com/portabletext/editor/pull/3242) [`e4abe23`](https://github.com/portabletext/editor/commit/e4abe233743736ec15e3bbf3fcb118182beaf49d) Thanks [@christianhg](https://github.com/christianhg)! - fix: mint sibling-unique keys even from a colliding `keyGenerator`

`markdownToPortableText` (and everything built on it) now guards the supplied `keyGenerator`: a generator that returns an already-minted key is retried, then deterministically suffixed, so one conversion can never mint the same `_key` twice. A repeated key did not just duplicate identity, it made annotation ownership ambiguous: two mark definitions sharing a key leave every referencing span attributable to either, which no later repair can resolve. Well-behaved generators are unaffected.

## 2.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@portabletext/markdown",
"version": "2.1.0",
"version": "2.2.0",
"description": "Convert Portable Text to and from Markdown",
"keywords": [
"markdown",
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-character-pair-decorator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 9.0.9

### Patch Changes

- Updated dependencies []:
- @portabletext/plugin-input-rule@7.0.9

## 9.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-character-pair-decorator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@portabletext/plugin-character-pair-decorator",
"version": "9.0.8",
"version": "9.0.9",
"description": "Automatically match a pair of characters and decorate the text in between",
"keywords": [
"behaviors",
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-dnd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @portabletext/plugin-dnd

## 2.0.10

### Patch Changes

- fix(deps): require `@portabletext/editor@^8.1.4`

## 2.0.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dnd/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@portabletext/plugin-dnd",
"version": "2.0.9",
"version": "2.0.10",
"description": "Track the drop position during drag and drop for custom drop indicators",
"keywords": [
"dnd",
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-emoji-picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @portabletext/plugin-emoji-picker

## 8.0.9

### Patch Changes

- Updated dependencies []:
- @portabletext/plugin-input-rule@7.0.9

## 8.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-emoji-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@portabletext/plugin-emoji-picker",
"version": "8.0.8",
"version": "8.0.9",
"description": "Easily configure an Emoji Picker for the Portable Text Editor",
"keywords": [
"emoji-picker",
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-input-rule/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @portabletext/plugin-input-rule

## 7.0.9

### Patch Changes

- fix(deps): require `@portabletext/editor@^8.1.4`

## 7.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-input-rule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@portabletext/plugin-input-rule",
"version": "7.0.8",
"version": "7.0.9",
"description": "Easily configure Input Rules in the Portable Text Editor",
"keywords": [
"input-rule",
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-list-index/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @portabletext/plugin-list-index

## 2.0.8

### Patch Changes

- fix(deps): require `@portabletext/editor@^8.1.4`

## 2.0.7

### Patch Changes
Expand Down
Loading
Loading