mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 08:39:02 +03:00
feat(app): refine artifact previews and file actions (#59657)
This commit is contained in:
committed by
GitHub
Unverified
parent
5f1f8d094c
commit
b3de41a572
@@ -6,6 +6,7 @@ import { browseFiles, openFileLauncher, openReviewLauncher, reviewTabs } from ".
|
||||
import { mockOpenCodeServer } from "../utils/mock-server"
|
||||
import { fileDiff, fileNode, openSession } from "../utils/workspace"
|
||||
import { expectSessionTitle } from "../utils/waits"
|
||||
import { readFile } from "node:fs/promises"
|
||||
|
||||
test.use({ viewport: { width: 1440, height: 900 } })
|
||||
|
||||
@@ -679,6 +680,276 @@ test("rereads a file each time an artifact link opens it", async ({ page }) => {
|
||||
await expect(missingTab).toHaveCount(0)
|
||||
})
|
||||
|
||||
test("artifact actions copy and download content, switch source, and follow the selected file's capabilities", async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"])
|
||||
const source = '<svg xmlns="http://www.w3.org/2000/svg" width="120" height="80"><rect width="120" height="80"/></svg>'
|
||||
const table = 'name,role\n"Jensen, Oliver",Researcher\nIsabella,Support'
|
||||
|
||||
const workspace = await openSession(page, {
|
||||
name: "ArtifactActions",
|
||||
fileList: () => [],
|
||||
fileContent: (path) => {
|
||||
if (path === "vector.svg") return { content: source }
|
||||
|
||||
if (path === "data.csv") return { content: table }
|
||||
|
||||
if (path === "notes.md") return { content: "# Notes\n\nA document with a visible top edge." }
|
||||
|
||||
return { type: "binary", content: "AAEC", encoding: "base64" }
|
||||
},
|
||||
pageMessages: () => ({
|
||||
items: [
|
||||
{
|
||||
id: "msg_artifact_actions",
|
||||
type: "assistant",
|
||||
agent: "build",
|
||||
model: { id: "test", providerID: "opencode" },
|
||||
content: [
|
||||
{ type: "text", text: "[Vector](vector.svg) [Table](data.csv) [Notes](notes.md) [Binary](sample.bin)" },
|
||||
],
|
||||
time: { created: 1, completed: 2 },
|
||||
},
|
||||
],
|
||||
}),
|
||||
})
|
||||
|
||||
await page.getByRole("link", { name: "Vector", exact: true }).click()
|
||||
const panel = page.locator("#review-panel")
|
||||
const toolbar = panel.locator('[data-slot="artifact-toolbar"]:visible')
|
||||
const actions = toolbar.getByRole("button", { name: "File actions", exact: true })
|
||||
const image = panel.getByRole("img", { name: "vector.svg", exact: true })
|
||||
await expect(image).toHaveJSProperty("naturalWidth", 120)
|
||||
await expect(toolbar.getByText("vector.svg", { exact: true })).toBeVisible()
|
||||
await panel.getByRole("button", { name: "Toggle file tree", exact: true }).click()
|
||||
|
||||
// The source action stays visible at rest; only metadata needs hover or keyboard focus.
|
||||
await page.mouse.move(0, 0)
|
||||
const sourceAction = toolbar.getByRole("button", { name: "View source", exact: true })
|
||||
await expect(sourceAction).toHaveCSS("opacity", "1")
|
||||
await expect(toolbar.locator('[data-slot="artifact-metadata"]')).toHaveCSS("opacity", "0")
|
||||
await actions.focus()
|
||||
await expect(toolbar.locator('[data-slot="artifact-metadata"]')).toHaveCSS("opacity", "1")
|
||||
await expect(toolbar.getByText("120 × 80", { exact: true })).toBeVisible()
|
||||
const copy = toolbar.getByRole("button", { name: "Copy content", exact: true })
|
||||
await copy.click()
|
||||
await expect(page.getByText("Copied", { exact: true })).toBeVisible()
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(source)
|
||||
await page.getByRole("button", { name: "Dismiss", exact: true }).click()
|
||||
|
||||
await sourceAction.click()
|
||||
await expect(image).toHaveCount(0)
|
||||
await expect(panel.locator("diffs-container")).toContainText(source)
|
||||
await actions.click()
|
||||
await expect(page.getByRole("menuitem", { name: "View preview", exact: true })).toBeVisible()
|
||||
await expect(page.getByRole("menuitem", { name: "Open in", exact: true })).toHaveCount(0)
|
||||
await page.getByRole("menuitem", { name: "View preview", exact: true }).click()
|
||||
await expect(image).toHaveJSProperty("naturalWidth", 120)
|
||||
|
||||
await page.getByRole("link", { name: "Table", exact: true }).click()
|
||||
await expect(panel.getByRole("columnheader", { name: /^name(?:\s|$)/ })).toHaveCSS(
|
||||
"background-color",
|
||||
"rgb(242, 242, 242)",
|
||||
)
|
||||
const nameCell = panel.getByRole("cell", { name: /^Jensen, Oliver(?:\s|$)/ })
|
||||
await expect(nameCell).toBeVisible()
|
||||
await expect(toolbar.getByText("data.csv", { exact: true })).toBeVisible()
|
||||
await nameCell.hover()
|
||||
await nameCell.getByRole("button", { name: "Copy cell", exact: true }).click()
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe("Jensen, Oliver")
|
||||
await toolbar.hover()
|
||||
await expect(nameCell.getByRole("button", { name: "Copy cell", exact: true })).toHaveCSS("opacity", "0")
|
||||
await page.keyboard.press("Tab")
|
||||
|
||||
const nextCopy = panel
|
||||
.getByRole("cell", { name: /^Researcher(?:\s|$)/ })
|
||||
.getByRole("button", { name: "Copy cell", exact: true })
|
||||
|
||||
await expect(nextCopy).toBeFocused()
|
||||
await expect(nextCopy).toHaveCSS("opacity", "1")
|
||||
|
||||
const copyHeader = panel
|
||||
.getByRole("columnheader", { name: /^role(?:\s|$)/ })
|
||||
.getByRole("button", { name: "Copy cell", exact: true })
|
||||
|
||||
await copyHeader.focus()
|
||||
await copyHeader.press("Enter")
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe("role")
|
||||
await actions.click()
|
||||
const downloaded = page.waitForEvent("download")
|
||||
await page.getByRole("menuitem", { name: "Download", exact: true }).click()
|
||||
const download = await downloaded
|
||||
expect(download.suggestedFilename()).toBe("data.csv")
|
||||
expect(await readFile((await download.path())!, "utf8")).toBe(table)
|
||||
|
||||
await page.getByRole("link", { name: "Notes", exact: true }).click()
|
||||
await expect(panel.getByRole("heading", { name: "Notes", exact: true })).toBeVisible()
|
||||
const paper = panel.locator('[data-slot="artifact-markdown-page"]')
|
||||
await expect(paper).toHaveCSS("border-radius", "8px")
|
||||
await expect(paper).toHaveAttribute("data-component", "document-surface")
|
||||
expect(await paper.evaluate((element) => getComputedStyle(element, "::after").borderTopStyle)).toBe("solid")
|
||||
const surface = (await paper.boundingBox())!
|
||||
const bar = (await toolbar.boundingBox())!
|
||||
expect(surface.y - bar.y - bar.height).toBe(1)
|
||||
await expect(panel.getByRole("group", { name: "Preview controls", exact: true })).toHaveCount(0)
|
||||
|
||||
await page.getByRole("link", { name: "Binary", exact: true }).click()
|
||||
await expect(panel.getByText(/Binary file/)).toBeVisible()
|
||||
await expect(toolbar.getByText("sample.bin", { exact: true })).toBeVisible()
|
||||
await expect(copy).toHaveCount(0)
|
||||
await expect(toolbar.getByRole("button", { name: "View source", exact: true })).toHaveCount(0)
|
||||
await actions.click()
|
||||
await expect(page.getByRole("menuitem", { name: "Download", exact: true })).toHaveCount(0)
|
||||
await page.getByRole("menuitem", { name: "Copy path", exact: true }).click()
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(`${workspace.directory}/sample.bin`)
|
||||
})
|
||||
|
||||
test("Markdown and DOCX sheets stay aligned when switching at wide and narrow preview widths", async ({ page }) => {
|
||||
// Minimal DOCX containing one paragraph, "Document spacing", and a letter-sized page.
|
||||
const docx =
|
||||
"UEsDBBQAAAAIAI51W13mdcR+0gAAAIsBAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbH2QvVLDMAzHX8XnlasVGBh6SToAKzD0BXSOkvjw11luad++Sls6cIVR+n/8ZLebQ/BqT4Vdip1+NI3e9O32mImVKJE7Pdea1wBsZwrIJmWKooypBKwylgky2i+cCJ6a5hlsipViXdWlQ/ftK42481W9HWR9oRTyrNXLxbiwOo05e2exig77OPyirK4EI8mzh2eX+UEMGu4SFuVvwDX3Ic8ubiD1iaW+YxAXfKcywJDsLkjS/F9z5840js7SLb+05ZIsMbs4BW9uSkAXf+6H83f3J1BLAwQUAAAACACOdVtdXzOVUpUAAAAHAQAACwAAAF9yZWxzLy5yZWxzjc87DsIwDAbgq0Q+QJ0yMKCmXVi6Ii4QJW5T0TzkhNftycBAEQOjf//6LHfDw6/iRpyXGBS0jYSh70606lKD7JaURW2ErMCVkg6I2TjyOjcxUaibKbLXpY48Y9LmomfCnZR75E8DtqYYrQIebQvi/Ez0jx2naTF0jObqKZQfJ74aVdY8U1Fwj2zRvuOmsoB9h5sX+xdQSwMEFAAAAAgAjnVbXUye0X++AAAAMQEAABEAAAB3b3JkL2RvY3VtZW50LnhtbEVQ0Q6CMAz8FbIPsEjUGILw4quJiV8wxwQSti5dFfXr7TCEl9v1ru01q5q3G7OXpTigP6ntJldNXU1li+bprOdMbB/L6aR65lACRNNbp+MGg/XiPZCcZimpgwmpDYTGxjj4zo1Q5PkBnB68Sivv2H7SGxJQAq7PS0wM2shQBUlNSDPOvdEavs4Dobt9syldsy2KXa6E98L3R+Hwb7hoEpUxiL77t9DQ9byWd2RGt9ajfSwuzKFLHiw3w/of9Q9QSwECFAMUAAAACACOdVtd5nXEftIAAACLAQAAEwAAAAAAAAAAAAAAgAEAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQIUAxQAAAAIAI51W11fM5VSlQAAAAcBAAALAAAAAAAAAAAAAACAAQMBAABfcmVscy8ucmVsc1BLAQIUAxQAAAAIAI51W11MntF/vgAAADEBAAARAAAAAAAAAAAAAACAAcEBAAB3b3JkL2RvY3VtZW50LnhtbFBLBQYAAAAAAwADALkAAACuAgAAAAA="
|
||||
|
||||
await page.setViewportSize({ width: 1728, height: 900 })
|
||||
await openSession(page, {
|
||||
name: "DocumentAlignment",
|
||||
fileList: () => [],
|
||||
fileContent: (path) =>
|
||||
path === "notes.md"
|
||||
? { type: "text", content: "# Document spacing\n\nA Markdown sheet beside an Office document." }
|
||||
: {
|
||||
type: "binary",
|
||||
content: docx,
|
||||
encoding: "base64",
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
},
|
||||
pageMessages: () => ({
|
||||
items: [
|
||||
{
|
||||
id: "msg_document_alignment",
|
||||
type: "assistant",
|
||||
agent: "build",
|
||||
model: { id: "test", providerID: "opencode" },
|
||||
content: [{ type: "text", text: "[Markdown](notes.md) [Word](sample.docx) [Second Word](other.docx)" }],
|
||||
time: { created: 1, completed: 2 },
|
||||
},
|
||||
],
|
||||
}),
|
||||
seed: { storage: { "opencode.global.dat:review-panel-v2": { sidebarOpened: false } } },
|
||||
})
|
||||
|
||||
const panel = page.locator("#review-panel")
|
||||
const toolbar = panel.locator('[data-slot="artifact-toolbar"]:visible')
|
||||
const markdown = panel.locator('[data-slot="artifact-markdown-page"]')
|
||||
const word = panel.getByRole("group", { name: "Page 1", exact: true })
|
||||
|
||||
const edges = (sheet: Locator) =>
|
||||
sheet.evaluate((element) => {
|
||||
const rect = element.getBoundingClientRect()
|
||||
const scrollport = element.closest("[data-document-surface-scrollport]")!
|
||||
|
||||
return { left: rect.left, right: rect.right, inset: rect.left - scrollport.getBoundingClientRect().left }
|
||||
})
|
||||
|
||||
await page.getByRole("link", { name: "Markdown", exact: true }).click()
|
||||
await page.getByRole("link", { name: "Word", exact: true }).click()
|
||||
await expect(toolbar.getByText("sample.docx", { exact: true })).toBeVisible()
|
||||
// The real Office engine may need a cold WASM initialization before its text layer is ready.
|
||||
await expect(word.getByText("Document spacing", { exact: true })).toBeVisible({ timeout: 30_000 })
|
||||
await word.evaluate((element) => {
|
||||
element.dataset.e2eProbe = "warm"
|
||||
})
|
||||
const canvas = await word.locator("canvas").elementHandle()
|
||||
expect(canvas).not.toBeNull()
|
||||
await expect.poll(() => canvas!.evaluate((element) => Number(element.getAttribute("width")))).toBeGreaterThan(0)
|
||||
await page.getByRole("link", { name: "Second Word", exact: true }).click()
|
||||
await expect(toolbar.getByText("other.docx", { exact: true })).toBeVisible()
|
||||
await expect(word.getByText("Document spacing", { exact: true })).toBeVisible({ timeout: 30_000 })
|
||||
await word.evaluate((element) => {
|
||||
element.dataset.e2eProbe = "other-warm"
|
||||
})
|
||||
|
||||
for (const size of [
|
||||
{ width: 1728, gutter: 20 },
|
||||
{ width: 1000, gutter: 12 },
|
||||
]) {
|
||||
await page.setViewportSize({ width: size.width, height: 900 })
|
||||
await panel.getByRole("tab", { name: "notes.md", exact: true }).click()
|
||||
await expect(markdown.getByRole("heading", { name: "Document spacing", exact: true })).toBeVisible()
|
||||
await toolbar.hover()
|
||||
await expect.poll(async () => (await edges(markdown)).inset).toBeCloseTo(size.gutter, 1)
|
||||
const reference = await edges(markdown)
|
||||
const header = await toolbar.boundingBox()
|
||||
|
||||
await panel.getByRole("tab", { name: "sample.docx", exact: true }).click()
|
||||
await expect(word).toHaveAttribute("data-e2e-probe", "warm")
|
||||
await expect(word.getByText("Document spacing", { exact: true })).toBeVisible()
|
||||
await expect
|
||||
.poll(() => edges(word))
|
||||
.toEqual({
|
||||
left: expect.closeTo(reference.left, 1),
|
||||
right: expect.closeTo(reference.right, 1),
|
||||
inset: expect.closeTo(size.gutter, 1),
|
||||
})
|
||||
await expect.poll(() => toolbar.boundingBox()).toEqual(header)
|
||||
|
||||
await panel.getByRole("tab", { name: "notes.md", exact: true }).click()
|
||||
await expect(markdown.getByRole("heading", { name: "Document spacing", exact: true })).toBeVisible()
|
||||
await expect.poll(() => edges(markdown)).toEqual(reference)
|
||||
await expect.poll(() => toolbar.boundingBox()).toEqual(header)
|
||||
expect(await canvas!.evaluate((element) => element.isConnected && Number(element.getAttribute("width")) > 0)).toBe(true)
|
||||
await panel.getByRole("tab", { name: "other.docx", exact: true }).click()
|
||||
await expect(word).toHaveAttribute("data-e2e-probe", "other-warm")
|
||||
await panel.getByRole("tab", { name: "notes.md", exact: true }).click()
|
||||
}
|
||||
|
||||
await panel
|
||||
.getByRole("tab", { name: "sample.docx", exact: true })
|
||||
.locator("..")
|
||||
.getByRole("button", { name: "Close tab", exact: true })
|
||||
.click()
|
||||
await expect.poll(() => canvas!.evaluate((element) => element.isConnected)).toBe(false)
|
||||
})
|
||||
|
||||
test("diagram preview controls zoom the rendered diagram and fit it back into its pane", async ({ page }) => {
|
||||
await openSession(page, {
|
||||
name: "DiagramZoom",
|
||||
fileList: () => [],
|
||||
fileContent: () => ({ content: "flowchart LR\n Start[Start] --> Review[Review] --> Finish[Finish]" }),
|
||||
pageMessages: () => ({
|
||||
items: [
|
||||
{
|
||||
id: "msg_diagram_zoom",
|
||||
type: "assistant",
|
||||
agent: "build",
|
||||
model: { id: "test", providerID: "opencode" },
|
||||
content: [{ type: "text", text: "[Diagram](flow.mmd)" }],
|
||||
time: { created: 1, completed: 2 },
|
||||
},
|
||||
],
|
||||
}),
|
||||
})
|
||||
await page.getByRole("link", { name: "Diagram", exact: true }).click()
|
||||
const panel = page.locator("#review-panel")
|
||||
const diagram = panel.locator('[data-component="markdown-mermaid"] > svg')
|
||||
const controls = panel.getByRole("group", { name: "Preview controls", exact: true })
|
||||
const fit = controls.getByRole("button", { name: "Fit", exact: true })
|
||||
await expect(panel.getByText("Finish", { exact: true })).toBeVisible()
|
||||
await diagram.hover()
|
||||
const initial = (await diagram.boundingBox())!
|
||||
|
||||
await expect(fit).toBeEnabled()
|
||||
await controls.getByRole("button", { name: "Zoom in", exact: true }).click()
|
||||
await expect.poll(async () => (await diagram.boundingBox())!.width).toBeCloseTo(initial.width * 1.25, 1)
|
||||
await controls.getByRole("button", { name: "Zoom out", exact: true }).click()
|
||||
await expect.poll(async () => (await diagram.boundingBox())!.width).toBeCloseTo(initial.width, 1)
|
||||
await controls.getByRole("button", { name: "Zoom out", exact: true }).click()
|
||||
await expect.poll(async () => (await diagram.boundingBox())!.width).toBeCloseTo(initial.width / 1.25, 1)
|
||||
await fit.click()
|
||||
await expect.poll(() => diagram.boundingBox()).toEqual(initial)
|
||||
})
|
||||
|
||||
/** What the image case's frame probe records on the window. */
|
||||
type ImageProbe = { problems: string[]; frames: number; running: boolean }
|
||||
|
||||
@@ -698,12 +969,20 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
await openSession(page, {
|
||||
name: "ImageGestures",
|
||||
fileList: () => [],
|
||||
fileContent: (path) => ({
|
||||
content:
|
||||
path === "second.svg"
|
||||
? '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1600"><rect width="1600" height="1600" fill="#6699aa"/></svg>'
|
||||
: '<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1600"><rect width="1600" height="1600" fill="#6699aa"/></svg>',
|
||||
}),
|
||||
fileContent: (path) => {
|
||||
if (path === "small.svg")
|
||||
return {
|
||||
content:
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><rect width="32" height="32" fill="#6699aa"/></svg>',
|
||||
}
|
||||
|
||||
return {
|
||||
content:
|
||||
path === "second.svg"
|
||||
? '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1600"><rect width="1600" height="1600" fill="#6699aa"/></svg>'
|
||||
: '<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="1600"><rect width="1600" height="1600" fill="#6699aa"/></svg>',
|
||||
}
|
||||
},
|
||||
pageMessages: () => ({
|
||||
items: [
|
||||
{
|
||||
@@ -711,7 +990,7 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
type: "assistant",
|
||||
agent: "build",
|
||||
model: { id: "test", providerID: "opencode" },
|
||||
content: [{ type: "text", text: "[First](first.svg) [Second](second.svg)" }],
|
||||
content: [{ type: "text", text: "[First](first.svg) [Second](second.svg) [Small](small.svg)" }],
|
||||
time: { created: 1, completed: 2 },
|
||||
},
|
||||
],
|
||||
@@ -723,11 +1002,15 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
const stage = panel.locator('[data-slot="artifact-stage"]')
|
||||
const fit = panel.getByRole("button", { name: "Fit", exact: true })
|
||||
await expect(image).toBeVisible()
|
||||
await expect(fit).toBeDisabled()
|
||||
await expect(fit).toBeEnabled()
|
||||
// Wait for the side pane's opening motion before choosing a gesture anchor.
|
||||
await image.hover()
|
||||
const initial = (await image.boundingBox())!
|
||||
const pane = (await panel.boundingBox())!
|
||||
await panel.getByRole("button", { name: "Zoom in", exact: true }).click()
|
||||
await expect.poll(async () => (await image.boundingBox())!.width).toBeCloseTo(initial.width * 1.25, 1)
|
||||
await panel.getByRole("button", { name: "Zoom out", exact: true }).click()
|
||||
await expect.poll(() => image.boundingBox()).toEqual(initial)
|
||||
const anchor = { x: Math.round(initial.x + initial.width * 0.55), y: Math.round(initial.y + initial.height * 0.55) }
|
||||
await page.mouse.move(anchor.x, anchor.y)
|
||||
// A continuous pinch catches anchor drift while the image still fits one axis.
|
||||
@@ -739,7 +1022,7 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
gestureSourceType: "mouse",
|
||||
})
|
||||
await cdp.detach()
|
||||
await expect(fit).toBeEnabled()
|
||||
await expect(stage).toHaveAttribute("data-zoom", "actual")
|
||||
const zoomed = (await image.boundingBox())!
|
||||
expect(zoomed.width).toBeCloseTo(initial.width * 2, 1)
|
||||
expect((anchor.x - zoomed.x) / zoomed.width).toBeCloseTo((anchor.x - initial.x) / initial.width, 4)
|
||||
@@ -753,7 +1036,7 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(anchor.x + 60, anchor.y + 40, { steps: 5 })
|
||||
await page.mouse.up()
|
||||
await expect(fit).toBeEnabled()
|
||||
await expect(stage).toHaveAttribute("data-zoom", "actual")
|
||||
expect((await image.boundingBox())!.x).toBeCloseTo(scrolled.x + 60, 1)
|
||||
expect((await image.boundingBox())!.y).toBeCloseTo(scrolled.y + 40, 1)
|
||||
// Touch uses the same captured-pointer path and must not generate a click-to-fit.
|
||||
@@ -765,13 +1048,13 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
})
|
||||
await touch.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] })
|
||||
await touch.detach()
|
||||
await expect(fit).toBeEnabled()
|
||||
await expect(stage).toHaveAttribute("data-zoom", "actual")
|
||||
expect((await image.boundingBox())!.x).toBeCloseTo(scrolled.x + 30, 1)
|
||||
expect((await image.boundingBox())!.y).toBeCloseTo(scrolled.y + 20, 1)
|
||||
// Keyboard-accessible fit restores the exact original geometry.
|
||||
await fit.focus()
|
||||
await page.keyboard.press("Enter")
|
||||
await expect(fit).toBeDisabled()
|
||||
await expect(stage).toHaveAttribute("data-zoom", "fit")
|
||||
expect(await image.boundingBox()).toEqual(initial)
|
||||
expect(
|
||||
await stage.evaluate((element) =>
|
||||
@@ -779,17 +1062,17 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
),
|
||||
).toBe(true)
|
||||
await image.click()
|
||||
await expect(fit).toBeEnabled()
|
||||
await expect(stage).toHaveAttribute("data-zoom", "actual")
|
||||
await page.getByRole("link", { name: "Second", exact: true }).click()
|
||||
await expect(panel.getByRole("img", { name: "second.svg", exact: true })).toBeVisible()
|
||||
await expect(fit).toBeDisabled()
|
||||
await expect(stage).toHaveAttribute("data-zoom", "fit")
|
||||
await panel.getByRole("img", { name: "second.svg", exact: true }).hover()
|
||||
const second = (await panel.getByRole("img", { name: "second.svg", exact: true }).boundingBox())!
|
||||
expect(second.width).toBeGreaterThan(0)
|
||||
expect(second.height).toBeGreaterThan(0)
|
||||
await page.keyboard.down("Control")
|
||||
await page.mouse.wheel(0, -50)
|
||||
await expect(fit).toBeEnabled()
|
||||
await expect(stage).toHaveAttribute("data-zoom", "actual")
|
||||
await page.keyboard.up("Control")
|
||||
await fit.click()
|
||||
await page.setViewportSize({ width: 1200, height: 700 })
|
||||
@@ -801,6 +1084,14 @@ test("image gestures anchor zoom, pan, and reset independently of the pane", asy
|
||||
return media.width <= frame.width - 47 && media.height <= frame.height - 47
|
||||
})
|
||||
.toBe(true)
|
||||
await page.getByRole("link", { name: "Small", exact: true }).click()
|
||||
const small = panel.getByRole("img", { name: "small.svg", exact: true })
|
||||
await expect(small).toHaveJSProperty("naturalWidth", 32)
|
||||
await small.click()
|
||||
await expect.poll(async () => (await small.boundingBox())!.width).toBeCloseTo(32, 1)
|
||||
await expect(panel.getByRole("button", { name: "Zoom out", exact: true })).toBeDisabled()
|
||||
await fit.click()
|
||||
await expect.poll(async () => (await small.boundingBox())!.width).toBeGreaterThan(128)
|
||||
})
|
||||
|
||||
test("image files load into the review panel and keep it painted while loading", async ({ page }) => {
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
import { For, Show } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { IconButton } from "@opencode/ui/icon-button"
|
||||
import { Menu } from "@opencode/ui/menu"
|
||||
import { Tooltip } from "@opencode/ui/tooltip"
|
||||
import { showToast } from "@opencode/ui/toast"
|
||||
import { artifactKind } from "@opencode/util/artifact"
|
||||
import { getFilename } from "@opencode/util/path"
|
||||
import { usePlugin, type MountedSession, type SessionScreen } from "@opencode/plugin/gui"
|
||||
import { current, useShared } from "./context"
|
||||
import { OpenInAppMenuItemsV2, useOpenInApp } from "./open-in-app"
|
||||
import { resolveOpenInAppPath, workspaceFileUrl } from "./path"
|
||||
|
||||
export function ArtifactToolbar(props: {
|
||||
session: MountedSession
|
||||
screen: SessionScreen
|
||||
path: string
|
||||
text?: string
|
||||
mode: "preview" | "source"
|
||||
onModeChange?: (mode: "preview" | "source") => void
|
||||
meta: string[]
|
||||
html: boolean
|
||||
}) {
|
||||
const ctx = usePlugin()
|
||||
const shared = useShared()
|
||||
const [store, setStore] = createStore({ open: false })
|
||||
const path = () => resolveOpenInAppPath(props.screen.file.root, props.path)
|
||||
const kind = () => artifactKind(props.path)
|
||||
|
||||
const apps = useOpenInApp({
|
||||
get session() {
|
||||
return props.session
|
||||
},
|
||||
path,
|
||||
})
|
||||
|
||||
const browser = () => {
|
||||
if (!props.html) return
|
||||
const pane = current(shared.browser())
|
||||
|
||||
return pane?.canOpen(props.session, props.path) ? pane : undefined
|
||||
}
|
||||
|
||||
const modeLabel = () => ctx.t(props.mode === "preview" ? "view.viewSource" : "view.viewPreview")
|
||||
const toggleMode = () => props.onModeChange?.(props.mode === "preview" ? "source" : "preview")
|
||||
|
||||
const failed = () => {
|
||||
if (ctx.signal.aborted) return
|
||||
showToast({ variant: "error", title: ctx.t("common.requestFailed") })
|
||||
}
|
||||
|
||||
const copy = (text: string) => {
|
||||
void ctx.system
|
||||
.copy(text)
|
||||
.then(() => {
|
||||
if (ctx.signal.aborted) return
|
||||
showToast({ variant: "success", title: ctx.t("common.copied") })
|
||||
})
|
||||
.catch(failed)
|
||||
}
|
||||
|
||||
return (
|
||||
<div data-slot="artifact-toolbar" data-menu-open={store.open || undefined}>
|
||||
<div data-slot="artifact-filename" title={props.path}>
|
||||
<bdi>{getFilename(props.path)}</bdi>
|
||||
</div>
|
||||
<div data-slot="artifact-toolbar-trailing">
|
||||
<div data-slot="artifact-metadata">
|
||||
<For each={props.meta}>
|
||||
{(item, index) => (
|
||||
<>
|
||||
<Show when={index() > 0}>
|
||||
<span aria-hidden>·</span>
|
||||
</Show>
|
||||
<bdi class="truncate" title={item}>
|
||||
{item}
|
||||
</bdi>
|
||||
</>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
<div data-slot="artifact-toolbar-actions">
|
||||
<Show when={props.onModeChange}>
|
||||
<Tooltip value={modeLabel()}>
|
||||
<IconButton
|
||||
data-slot="artifact-mode-toggle"
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
aria-label={modeLabel()}
|
||||
onClick={toggleMode}
|
||||
icon={<Icon name={props.mode === "preview" ? "outline-code-brackets" : "outline-eye"} size="normal" />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Show>
|
||||
<Show when={props.text !== undefined}>
|
||||
<Tooltip value={ctx.t("view.copyContent")}>
|
||||
<IconButton
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
aria-label={ctx.t("view.copyContent")}
|
||||
onClick={() => copy(props.text ?? "")}
|
||||
icon={<Icon name="outline-copy" size="normal" />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Show>
|
||||
<Menu gutter={0} placement="bottom-end" open={store.open} onOpenChange={(open) => setStore("open", open)}>
|
||||
<Menu.Trigger
|
||||
as={IconButton}
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
aria-label={ctx.t("view.actions")}
|
||||
icon={<Icon name="outline-dots" size="normal" />}
|
||||
/>
|
||||
<Menu.Portal>
|
||||
<Menu.Content class="artifact-actions-menu">
|
||||
<Show when={props.text !== undefined}>
|
||||
<Menu.Item
|
||||
onSelect={() => {
|
||||
void ctx.system.save({ name: getFilename(props.path), content: props.text ?? "" }).catch(failed)
|
||||
}}
|
||||
>
|
||||
{ctx.t("view.download")}
|
||||
</Menu.Item>
|
||||
</Show>
|
||||
<Show when={props.onModeChange}>
|
||||
<Menu.Item onSelect={toggleMode}>{modeLabel()}</Menu.Item>
|
||||
</Show>
|
||||
<Show when={browser()}>
|
||||
{(pane) => (
|
||||
<Menu.Item
|
||||
onSelect={() => pane().open(props.session, workspaceFileUrl(props.screen.file.root, props.path))}
|
||||
>
|
||||
{ctx.t("view.openInBrowser")}
|
||||
</Menu.Item>
|
||||
)}
|
||||
</Show>
|
||||
<Show when={apps.canOpen()}>
|
||||
<Menu.Item onSelect={() => apps.openPath("finder", path(), true)} disabled={apps.opening()}>
|
||||
{ctx.t("view.reveal", { app: apps.options()[0].label })}
|
||||
</Menu.Item>
|
||||
</Show>
|
||||
<Menu.Item onSelect={() => copy(path())}>{ctx.t("open.copyPath")}</Menu.Item>
|
||||
<Show when={apps.canOpen() && kind() !== "audio" && kind() !== "video"}>
|
||||
<Menu.Sub>
|
||||
<Menu.SubTrigger disabled={apps.opening()}>{ctx.t("open.in")}</Menu.SubTrigger>
|
||||
<Menu.Portal>
|
||||
<Menu.SubContent class="open-in-app-v2-menu">
|
||||
<OpenInAppMenuItemsV2 state={apps} copyPath={false} close={() => setStore("open", false)} />
|
||||
</Menu.SubContent>
|
||||
</Menu.Portal>
|
||||
</Menu.Sub>
|
||||
</Show>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,36 +1,94 @@
|
||||
/* The control defaults to a fixed 232px with equal segments; here it hugs its two labels. */
|
||||
[data-slot="artifact-toolbar"] [data-slot="segmented-control-v2"] {
|
||||
width: auto;
|
||||
@import "@opencode/ui/document-surface.css";
|
||||
|
||||
[data-slot="artifact-view"] {
|
||||
--opencode-diffs-bg: var(--v2-background-bg-layer-01);
|
||||
container-type: inline-size;
|
||||
background-color: var(--v2-background-bg-layer-01);
|
||||
}
|
||||
|
||||
[data-slot="artifact-toolbar"] [data-slot="segmented-control-v2-item"] {
|
||||
flex: 0 0 auto;
|
||||
padding: 0 14px;
|
||||
[data-slot="artifact-toolbar"] {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
height: 44px;
|
||||
padding-inline: 20px 12px;
|
||||
background-color: var(--v2-background-bg-layer-01);
|
||||
}
|
||||
|
||||
/* Shrink-wrapped segments round the label box down a fraction; the ellipsis overflow then clips glyph edges. */
|
||||
[data-slot="artifact-toolbar"] [data-slot="segmented-control-v2-item-label"] {
|
||||
overflow: visible;
|
||||
max-width: none;
|
||||
[data-slot="artifact-filename"] {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--v2-text-text-base);
|
||||
font-size: 13px;
|
||||
font-weight: var(--font-weight-medium);
|
||||
line-height: var(--line-height-compact);
|
||||
}
|
||||
|
||||
[data-slot="artifact-toolbar-trailing"],
|
||||
[data-slot="artifact-toolbar-actions"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
[data-slot="artifact-toolbar-trailing"] {
|
||||
min-width: 0;
|
||||
max-width: 65%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
[data-slot="artifact-toolbar-actions"] {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
[data-slot="artifact-metadata"] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
color: var(--v2-text-text-faint);
|
||||
font-size: 13px;
|
||||
line-height: var(--line-height-compact);
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Reserve the metadata slot so revealing details never shifts the filename or actions. */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
[data-slot="artifact-metadata"] {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
[data-slot="artifact-toolbar"]:hover [data-slot="artifact-metadata"],
|
||||
[data-slot="artifact-toolbar"]:focus-within [data-slot="artifact-metadata"],
|
||||
[data-slot="artifact-toolbar"][data-menu-open] [data-slot="artifact-metadata"] {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.artifact-actions-menu {
|
||||
min-width: 160px;
|
||||
}
|
||||
|
||||
@container (max-width: 600px) {
|
||||
[data-slot="artifact-metadata"] {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
[data-slot="artifact-toolbar-actions"] [data-component="icon-button-v2"] {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="artifact-stage"] {
|
||||
--artifact-check: color-mix(in oklch, var(--v2-text-text-base) 5%, transparent);
|
||||
background-color: var(--v2-background-bg-deep);
|
||||
}
|
||||
|
||||
[data-slot="artifact-stage"][data-checker] {
|
||||
background-image:
|
||||
linear-gradient(45deg, var(--artifact-check) 25%, transparent 25%),
|
||||
linear-gradient(-45deg, var(--artifact-check) 25%, transparent 25%),
|
||||
linear-gradient(45deg, transparent 75%, var(--artifact-check) 75%),
|
||||
linear-gradient(-45deg, transparent 75%, var(--artifact-check) 75%);
|
||||
background-size: 16px 16px;
|
||||
background-position:
|
||||
0 0,
|
||||
0 8px,
|
||||
8px -8px,
|
||||
-8px 0;
|
||||
background-color: var(--v2-background-bg-layer-01);
|
||||
}
|
||||
|
||||
[data-slot="artifact-media"] {
|
||||
@@ -41,6 +99,11 @@
|
||||
0 12px 32px -12px color-mix(in oklch, var(--v2-text-text-base) 25%, transparent);
|
||||
}
|
||||
|
||||
img[data-slot="artifact-media"] {
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
[data-slot="artifact-media"]::-webkit-media-controls-fullscreen-button {
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
@@ -73,36 +136,130 @@
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
background: var(--v2-background-bg-base);
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
|
||||
[data-slot="artifact-table"] th,
|
||||
[data-slot="artifact-table"] td {
|
||||
position: relative;
|
||||
height: 28px;
|
||||
padding: 5px 12px;
|
||||
border-bottom: 1px solid var(--v2-border-border-muted);
|
||||
border-inline-end: 1px solid var(--v2-border-border-muted);
|
||||
padding-inline-end: 36px;
|
||||
border-bottom: 0.5px solid var(--v2-border-border-muted);
|
||||
border-inline-end: 0.5px solid var(--v2-border-border-muted);
|
||||
white-space: pre;
|
||||
max-width: 40ch;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: start;
|
||||
line-height: var(--line-height-compact);
|
||||
}
|
||||
|
||||
[data-slot="artifact-table-cell-text"] {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
[data-slot="artifact-table-copy"] {
|
||||
position: absolute;
|
||||
inset-inline-end: 6px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
[data-slot="artifact-table-copy"]:focus-visible {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
[data-slot="artifact-table"] :is(th, td):hover [data-slot="artifact-table-copy"] {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: none), (pointer: coarse) {
|
||||
[data-slot="artifact-table-copy"] {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
[data-slot="artifact-table"] :is(th, td) {
|
||||
height: 48px;
|
||||
padding-inline-end: 60px;
|
||||
}
|
||||
|
||||
[data-slot="artifact-table-copy"] {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="artifact-table"] th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
background: var(--v2-background-bg-layer-02);
|
||||
border-top: 0.5px solid var(--v2-border-border-base);
|
||||
border-bottom-color: var(--v2-border-border-base);
|
||||
border-inline-end-color: var(--v2-border-border-base);
|
||||
font-weight: var(--font-weight-medium);
|
||||
color: var(--v2-text-text-muted);
|
||||
}
|
||||
|
||||
[data-slot="artifact-table"] tbody tr:hover td {
|
||||
background: color-mix(in oklch, var(--v2-text-text-base) 3%, transparent);
|
||||
[data-slot="artifact-table"] th:last-child {
|
||||
border-inline-end: 0;
|
||||
}
|
||||
|
||||
[data-slot="artifact-table"] td[data-index] {
|
||||
color: var(--v2-text-text-faint);
|
||||
text-align: end;
|
||||
user-select: none;
|
||||
@media (hover: hover) {
|
||||
[data-slot="artifact-table"] tbody tr:hover td {
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="artifact-table"] th:first-child,
|
||||
[data-slot="artifact-table"] td:first-child {
|
||||
padding-inline-start: 20px;
|
||||
}
|
||||
|
||||
[data-slot="artifact-document-stage"][data-kind="markdown"],
|
||||
[data-slot="artifact-document-stage"][data-kind="font"] {
|
||||
padding-block-end: 20px;
|
||||
}
|
||||
|
||||
[data-slot="artifact-markdown-page"] {
|
||||
min-height: 100%;
|
||||
padding: 64px clamp(24px, 12.5%, 134px);
|
||||
}
|
||||
|
||||
[data-slot="artifact-markdown-content"] {
|
||||
width: 100%;
|
||||
max-width: 768px;
|
||||
margin-inline: auto;
|
||||
}
|
||||
|
||||
[data-slot="artifact-diagram"] {
|
||||
min-width: 0;
|
||||
padding: 24px 32px;
|
||||
}
|
||||
|
||||
@container (max-width: 600px) {
|
||||
[data-slot="artifact-document-stage"][data-kind="markdown"],
|
||||
[data-slot="artifact-document-stage"][data-kind="font"] {
|
||||
padding-block-end: 12px;
|
||||
}
|
||||
|
||||
[data-slot="artifact-markdown-page"] {
|
||||
padding: 32px 24px;
|
||||
}
|
||||
|
||||
[data-slot="artifact-diagram"] {
|
||||
padding: 20px 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,21 +13,22 @@ import {
|
||||
import { createStore } from "solid-js/store"
|
||||
import { Dynamic } from "solid-js/web"
|
||||
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
||||
import { Button } from "@opencode/ui/button"
|
||||
import { PreviewControls } from "@opencode/ui/preview-controls"
|
||||
import { useDialog } from "@opencode/ui/context/dialog"
|
||||
import { FileIcon } from "@opencode/ui/file-icon"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { IconButton } from "@opencode/ui/icon-button"
|
||||
import { ImagePreview } from "@opencode/ui/image-preview"
|
||||
import { SegmentedControl, SegmentedControlItem } from "@opencode/ui/segmented-control"
|
||||
import { Loader } from "@opencode/ui/loader"
|
||||
import { showToast } from "@opencode/ui/toast"
|
||||
import { Markdown } from "@opencode/session-ui/markdown"
|
||||
import { MarkdownProvider, useMarkdown } from "@opencode/session-ui/context/markdown"
|
||||
import { artifactKind, type ArtifactKind } from "@opencode/util/artifact"
|
||||
import { getDirectory, getFilename } from "@opencode/util/path"
|
||||
import { createKeyed, usePlugin, type FileContent, type MountedSession } from "@opencode/plugin/gui"
|
||||
import { createKeyed, usePlugin, type FileContent, type MountedSession, type SessionScreen } from "@opencode/plugin/gui"
|
||||
import { blobUrlFromContent, bytesFromContent, contentBytes, parseDelimited, resolveArtifactPath } from "./artifact"
|
||||
import { current, useShared } from "./context"
|
||||
import { FileViewer } from "@opencode/plugin/gui/file"
|
||||
import { workspaceFileUrl } from "./path"
|
||||
import { ArtifactToolbar } from "./artifact-toolbar"
|
||||
|
||||
type ArtifactMode = "preview" | "source"
|
||||
|
||||
@@ -67,6 +68,7 @@ const previewableKinds: readonly ArtifactKind[] = ["svg", "html", "markdown", "m
|
||||
*/
|
||||
export default function ArtifactView(props: {
|
||||
session: MountedSession
|
||||
screen: SessionScreen
|
||||
path: string
|
||||
content: FileContent
|
||||
cacheKey?: string
|
||||
@@ -112,10 +114,10 @@ export default function ArtifactView(props: {
|
||||
const info: ArtifactInfo = parsed ? { rows: parsed.total, columns: parsed.columns } : state().info
|
||||
|
||||
return [
|
||||
info.width && info.height ? `${info.width} × ${info.height}` : undefined,
|
||||
info.duration ? formatDuration(info.duration) : undefined,
|
||||
info.rows !== undefined ? ctx.plural("view.table.rows", Math.max(0, info.rows - 1)) : undefined,
|
||||
info.width && info.height ? `${info.width} × ${info.height}` : undefined,
|
||||
info.columns !== undefined ? ctx.plural("view.table.columns", info.columns) : undefined,
|
||||
info.rows !== undefined ? ctx.plural("view.table.rows", Math.max(0, info.rows - 1)) : undefined,
|
||||
...(info.details ?? []),
|
||||
formatBytes(locale.locale(), contentBytes(props.content)),
|
||||
].filter((item): item is string => !!item)
|
||||
@@ -136,10 +138,18 @@ export default function ArtifactView(props: {
|
||||
})
|
||||
|
||||
const rendered = () => (
|
||||
<div class="min-h-0 flex-1 overflow-y-auto" data-scrollable>
|
||||
<Show
|
||||
when={kind() === "markdown"}
|
||||
fallback={<ArtifactMermaid text={props.content.content} cacheKey={props.cacheKey} />}
|
||||
<Show
|
||||
when={kind() === "markdown"}
|
||||
fallback={<ArtifactMermaid text={props.content.content} cacheKey={props.cacheKey} />}
|
||||
>
|
||||
<div
|
||||
data-slot="artifact-document-stage"
|
||||
data-kind="markdown"
|
||||
data-document-surface-inset
|
||||
data-document-surface-scrollport
|
||||
data-document-surface-column
|
||||
class="min-h-0 flex-1 overflow-auto"
|
||||
data-scrollable
|
||||
>
|
||||
<ArtifactMarkdown
|
||||
session={props.session}
|
||||
@@ -147,21 +157,25 @@ export default function ArtifactView(props: {
|
||||
text={props.content.content}
|
||||
cacheKey={props.cacheKey}
|
||||
/>
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
</Show>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<div data-slot="artifact-view" class="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
<ArtifactToolbar
|
||||
session={props.session}
|
||||
screen={props.screen}
|
||||
path={props.path}
|
||||
text={
|
||||
props.content.type !== "binary" && previewableKinds.includes(artifactKind(props.path))
|
||||
? props.content.content
|
||||
: undefined
|
||||
}
|
||||
mode={state().mode}
|
||||
onModeChange={previewable() ? (mode) => change({ mode }) : undefined}
|
||||
meta={meta()}
|
||||
actions={
|
||||
<Show when={kind() === "html"}>
|
||||
<OpenInBrowserButton session={props.session} path={props.path} />
|
||||
</Show>
|
||||
}
|
||||
html={kind() === "html"}
|
||||
/>
|
||||
<Show when={!previewable() || state().mode === "preview"} fallback={props.source}>
|
||||
<Switch fallback={<ArtifactBinary path={props.path} size={size()} reason={state().reason} />}>
|
||||
@@ -197,7 +211,7 @@ export default function ArtifactView(props: {
|
||||
</Match>
|
||||
</Switch>
|
||||
</Show>
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -222,80 +236,6 @@ function formatDuration(seconds: number) {
|
||||
return `${minutes}:${String(total % 60).padStart(2, "0")}`
|
||||
}
|
||||
|
||||
function ArtifactToolbar(props: {
|
||||
mode?: ArtifactMode
|
||||
onModeChange?: (mode: ArtifactMode) => void
|
||||
meta: string[]
|
||||
actions?: JSX.Element
|
||||
}) {
|
||||
const ctx = usePlugin()
|
||||
|
||||
return (
|
||||
<div data-slot="artifact-toolbar" class="flex h-10 shrink-0 items-center gap-3 px-4">
|
||||
<Show when={props.onModeChange}>
|
||||
<SegmentedControl
|
||||
value={props.mode ?? "preview"}
|
||||
onChange={(value) => {
|
||||
if (value === "preview" || value === "source") props.onModeChange?.(value)
|
||||
}}
|
||||
>
|
||||
<SegmentedControlItem value="preview">{ctx.t("view.preview")}</SegmentedControlItem>
|
||||
<SegmentedControlItem value="source">{ctx.t("view.source")}</SegmentedControlItem>
|
||||
</SegmentedControl>
|
||||
</Show>
|
||||
<div class="ms-auto flex min-w-0 items-center gap-3">
|
||||
<div class="flex min-w-0 items-center gap-2 text-12-regular text-text-weak">
|
||||
<For each={props.meta}>
|
||||
{(item, index) => (
|
||||
<>
|
||||
<Show when={index() > 0}>
|
||||
<span aria-hidden class="text-text-faint">
|
||||
·
|
||||
</span>
|
||||
</Show>
|
||||
<span class="truncate tabular-nums">{item}</span>
|
||||
</>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
{props.actions}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Shows only while the browser pane is active and can load the file. */
|
||||
function OpenInBrowserButton(props: { session: MountedSession; path: string }) {
|
||||
const ctx = usePlugin()
|
||||
const shared = useShared()
|
||||
|
||||
const pane = () => {
|
||||
const browser = current(shared.browser())
|
||||
|
||||
return browser?.canOpen(props.session, props.path) ? browser : undefined
|
||||
}
|
||||
|
||||
return (
|
||||
<Show when={pane()}>
|
||||
{(browser) => (
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost"
|
||||
icon="globe"
|
||||
onClick={() => {
|
||||
// The screen's workspace root, read when the user acts.
|
||||
const root = ctx.screen.current()?.file.root
|
||||
|
||||
if (root !== undefined) browser().open(props.session, workspaceFileUrl(root, props.path))
|
||||
}}
|
||||
>
|
||||
{ctx.t("view.openInBrowser")}
|
||||
</Button>
|
||||
)}
|
||||
</Show>
|
||||
)
|
||||
}
|
||||
|
||||
function createMediaUrl(content: () => FileContent) {
|
||||
return createMemo(() => {
|
||||
const streamed = content().url
|
||||
@@ -335,8 +275,6 @@ function ArtifactImage(props: MediaProps) {
|
||||
}
|
||||
|
||||
function ImageStage(props: MediaProps & { src: string }) {
|
||||
const ctx = usePlugin()
|
||||
|
||||
const [view, setView] = createStore({
|
||||
width: 0,
|
||||
height: 0,
|
||||
@@ -350,15 +288,18 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
|
||||
const fit = () =>
|
||||
Math.min(
|
||||
1,
|
||||
artifactKind(props.path) === "svg" ? Infinity : 1,
|
||||
Math.max(1, view.width - 48) / (view.imageWidth || 1),
|
||||
Math.max(1, view.height - 48) / (view.imageHeight || 1),
|
||||
)
|
||||
|
||||
const minZoom = () => Math.min(0.25, 1 / fit())
|
||||
const maxZoom = () => Math.max(8, 1 / fit())
|
||||
|
||||
const bound = (offset: number, image: number, zoom: number) => {
|
||||
// Keep the fitted footprint covered, including its letterboxing. Clamping to
|
||||
// the stage edges instead would move the anchor during small pinch increments.
|
||||
const limit = (image * fit() * (zoom - 1)) / 2
|
||||
const limit = Math.max(0, (image * fit() * (zoom - 1)) / 2)
|
||||
|
||||
return Math.max(-limit, Math.min(limit, offset))
|
||||
}
|
||||
@@ -375,7 +316,7 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
let dragged = false
|
||||
|
||||
const cursor = () => {
|
||||
if (view.zoom === 1) return undefined
|
||||
if (view.zoom <= 1) return undefined
|
||||
|
||||
return view.dragging ? "grabbing" : "grab"
|
||||
}
|
||||
@@ -391,7 +332,7 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
if (!stage) return
|
||||
|
||||
const rect = stage.getBoundingClientRect()
|
||||
const next = Math.max(1, Math.min(Math.max(8, 1 / fit()), zoom))
|
||||
const next = Math.max(minZoom(), Math.min(maxZoom(), zoom))
|
||||
const ratio = next / view.zoom
|
||||
const anchor = { x: clientX - rect.left - rect.width / 2, y: clientY - rect.top - rect.height / 2 }
|
||||
setView({
|
||||
@@ -401,6 +342,13 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
})
|
||||
}
|
||||
|
||||
const zoomBy = (factor: number) => {
|
||||
if (!stage) return
|
||||
const rect = stage.getBoundingClientRect()
|
||||
|
||||
zoomAt(view.zoom * factor, rect.left + rect.width / 2, rect.top + rect.height / 2)
|
||||
}
|
||||
|
||||
createResizeObserver(
|
||||
() => stage,
|
||||
() => {
|
||||
@@ -415,12 +363,11 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
<div
|
||||
ref={stage}
|
||||
data-slot="artifact-stage"
|
||||
data-checker
|
||||
data-zoom={view.zoom === 1 ? "fit" : "actual"}
|
||||
data-overflow={fit() < 1 || undefined}
|
||||
class="relative min-h-0 flex-1 overflow-hidden"
|
||||
on:wheel={(event) => {
|
||||
if (!view.imageWidth || (!event.ctrlKey && view.zoom === 1)) return
|
||||
if (!view.imageWidth || (!event.ctrlKey && view.zoom <= 1)) return
|
||||
|
||||
// Chromium delivers trackpad pinch as Ctrl-wheel. Consume it here before
|
||||
// Desktop's window-level zoom handler; ordinary fitted scrolling stays native.
|
||||
@@ -458,7 +405,7 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
|
||||
dragged = false
|
||||
|
||||
if (view.zoom === 1) return
|
||||
if (view.zoom <= 1) return
|
||||
|
||||
drag = { id: event.pointerId, clientX: event.clientX, clientY: event.clientY, x: x(), y: y() }
|
||||
event.currentTarget.setPointerCapture(event.pointerId)
|
||||
@@ -499,7 +446,7 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
return
|
||||
}
|
||||
|
||||
if (view.zoom > 1) return reset()
|
||||
if (view.zoom !== 1) return reset()
|
||||
|
||||
zoomAt(1 / fit(), event.clientX, event.clientY)
|
||||
}}
|
||||
@@ -507,11 +454,14 @@ function ImageStage(props: MediaProps & { src: string }) {
|
||||
<Show when={!view.imageWidth}>
|
||||
<MediaLoading />
|
||||
</Show>
|
||||
<div class="absolute end-3 top-3">
|
||||
<Button size="small" variant="neutral" disabled={view.zoom === 1} onClick={reset}>
|
||||
{ctx.t("view.fit")}
|
||||
</Button>
|
||||
</div>
|
||||
<PreviewControls
|
||||
disabled={!view.imageWidth}
|
||||
zoomInDisabled={view.zoom >= maxZoom()}
|
||||
zoomOutDisabled={view.zoom <= minZoom()}
|
||||
onZoomIn={() => zoomBy(1.25)}
|
||||
onZoomOut={() => zoomBy(1 / 1.25)}
|
||||
onFit={reset}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -638,14 +588,7 @@ function ArtifactVideo(props: MediaProps) {
|
||||
}}
|
||||
>
|
||||
<span class="flex size-9 items-center justify-center rounded-full transition-colors">
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||
<path
|
||||
d="M3 6V3H6M10 3H13V6M13 10V13H10M6 13H3V10"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="square"
|
||||
/>
|
||||
</svg>
|
||||
<Icon name="outline-expand" size="normal" />
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -659,9 +602,9 @@ function ArtifactAudio(props: MediaProps) {
|
||||
return (
|
||||
<div data-slot="artifact-stage" class="relative min-h-0 flex-1 overflow-auto">
|
||||
<div class="absolute inset-0 flex items-center justify-center p-6">
|
||||
<div class="flex w-full max-w-lg flex-col items-center gap-5 rounded-xl border border-v2-border-border-muted bg-v2-background-bg-base px-8 py-8 shadow-[var(--v2-elevation-raised)]">
|
||||
<div class="flex w-full max-w-lg flex-col items-center gap-5 rounded-xl bg-v2-background-bg-base px-8 py-8 shadow-[var(--v2-elevation-raised)]">
|
||||
<div class="flex size-14 items-center justify-center rounded-full bg-v2-background-bg-layer-02">
|
||||
<FileIcon node={{ path: props.path, type: "file" }} class="size-7" />
|
||||
<FileIcon node={{ path: props.path, type: "file" }} mono class="size-7 text-v2-icon-icon-muted" />
|
||||
</div>
|
||||
<div class="max-w-full truncate text-14-medium text-text-strong">{getFilename(props.path)}</div>
|
||||
<audio
|
||||
@@ -711,8 +654,10 @@ function ArtifactMarkdown(props: { session: MountedSession; path: string; text:
|
||||
openLocalFile={(href) => void links.open({ href, base: dir(), session: props.session })}
|
||||
localFileExists={(href) => untrack(() => links.exists({ href, base: dir(), session: props.session }))}
|
||||
>
|
||||
<div class="mx-auto w-full max-w-3xl px-8 py-6">
|
||||
<Markdown text={props.text} cacheKey={props.cacheKey} />
|
||||
<div data-slot="artifact-markdown-page" data-component="document-surface">
|
||||
<div data-slot="artifact-markdown-content">
|
||||
<Markdown text={props.text} cacheKey={props.cacheKey} />
|
||||
</div>
|
||||
</div>
|
||||
</MarkdownProvider>
|
||||
)
|
||||
@@ -720,35 +665,97 @@ function ArtifactMarkdown(props: { session: MountedSession; path: string; text:
|
||||
|
||||
/** Mermaid sources render through the same fenced-block pipeline the timeline uses. */
|
||||
function ArtifactMermaid(props: { text: string; cacheKey?: string }) {
|
||||
const [view, setView] = createStore({ zoom: 1, width: 0 })
|
||||
let scroller: HTMLDivElement | undefined
|
||||
|
||||
createResizeObserver(
|
||||
() => scroller,
|
||||
(rect) => setView("width", rect.width),
|
||||
)
|
||||
|
||||
return (
|
||||
<div class="mx-auto w-full max-w-4xl px-8 py-6">
|
||||
<Markdown text={`\`\`\`mermaid\n${props.text}\n\`\`\``} cacheKey={props.cacheKey} />
|
||||
<div class="relative flex min-h-0 flex-1 flex-col">
|
||||
<div ref={scroller} class="min-h-0 flex-1 overflow-auto" data-scrollable>
|
||||
<div class="grid min-h-full w-max min-w-full place-items-center">
|
||||
<div data-slot="artifact-diagram" style={{ width: `${Math.min(view.width, 896)}px`, zoom: view.zoom }}>
|
||||
<Markdown text={`\`\`\`mermaid\n${props.text}\n\`\`\``} cacheKey={props.cacheKey} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<PreviewControls
|
||||
disabled={view.width === 0}
|
||||
zoomInDisabled={view.zoom >= 4}
|
||||
zoomOutDisabled={view.zoom <= 0.25}
|
||||
onZoomIn={() => setView("zoom", Math.min(4, view.zoom * 1.25))}
|
||||
onZoomOut={() => setView("zoom", Math.max(0.25, view.zoom / 1.25))}
|
||||
onFit={() => {
|
||||
setView("zoom", 1)
|
||||
scroller?.scrollTo({ top: 0, left: 0 })
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ArtifactTable(props: { parsed: ReturnType<typeof parseDelimited> }) {
|
||||
const ctx = usePlugin()
|
||||
const controller = new AbortController()
|
||||
onCleanup(() => controller.abort())
|
||||
const parsed = () => props.parsed
|
||||
// Pad the header to the widest row so no data column is dropped.
|
||||
const header = () => Array.from({ length: parsed().columns }, (_, index) => parsed().rows[0]?.[index] ?? "")
|
||||
const body = () => parsed().rows.slice(1)
|
||||
|
||||
const copy = (text: string) => {
|
||||
// Read the parsed value, not the ellipsized presentation, including embedded tabs and newlines.
|
||||
void ctx.system.copy(text).catch(() => {
|
||||
if (!controller.signal.aborted) showToast({ variant: "error", title: ctx.t("view.table.copyFailed") })
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="min-h-0 flex-1 overflow-auto">
|
||||
<div class="min-h-0 flex-1 overflow-auto" data-scrollable>
|
||||
<table data-slot="artifact-table" class="min-w-full text-13-regular text-text-base">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-index />
|
||||
<For each={header()}>{(cell) => <th>{cell}</th>}</For>
|
||||
<For each={header()}>
|
||||
{(cell) => (
|
||||
<th scope="col">
|
||||
<span data-slot="artifact-table-cell-text">{cell}</span>
|
||||
<IconButton
|
||||
data-slot="artifact-table-copy"
|
||||
variant="ghost-muted"
|
||||
size="small"
|
||||
icon={<Icon name="outline-copy" size="normal" />}
|
||||
aria-label={ctx.t("view.table.copyCell")}
|
||||
title={ctx.t("view.table.copyCell")}
|
||||
onClick={() => copy(cell)}
|
||||
/>
|
||||
</th>
|
||||
)}
|
||||
</For>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<For each={body()}>
|
||||
{(row, index) => (
|
||||
{(row) => (
|
||||
<tr>
|
||||
<td data-index>{index() + 1}</td>
|
||||
<For each={header()}>{(_, column) => <td>{row[column()] ?? ""}</td>}</For>
|
||||
<For each={header()}>
|
||||
{(_, column) => (
|
||||
<td>
|
||||
<span data-slot="artifact-table-cell-text">{row[column()] ?? ""}</span>
|
||||
<IconButton
|
||||
data-slot="artifact-table-copy"
|
||||
variant="ghost-muted"
|
||||
size="small"
|
||||
icon={<Icon name="outline-copy" size="normal" />}
|
||||
aria-label={ctx.t("view.table.copyCell")}
|
||||
title={ctx.t("view.table.copyCell")}
|
||||
onClick={() => copy(row[column()] ?? "")}
|
||||
/>
|
||||
</td>
|
||||
)}
|
||||
</For>
|
||||
</tr>
|
||||
)}
|
||||
</For>
|
||||
@@ -780,8 +787,20 @@ function ArtifactFont(props: { path: string; content: FileContent }) {
|
||||
})
|
||||
|
||||
return (
|
||||
<div class="min-h-0 flex-1 overflow-auto">
|
||||
<div class="mx-auto flex w-full max-w-3xl flex-col gap-6 px-8 py-8" style={{ "font-family": `"${family()}"` }}>
|
||||
<div
|
||||
data-slot="artifact-document-stage"
|
||||
data-kind="font"
|
||||
data-document-surface-inset
|
||||
data-document-surface-scrollport
|
||||
data-document-surface-column
|
||||
class="min-h-0 flex-1 overflow-auto"
|
||||
data-scrollable
|
||||
>
|
||||
<div
|
||||
data-component="document-surface"
|
||||
class="flex min-h-full w-full flex-col gap-6 px-8 py-8"
|
||||
style={{ "font-family": `"${family()}"` }}
|
||||
>
|
||||
<div class="text-text-strong" style={{ "font-size": "56px", "line-height": "1.1" }}>
|
||||
{getFilename(props.path).replace(/\.[^.]+$/, "")}
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { createMemo, createUniqueId, onCleanup, Show, type Accessor } from "solid-js"
|
||||
import { createMemo, createUniqueId, For, onCleanup, Show, type Accessor } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { createQuery, keepPreviousData } from "@tanstack/solid-query"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { SessionFilePanelV2, SessionFilePanelV2Empty } from "@opencode/session-ui/v2/session-file-panel-v2"
|
||||
import { SessionReviewV2Sidebar, SessionReviewV2SidebarToggle } from "@opencode/session-ui/v2/session-review-v2"
|
||||
import { getFilename } from "@opencode/util/path"
|
||||
import { artifactKind } from "@opencode/util/artifact"
|
||||
import type { ChangeKind } from "@opencode/plugin/gui/review"
|
||||
import {
|
||||
createKeyed,
|
||||
@@ -187,28 +188,92 @@ export function SessionFileBrowserTab(props: {
|
||||
</SessionReviewV2Sidebar>
|
||||
}
|
||||
>
|
||||
<Show
|
||||
when={!props.placeholder}
|
||||
fallback={
|
||||
<SessionFilePanelV2Empty>
|
||||
<div class="flex flex-col items-center gap-2 text-center text-text-weak">
|
||||
<Icon name="file-tree" size="large" class="mb-2" />
|
||||
<div class="text-[13px] font-medium leading-[13px] text-text-strong">{ctx.t("command.open")}</div>
|
||||
<div class="h-5 text-13-regular leading-5">{ctx.t("selectToOpen")}</div>
|
||||
</div>
|
||||
</SessionFilePanelV2Empty>
|
||||
}
|
||||
>
|
||||
<div class="min-h-0 flex-1">
|
||||
<Show when={props.id} keyed>
|
||||
{(id) => <SessionFileView session={props.session} screen={props.screen} id={id} />}
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
<SessionFileViews session={props.session} screen={props.screen} id={props.id} placeholder={props.placeholder} />
|
||||
</SessionFilePanelV2>
|
||||
)
|
||||
}
|
||||
|
||||
function SessionFileViews(props: {
|
||||
session: MountedSession
|
||||
screen: SessionScreen
|
||||
id?: string
|
||||
placeholder: boolean
|
||||
}) {
|
||||
const ctx = usePlugin()
|
||||
const panel = usePanel()
|
||||
|
||||
const scope = createMemo(
|
||||
() => ({ session: props.session.key, root: props.screen.file.root, screen: props.screen }),
|
||||
undefined,
|
||||
{
|
||||
equals: (previous, next) =>
|
||||
previous?.session === next.session && previous.root === next.root && previous.screen === next.screen,
|
||||
},
|
||||
)
|
||||
|
||||
return (
|
||||
<Show when={scope()} keyed>
|
||||
{(scope) => {
|
||||
const offices = createMemo(() =>
|
||||
panel.open().filter((id) => {
|
||||
if (!isFileTab(id)) return false
|
||||
|
||||
const kind = artifactKind(fileTabPath(scope.screen.file, id))
|
||||
|
||||
return kind === "document" || kind === "spreadsheet" || kind === "presentation"
|
||||
}),
|
||||
)
|
||||
|
||||
const selected = () => (props.placeholder ? undefined : props.id)
|
||||
|
||||
const other = () => {
|
||||
const id = selected()
|
||||
|
||||
return id && !offices().includes(id) ? id : undefined
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="relative min-h-0 flex-1">
|
||||
<Show when={props.placeholder}>
|
||||
<SessionFilePanelV2Empty>
|
||||
<div class="flex flex-col items-center gap-2 text-center text-text-weak">
|
||||
<Icon name="file-tree" size="large" class="mb-2" />
|
||||
<div class="text-[13px] font-medium leading-[13px] text-text-strong">{ctx.t("command.open")}</div>
|
||||
<div class="h-5 text-13-regular leading-5">{ctx.t("selectToOpen")}</div>
|
||||
</div>
|
||||
</SessionFilePanelV2Empty>
|
||||
</Show>
|
||||
<Show when={other()} keyed>
|
||||
{(id) => <SessionFileView session={props.session} screen={props.screen} id={id} />}
|
||||
</Show>
|
||||
<For each={offices()}>
|
||||
{(id) => {
|
||||
// Selection history belongs to this open tab; closing it disposes the viewer and its worker.
|
||||
const visited = createMemo((previous) => previous || selected() === id, false)
|
||||
const active = () => selected() === id
|
||||
|
||||
return (
|
||||
<Show when={visited()}>
|
||||
<div
|
||||
class="absolute inset-0"
|
||||
// Unlike display:none, this preserves the viewport geometry and its warm page canvases.
|
||||
style={{ visibility: active() ? "visible" : "hidden" }}
|
||||
inert={!active() || undefined}
|
||||
aria-hidden={!active() || undefined}
|
||||
>
|
||||
<SessionFileView session={props.session} screen={props.screen} id={id} />
|
||||
</div>
|
||||
</Show>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
</Show>
|
||||
)
|
||||
}
|
||||
|
||||
/** The side panel render every file tab and the "Open file" launcher share. */
|
||||
export default function FileBrowser(props: {
|
||||
tab: Accessor<PanelTab>
|
||||
|
||||
@@ -6,6 +6,12 @@ export default {
|
||||
"view.preview": "Preview",
|
||||
"view.fit": "Fit",
|
||||
"view.source": "Source",
|
||||
"view.viewSource": "View source",
|
||||
"view.viewPreview": "View preview",
|
||||
"view.copyContent": "Copy content",
|
||||
"view.actions": "File actions",
|
||||
"view.download": "Download",
|
||||
"view.reveal": "Reveal in {{app}}",
|
||||
"view.openInBrowser": "Open in browser",
|
||||
"view.fullscreen": "Enter full screen",
|
||||
"view.binary": "Binary file · {{size}}",
|
||||
@@ -15,6 +21,8 @@ export default {
|
||||
"view.table.columns.one": "{{count}} column",
|
||||
"view.table.columns.other": "{{count}} columns",
|
||||
"view.table.truncated": "Showing the first {{shown}} of {{total}} rows.",
|
||||
"view.table.copyCell": "Copy cell",
|
||||
"view.table.copyFailed": "Couldn't copy this cell.",
|
||||
"view.fontSample": "Sphinx of black quartz, judge my vow.",
|
||||
"open.in": "Open in",
|
||||
"open.ariaLabel": "Open in {{app}}",
|
||||
|
||||
@@ -11,7 +11,7 @@ export function FileVisual(props: { path: string; temporary?: boolean; notFound?
|
||||
<FileIcon node={{ path: props.path, type: "file" }} mono class="absolute inset-0 size-4 tab-fileicon-mono" />
|
||||
</span>
|
||||
<span
|
||||
class="text-14-medium truncate"
|
||||
class="font-sans font-medium leading-[calc(var(--font-size-base)*1.5)] tracking-normal truncate"
|
||||
classList={{ italic: props.temporary, "line-through": props.notFound }}
|
||||
data-file-not-found={props.notFound ? "" : undefined}
|
||||
>
|
||||
|
||||
@@ -269,11 +269,12 @@ export default function OpenInAppButton(props: { session: MountedSession; screen
|
||||
)
|
||||
}
|
||||
|
||||
function OpenInAppMenuItemsV2(props: {
|
||||
export function OpenInAppMenuItemsV2(props: {
|
||||
state: OpenInAppState
|
||||
path?: () => string
|
||||
reveal?: boolean
|
||||
selection?: boolean
|
||||
copyPath?: boolean
|
||||
close?: () => void
|
||||
}) {
|
||||
const ctx = usePlugin()
|
||||
@@ -331,16 +332,18 @@ function OpenInAppMenuItemsV2(props: {
|
||||
</Menu.RadioGroup>
|
||||
</Show>
|
||||
</Menu.Group>
|
||||
<Menu.Separator />
|
||||
<Menu.Item
|
||||
onSelect={() => {
|
||||
props.close?.()
|
||||
props.state.copyPath(path())
|
||||
}}
|
||||
>
|
||||
<Icon name="copy" size="small" class="text-icon-weak" />
|
||||
{ctx.t("open.copyPath")}
|
||||
</Menu.Item>
|
||||
<Show when={props.copyPath !== false}>
|
||||
<Menu.Separator />
|
||||
<Menu.Item
|
||||
onSelect={() => {
|
||||
props.close?.()
|
||||
props.state.copyPath(path())
|
||||
}}
|
||||
>
|
||||
<Icon name="copy" size="small" class="text-icon-weak" />
|
||||
{ctx.t("open.copyPath")}
|
||||
</Menu.Item>
|
||||
</Show>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -507,13 +507,14 @@ export function SessionFileView(props: { session: MountedSession; screen: Sessio
|
||||
)
|
||||
|
||||
return (
|
||||
<div class="mt-3 relative h-full min-h-0 flex flex-col">
|
||||
<div class="relative h-full min-h-0 flex flex-col" classList={{ "mt-3": !artifact() }}>
|
||||
<Switch>
|
||||
<Match when={current()?.loaded ? current()?.content : undefined}>
|
||||
{(value) => (
|
||||
<Show when={artifact()} fallback={codeView()}>
|
||||
<ArtifactView
|
||||
session={props.session}
|
||||
screen={props.screen}
|
||||
path={path() ?? ""}
|
||||
content={value()}
|
||||
cacheKey={cacheKey()}
|
||||
|
||||
@@ -117,7 +117,6 @@ export default function OfficeDocument(props: FileViewerProps) {
|
||||
return (
|
||||
<OfficePages
|
||||
pages={opened().pages()}
|
||||
maxScale={1}
|
||||
paint={opened().paint}
|
||||
label={(index) => ctx.t("page", { number: index + 1 })}
|
||||
overlay={(input) => (
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { createMemo, createSignal, Index, onCleanup, onMount, Show, type JSX } from "solid-js"
|
||||
import { batch, createMemo, createSignal, Index, onCleanup, onMount, Show, type JSX } from "solid-js"
|
||||
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { createKeyed } from "@opencode/plugin/gui"
|
||||
import { PreviewControls } from "@opencode/ui/preview-controls"
|
||||
import { DocumentSurface } from "@opencode/ui/document-surface"
|
||||
import { paper } from "./paper"
|
||||
|
||||
/** Paints one page into `canvas` at `scale`; `signal` aborts once a newer paint replaces this one or the page leaves. */
|
||||
@@ -27,8 +30,6 @@ type SharedObserver = { value: IntersectionObserver | undefined }
|
||||
/** The timer of the next slice of rows, and how many rows it mounts. */
|
||||
type Growth = { timer: ReturnType<typeof setTimeout> | undefined; slice: number }
|
||||
|
||||
const padding = 24
|
||||
|
||||
/** How long a resize has to settle before visible pages paint again at the new scale. */
|
||||
const settleDelay = 150
|
||||
|
||||
@@ -42,13 +43,12 @@ const sliceBudget = 12
|
||||
const maxSlice = 200
|
||||
|
||||
/**
|
||||
* A column of pages that fit the pane's width, up to `maxScale`. Only pages near the viewport hold a bitmap, an
|
||||
* A column of pages that fit the pane's width. Only pages near the viewport hold a bitmap, an
|
||||
* overlay and the work that keeps them: a long document would otherwise keep hundreds of page-sized canvases in memory,
|
||||
* and mount the work for each at once.
|
||||
*/
|
||||
export function OfficePages(props: {
|
||||
pages: readonly PageSize[]
|
||||
maxScale: number
|
||||
paint: PaintPage
|
||||
label: (index: number) => string
|
||||
/** Laid over each page near the viewport, such as a text layer for selection, links and screen readers. */
|
||||
@@ -60,6 +60,7 @@ export function OfficePages(props: {
|
||||
/** Receives the column's scroll function once it mounts. */
|
||||
onScrollTo?: (scrollTo: ScrollToPage) => void
|
||||
}) {
|
||||
const [view, setView] = createStore({ zoom: 1, gutter: 20 })
|
||||
const [width, setWidth] = createSignal(0)
|
||||
// The width pages paint at: a resize repaints each visible page once it settles, while the CSS size follows at once.
|
||||
const [settled, setSettled] = createSignal(0)
|
||||
@@ -73,12 +74,17 @@ export function OfficePages(props: {
|
||||
const watched = new Map<Element, (near: boolean) => void>()
|
||||
const observer: SharedObserver = { value: undefined }
|
||||
let scroller: HTMLDivElement | undefined
|
||||
let column: HTMLDivElement | undefined
|
||||
let timer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
createResizeObserver(
|
||||
() => scroller,
|
||||
(rect) => {
|
||||
setWidth(rect.width)
|
||||
if (!column) return
|
||||
batch(() => {
|
||||
setView("gutter", Number.parseFloat(getComputedStyle(column).paddingInlineStart))
|
||||
setWidth(rect.width)
|
||||
})
|
||||
clearTimeout(timer)
|
||||
|
||||
if (settled() === 0) return void setSettled(rect.width)
|
||||
@@ -112,7 +118,7 @@ export function OfficePages(props: {
|
||||
if (!scroller || !page || index >= mounted()) return void (pending.target = { index, y })
|
||||
|
||||
pending.target = undefined
|
||||
scroller.scrollTo({ top: page.offsetTop + y * fit(width(), target.width) - padding })
|
||||
scroller.scrollTo({ top: page.offsetTop + y * fit(width(), target.width) })
|
||||
}
|
||||
|
||||
onMount(() => props.onScrollTo?.(scrollTo))
|
||||
@@ -162,34 +168,57 @@ export function OfficePages(props: {
|
||||
})
|
||||
}
|
||||
|
||||
const fit = (available: number, page: number) =>
|
||||
Math.max(0, Math.min(props.maxScale, (available - padding * 2) / page))
|
||||
const fit = (available: number, page: number) => Math.max(0, (available - view.gutter * 2) / page) * view.zoom
|
||||
|
||||
return (
|
||||
<div ref={scroller} data-slot="artifact-stage" class="relative min-h-0 flex-1 overflow-auto">
|
||||
<div class="flex flex-col items-center gap-4 py-6">
|
||||
{/* Keyed by position: a replaced page keeps its row and canvas, and paints over its old bitmap. */}
|
||||
<Index each={shown()}>
|
||||
{(page, index) => (
|
||||
<div class="flex shrink-0 flex-col items-center gap-3">
|
||||
<OfficePage
|
||||
ref={(element) => (pages[index] = element)}
|
||||
watch={watch}
|
||||
index={index}
|
||||
page={page()}
|
||||
scale={fit(width(), page().width)}
|
||||
rasterScale={fit(settled(), page().width)}
|
||||
ratio={ratio()}
|
||||
paint={props.paint}
|
||||
overlay={props.overlay}
|
||||
text={props.text ?? false}
|
||||
label={props.label(index)}
|
||||
/>
|
||||
{props.footer?.(index)}
|
||||
</div>
|
||||
)}
|
||||
</Index>
|
||||
<div class="relative flex min-h-0 flex-1 flex-col">
|
||||
<div
|
||||
ref={scroller}
|
||||
data-slot="artifact-stage"
|
||||
data-document-surface-scrollport
|
||||
class="relative min-h-0 flex-1 overflow-auto"
|
||||
data-scrollable
|
||||
>
|
||||
<div
|
||||
ref={column}
|
||||
data-document-surface-inset
|
||||
data-document-surface-column
|
||||
class="flex w-max min-w-full flex-col items-center gap-4 pb-18"
|
||||
>
|
||||
{/* Keyed by position: a replaced page keeps its row and canvas, and paints over its old bitmap. */}
|
||||
<Index each={shown()}>
|
||||
{(page, index) => (
|
||||
<div class="flex shrink-0 flex-col items-center gap-3">
|
||||
<OfficePage
|
||||
ref={(element) => (pages[index] = element)}
|
||||
watch={watch}
|
||||
index={index}
|
||||
page={page()}
|
||||
scale={fit(width(), page().width)}
|
||||
rasterScale={fit(settled(), page().width)}
|
||||
ratio={ratio()}
|
||||
paint={props.paint}
|
||||
overlay={props.overlay}
|
||||
text={props.text ?? false}
|
||||
label={props.label(index)}
|
||||
/>
|
||||
{props.footer?.(index)}
|
||||
</div>
|
||||
)}
|
||||
</Index>
|
||||
</div>
|
||||
</div>
|
||||
<PreviewControls
|
||||
disabled={width() === 0 || props.pages.length === 0}
|
||||
zoomInDisabled={view.zoom >= 2}
|
||||
zoomOutDisabled={view.zoom <= 0.25}
|
||||
onZoomIn={() => setView("zoom", Math.min(2, view.zoom * 1.25))}
|
||||
onZoomOut={() => setView("zoom", Math.max(0.25, view.zoom / 1.25))}
|
||||
onFit={() => {
|
||||
setView("zoom", 1)
|
||||
scroller?.scrollTo({ left: 0 })
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -216,14 +245,14 @@ function OfficePage(props: {
|
||||
})
|
||||
|
||||
return (
|
||||
<div
|
||||
<DocumentSurface
|
||||
ref={(element) => {
|
||||
frame = element
|
||||
props.ref(element)
|
||||
}}
|
||||
role={props.text ? "group" : undefined}
|
||||
aria-label={props.text ? props.label : undefined}
|
||||
class="relative shrink-0 shadow-[var(--v2-elevation-raised)]"
|
||||
class="shrink-0 overflow-hidden"
|
||||
style={{
|
||||
width: `${props.page.width * props.scale}px`,
|
||||
height: `${props.page.height * props.scale}px`,
|
||||
@@ -252,7 +281,7 @@ function OfficePage(props: {
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
</div>
|
||||
</DocumentSurface>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ export default function OfficePresentation(props: FileViewerProps) {
|
||||
{(opened) => (
|
||||
<OfficePages
|
||||
pages={opened().slides}
|
||||
maxScale={Number.POSITIVE_INFINITY}
|
||||
paint={opened().paint}
|
||||
label={(index) => ctx.t("slide", { number: index + 1 })}
|
||||
overlay={(input) => (
|
||||
|
||||
@@ -990,7 +990,7 @@ function SpreadsheetGrid(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="relative flex min-h-0 flex-1">
|
||||
<div class="relative flex min-h-0 flex-1 border-t border-v2-border-border-muted">
|
||||
{/* Grids keep their column order in right-to-left layouts, as spreadsheet apps do. */}
|
||||
{/* The scroller is the grid screen readers hear: its rows are the block around the active cell, which it points
|
||||
at as the active descendant, while the canvas shows the cells. */}
|
||||
|
||||
@@ -98,15 +98,19 @@ export type IconName =
|
||||
| "outline-browser-annotate"
|
||||
| "outline-chevron-down"
|
||||
| "outline-chevron-right"
|
||||
| "outline-code-brackets"
|
||||
| "outline-console"
|
||||
| "outline-cookie"
|
||||
| "outline-copy"
|
||||
| "outline-dots"
|
||||
| "outline-expand"
|
||||
| "outline-eye"
|
||||
| "outline-eye-slash"
|
||||
| "outline-globe"
|
||||
| "outline-globe-plus"
|
||||
| "outline-hexagonal-warning"
|
||||
| "outline-magnifier-minus"
|
||||
| "outline-magnifier-plus"
|
||||
| "outline-photo"
|
||||
| "outline-quote"
|
||||
| "outline-reset"
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"./dialog": "./src/overlays/dialog/dialog.tsx",
|
||||
"./diff-changes": "./src/data-display/diff-changes/diff-changes.tsx",
|
||||
"./divider": "./src/layout/divider/divider.tsx",
|
||||
"./document-surface.css": "./src/components/document-surface.css",
|
||||
"./field": "./src/forms/field/field.tsx",
|
||||
"./file-tree.css": "./src/styles/file-tree.css",
|
||||
"./icon": "./src/icons/icon/icon.tsx",
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
[data-component="document-surface"] {
|
||||
position: relative;
|
||||
border-radius: 8px;
|
||||
background: var(--v2-background-bg-base);
|
||||
box-shadow: var(--v2-elevation-raised);
|
||||
}
|
||||
|
||||
/* Paint the border above page bitmaps without changing their dimensions or text coordinates. */
|
||||
[data-component="document-surface"]::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* The raised token paints outside the sheet; retain its top edge in flush scrollports. */
|
||||
[data-document-surface-inset] {
|
||||
padding-block-start: 1px;
|
||||
}
|
||||
|
||||
[data-document-surface-scrollport] {
|
||||
--document-surface-gutter: 20px;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
[data-document-surface-column] {
|
||||
padding-inline: var(--document-surface-gutter, 20px);
|
||||
}
|
||||
|
||||
@container (max-width: 600px) {
|
||||
[data-document-surface-scrollport] {
|
||||
--document-surface-gutter: 12px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { JSX } from "solid-js"
|
||||
import "./document-surface.css"
|
||||
|
||||
export function DocumentSurface(props: JSX.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div {...props} data-component="document-surface" />
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
[data-component="preview-controls"] {
|
||||
position: absolute;
|
||||
inset-inline-end: 12px;
|
||||
bottom: 12px;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 4px;
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
border-radius: 8px;
|
||||
background: var(--v2-background-bg-base);
|
||||
box-shadow: var(--v2-elevation-raised);
|
||||
}
|
||||
|
||||
[data-slot="preview-controls-divider"] {
|
||||
width: 0.5px;
|
||||
height: 20px;
|
||||
margin-inline: 4px;
|
||||
background: var(--v2-border-border-base);
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
[data-component="preview-controls"] [data-component="icon-button-v2"] {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { IconButton } from "@opencode/ui/icon-button"
|
||||
import { Tooltip } from "@opencode/ui/tooltip"
|
||||
import { useI18n } from "../context/i18n"
|
||||
import "./preview-controls.css"
|
||||
|
||||
export function PreviewControls(props: {
|
||||
onZoomIn: () => void
|
||||
onZoomOut: () => void
|
||||
onFit: () => void
|
||||
disabled?: boolean
|
||||
zoomInDisabled?: boolean
|
||||
zoomOutDisabled?: boolean
|
||||
}) {
|
||||
const i18n = useI18n()
|
||||
|
||||
return (
|
||||
<div data-component="preview-controls" role="group" aria-label={i18n.t("ui.preview.controls")}>
|
||||
<Tooltip value={i18n.t("ui.preview.zoomIn")} placement="top">
|
||||
<IconButton
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
aria-label={i18n.t("ui.preview.zoomIn")}
|
||||
disabled={props.disabled || props.zoomInDisabled}
|
||||
onClick={props.onZoomIn}
|
||||
icon={<Icon name="outline-magnifier-plus" size="normal" />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<span data-slot="preview-controls-divider" aria-hidden />
|
||||
<Tooltip value={i18n.t("ui.preview.zoomOut")} placement="top">
|
||||
<IconButton
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
aria-label={i18n.t("ui.preview.zoomOut")}
|
||||
disabled={props.disabled || props.zoomOutDisabled}
|
||||
onClick={props.onZoomOut}
|
||||
icon={<Icon name="outline-magnifier-minus" size="normal" />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<span data-slot="preview-controls-divider" aria-hidden />
|
||||
<Tooltip value={i18n.t("ui.preview.fit")} placement="top">
|
||||
<IconButton
|
||||
variant="ghost-muted"
|
||||
size="large"
|
||||
aria-label={i18n.t("ui.preview.fit")}
|
||||
disabled={props.disabled}
|
||||
onClick={props.onFit}
|
||||
icon={<Icon name="outline-expand" size="normal" />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
const source = {
|
||||
"ui.preview.controls": "Preview controls",
|
||||
"ui.preview.zoomIn": "Zoom in",
|
||||
"ui.preview.zoomOut": "Zoom out",
|
||||
"ui.preview.fit": "Fit",
|
||||
"ui.sessionReview.title": "Session changes",
|
||||
"ui.sessionReview.title.git": "Git changes",
|
||||
"ui.sessionReview.title.branch": "Branch changes",
|
||||
|
||||
@@ -70,6 +70,14 @@ const icons = {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M14 14L10.3454 10.3454M6.88889 11.7778C9.58889 11.7778 11.7778 9.58889 11.7778 6.88889C11.7778 4.18889 9.58889 2 6.88889 2C4.18889 2 2 4.18889 2 6.88889C2 9.58889 4.18889 11.7778 6.88889 11.7778Z" stroke="currentColor"/>`,
|
||||
},
|
||||
"outline-magnifier-minus": {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M14 14L11 11M4.66667 7.33333H10M12.6667 7.33333C12.6667 10.2789 10.2789 12.6667 7.33333 12.6667C4.38781 12.6667 2 10.2789 2 7.33333C2 4.38781 4.38781 2 7.33333 2C10.2789 2 12.6667 4.38781 12.6667 7.33333Z" stroke-miterlimit="10" stroke-linecap="square" stroke="currentColor"/>`,
|
||||
},
|
||||
"outline-magnifier-plus": {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M14 14L11 11M4.66667 7.33333H10M7.33333 4.66667V10M12.6667 7.33333C12.6667 10.2789 10.2789 12.6667 7.33333 12.6667C4.38781 12.6667 2 10.2789 2 7.33333C2 4.38781 4.38781 2 7.33333 2C10.2789 2 12.6667 4.38781 12.6667 7.33333Z" stroke-miterlimit="10" stroke-linecap="square" stroke="currentColor"/>`,
|
||||
},
|
||||
menu: {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M2 8H14M2 4.664H14M2 11.336H14" stroke="currentColor"/>`,
|
||||
@@ -150,6 +158,10 @@ const icons = {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M8.25 6.17773V1.17773M11.25 4.17773L8.25 1.17773L5.25 4.17773" stroke="currentColor"/><path d="M8.25 9.17773V14.1777M11.25 11.1777L8.25 14.1777L5.25 11.1777" stroke="currentColor"/><path d="M4.25 7.67773H12.25" stroke="currentColor"/>`,
|
||||
},
|
||||
"outline-expand": {
|
||||
viewBox: "0 0 24 24",
|
||||
body: `<g transform="scale(1.2)" stroke="currentColor" stroke-width="1.25"><path d="M4.58301 10.4163V15.4163H9.58301M10.4163 4.58301H15.4163V9.58301" stroke="currentColor" stroke-linecap="square"/></g>`,
|
||||
},
|
||||
filetree: {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M2.5 1.5V12.2484H6.75M2.5 4.74838H6.75" stroke="currentColor"/><rect x="8.5" y="3.2168" width="6" height="3" fill="none" stroke="currentColor"/><rect x="8.5" y="10.75" width="6" height="3" fill="none" stroke="currentColor"/>`,
|
||||
@@ -178,6 +190,10 @@ const icons = {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path fill-rule="evenodd" clip-rule="evenodd" d="M10.0812 2.10803L6.55974 14.0809L5.92016 13.8928L9.44161 1.91992L10.0812 2.10803ZM4.13793 4.97275L1.44666 8.00045L4.13793 11.0281L3.63966 11.471L0.554688 8.00045L3.63966 4.52984L4.13793 4.97275ZM12.3617 4.52984L15.4467 8.00045L12.3617 11.471L11.8634 11.0281L14.5547 8.00045L11.8634 4.97275L12.3617 4.52984Z" fill="currentColor"/>`,
|
||||
},
|
||||
"outline-code-brackets": {
|
||||
viewBox: "0 0 16 16",
|
||||
body: `<path d="M5 4L1 8L5 12M11 4L15 8L11 12M9 1L7 15" stroke="currentColor"/>`,
|
||||
},
|
||||
trash: {
|
||||
viewBox: "0 0 20 20",
|
||||
body: `<path d="M4.58342 17.9134L4.58369 17.4134L4.22787 17.5384L4.22766 18.0384H4.58342V17.9134ZM15.4167 17.9134V18.0384H15.7725L15.7723 17.5384L15.4167 17.9134ZM2.08342 3.95508V3.45508H1.58342V3.95508H2.08342V4.45508V3.95508ZM17.9167 4.45508V4.95508H18.4167V4.45508H17.9167V3.95508V4.45508ZM4.16677 4.58008L3.66701 4.5996L4.22816 17.5379L4.72792 17.4934L5.22767 17.4489L4.66652 4.54055L4.16677 4.58008ZM4.58342 18.0384V17.9134H15.4167V18.0384V18.5384H4.58342V18.0384ZM15.4167 17.9134L15.8332 17.5379L16.2498 4.5996L15.7501 4.58008L15.2503 4.56055L14.8337 17.4989L15.4167 17.9134ZM15.8334 4.58008V4.08008H4.16677V4.58008V5.08008H15.8334V4.58008ZM2.08342 4.45508V4.95508H4.16677V4.58008V4.08008H2.08342V4.45508ZM15.8334 4.58008V5.08008H17.9167V4.45508V3.95508H15.8334V4.58008ZM6.83951 4.35149L7.432 4.55047C7.79251 3.47701 8.80699 2.70508 10.0001 2.70508V2.20508V1.70508C8.25392 1.70508 6.77335 2.83539 6.24702 4.15251L6.83951 4.35149ZM10.0001 2.20508V2.70508C11.1932 2.70508 12.2077 3.47701 12.5682 4.55047L13.1607 4.35149L13.7532 4.15251C13.2269 2.83539 11.7463 1.70508 10.0001 1.70508V2.20508Z" fill="currentColor"/>`,
|
||||
|
||||
Reference in New Issue
Block a user