@atlaskit/editor-plugin-show-diff
Version:
ShowDiff plugin for @atlaskit/editor-core
95 lines (77 loc) • 4.53 kB
JavaScript
/**
* `'standard'` (purple insertions, default) and `'traditional'` (green/red) are the two
* plugin-configured schemes. The remaining accent names are the attribution palette used for
* per-contributor colouring (`stepsWithAttribution`) — callers of the imperative `showDiff`
* command (see `PMDiffParams.colorScheme`) can also pass one of these directly to match a
* specific contributor's colour outside of attribution mode, for example matching a Review
* moment diff to the streaming highlight of the agent that produced it.
*/
/**
* Attribution for a ProseMirror step.
*
* `userId` is the primary actor identity. `agentId` distinguishes multiple agents (or an agent
* from its user) when they share that user ID, with `agentType` used as a fallback when `agentId`
* is empty. `wasOffline` preserves additional provenance without affecting identity.
*/
/** Keeps a step and its attribution coupled through mapping and filtering. */
/** Branded agent presentations supported by contributor tags. */
export var DIFF_AGENT_BRANDS = new Set(['rovo', 'claude', 'chatgpt', 'figma', 'lovable', 'replit']);
/** The brand id `@atlaskit/agent-color` registers each `AgentBrandColorScheme` under. */
/**
* Compile-time-only: fails to build if `DiffAgentBrand` names a brand `@atlaskit/agent-color`
* hasn't registered a colour scheme for. Catches "added a brand here but forgot the colour"
* without needing a runtime check. Exported only so the unused check on this module-scope
* assertion doesn't fire; no consumer needs its value.
*/
export var ASSERT_DIFF_AGENT_BRANDS_ARE_REGISTERED = true;
/** A complete identity for one of the accounts named by a step attribution. */
/** Agent presentation: branded (dedicated icon and reserved participant colour), identified by profile, or a generic external agent. */
/**
* A contributor the plugin has resolved from a step attribution and a supplied profile. Internal:
* never re-exported from an entry point and not reachable from any public type. Same for
* `DiffContributors`.
*/
/** Where two contributors share an identity, the last wins. */
/** A contributor stripped of its attributions, as a tag presents it. Internal. */
/**
* Everything a contributor tag renders, resolved by the plugin so the tag UI does no lookups.
* Declared here rather than beside `extractContributorTags` so the shared state below can name it
* without importing back out of this file. Internal, like `TagContributor`.
*/
/**
* Where node/paragraph-level deleted content is rendered relative to the new (replacement)
* content in the `smart` diffType:
* - `'top'` (default): the deleted content is anchored above the new content.
* - `'bottom'`: the deleted content is anchored below the new content.
*/
/**
* Where inline-level (and sentence-level) deleted content is rendered relative to the new
* (replacement) content in the `smart` diffType. This is independent of the node/paragraph-level
* `deletedDiffPlacement` option:
* - `'before'` (default): the deleted content is anchored before the new content.
* - `'after'`: the deleted content is anchored after the new content.
*/
/**
* A rendered deleted-content widget: the DOM element show-diff renders for a piece of deleted
* content, together with the document position it is anchored at. Deleted content is rendered as
* widget decorations rather than document nodes, so this is how consumers recover the element and
* its position — via the `getDeletedWidgets` action — without reaching into the plugin's internal
* state.
*/
// Re-export the canonical `SmartDiffThresholds` declaration (single source of truth) so the
// public plugin types stay in sync with the smart-diff implementation.
/**
* How the diff is revealed when it is painted.
*
* - `phased` — the two-phase choreography used when opening the diff from a clean "new state":
* the outgoing state cross-fades to the incoming one while the agent highlight wipes out to the
* right, then every highlight wipes back in from the left.
*
* Deliberately separate from {@link DiffType}: that describes how changes are computed and grouped,
* this describes how the result is presented over time. Folding one into the other would make every
* `DiffType` consumer — version history, track-changes, publish diff — care about presentation.
*/
/**
* Attributed alternative to `PMDiffParams`. When agent colouring is enabled, changes are grouped
* by `userId`, with `agentId` used as a tie-breaker.
*/