Skip to content

feat(plugins): let editor plugins insert site fragments - #641

Draft
DavidBabinec wants to merge 2 commits into
feat/site-fragmentsfrom
feat/plugin-fragments-api
Draft

DavidBabinec wants to merge 2 commits into
feat/site-fragmentsfrom
feat/plugin-fragments-api

Conversation

@DavidBabinec

@DavidBabinec DavidBabinec commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Editor plugins with the new editor.fragments permission get api.editor.fragments.insert and api.editor.fragments.plan. Insert runs the same plan, step-up and one-undo commit as Spotlight "Insert fragment from file…", with the plugin supplying media bytes and a placement (after-selection, inside-selection or end). Plan is a dry run that returns the report and changes nothing. Both take colorSources, which fills a colour the fragment adds from one of the site's own instead of the source site's value.

Why

A plugin that ships sections or pages had no way to insert them except mutating the store by hand, which skips the merge rules, media upload and table writes. The store action now takes an explicit placement; the dialog keeps its current behaviour.

Verification

New pluginFragmentsApi.test.ts covers the permission, placements, media reads, undo, plan and malformed input; insertFragment.test.ts covers the placements in the store. In a browser, a plugin installed through the Plugins page inserted two sections from its own panel, with the step-up prompt for a table write, and the published page matched the editor.

BUILD_EXIT=0
LINT_EXIT=0
TEST_EXIT=0
 7233 pass
 0 fail

Stacked on #640.

Plugins that ship sections or pages could only drop them in by mutating the editor store by hand, which skips the merge rules, media uploads, table writes and the single undo step. api.editor.fragments (permission editor.fragments) runs the Insert fragment dialog's own plan and commit with the plugin's media reader and an explicit placement; the store action takes that placement while the dialog keeps placing after the selection.
@DavidBabinec
DavidBabinec force-pushed the feat/plugin-fragments-api branch from 0ce3ec4 to 0987d9e Compare October 13, 2026 17:16
A section that brings a colour the site lacks used to add it with the source site's value, so a pale band could land under a dark site's light text. Callers can now name a site colour to take the values from (colorSources on planFragmentInsert and on the plugin API's plan and insert); the report lists what was filled.

This branch has not been deployed

No deployments
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.

1 participant