UNPKG

@atlaskit/editor-plugin-show-diff

Version:

ShowDiff plugin for @atlaskit/editor-core

83 lines (66 loc) • 4.03 kB
/** * `'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. `agentNamedId` carries a stable external * configuration reference for presentation overrides. `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 const DIFF_AGENT_BRANDS = new Set(['rovo', 'claude', 'chatgpt', 'figma', 'lovable', 'replit', 'amplitude', 'cortex', 'databricks', 'gemini', 'manus', 'slack', 'antigravity', 'copilot']); /** 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 const 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. /** * Attributed alternative to `PMDiffParams`. When agent colouring is enabled, changes are grouped * by `userId`, with `agentId` used as a tie-breaker. */