`@effect/ui` (Effect-TS/ui): add `files` to the `paste` payload, as `drop` has
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Read packages/ui/src/html/Html.ts around the PastePayload definition and packages/ui/src/html/internal/payload.ts where paste data is read; compare those paths with the drop payload handling. The issue proposes adding clipboardData.files and a handler test using a File; an open linked pull request (#641) indicates work is already underway.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Written with Claude Code for @magoz, from an app we're building on Effect UI.
What is the problem this feature would solve?
Pasting an image copied from somewhere else into a chat composer can't be heard through Html's paste event. PastePayload is the clipboard's plain text only (Html.ts#L430-L442), and the host reads nothing else from clipboardData (payload.ts#L100-L107, #L253-L254). The other two ways a user hands an app files both carry them: DropPayload has files (Html.ts#L541-L565), and so does InputPayload for a file input (Html.ts#L403-L428).
So our composer takes drops and the file picker through the view, and pastes through a Mount with its own listener:
/** Hears files pasted into the composer (an image copied from elsewhere): the text stays text. */
export const TrackPaste = Mount.makeStream(
"TrackPaste",
{ args: { disabled: Schema.Boolean } },
(node: HTMLElement, initial, changes) =>
Stream.callback<ReadonlyArray<File>>((queue) =>
Effect.gen(function*() {
let disabled = initial.disabled
const paste = (event: ClipboardEvent) => {
const files = Array.from(event.clipboardData?.files ?? [])
if (disabled || files.length === 0) return
event.preventDefault()
Queue.offerUnsafe(queue, files)
}
yield* Effect.acquireRelease(
Effect.sync(() => node.addEventListener("paste", paste)),
() => Effect.sync(() => node.removeEventListener("paste", paste))
)
yield* Stream.runForEach(changes, (args) => Effect.sync(() => (disabled = args.disabled)))
.pipe(Effect.forkScoped)
})
)
)
That's about 25 lines for one event, a disabled arg the Mount has to track by hand, and a listener the view's tests can't reach: Locator.fire(el, "paste", { text }) goes to the view's paste handler, not to the Mount, so only our Playwright test covers it, dispatching a DOM ClipboardEvent.
Checked on Effect-TS/ui main at dec1ca9. It was item 7 of Effect-TS/ui#315 and item 6 of Effect-TS/ui#532, with no change since, and we found no other issue or PR about it in either repository. Filed here as Effect-TS/ui#593 asks.
What is the feature you are proposing to solve the problem?
Add files to PastePayload, read from clipboardData.files as drop reads dataTransfer.files, empty when the clipboard holds none:
export interface PastePayload {
readonly text: string
readonly files: ReadonlyArray<File>
}
The rest already fits. A handler returning undefined ignores the event, so with { preventDefault: true } a view cancels only the pastes that carry files and lets text paste as usual:
h.textarea
.on("paste", ({ files }) => files.length > 0 ? Msg.PastedFiles({ files }) : undefined, {
preventDefault: true
})
PastePayload's doc could take DropPayload's note: a File isn't plain data, so send it on to a Command and keep plain facts about it in the Model. A test then fires { text: "", files: [new File(["x"], "a.png")] } at the handler, as HtmlScene's drop step takes files.
What alternatives have you considered?
The Mount above. It works, but every app that takes pasted images writes it, outside the view and its tests. HtmlSubscription.onDocument doesn't list paste, and a document listener would hear pastes anywhere on the page anyway.
- Ngôn ngữ chính
- TypeScript
- Star
- 16.7k
- Fork
- 808
- Merge trung bình
- 21 giờ 22 phút
- Pull request đã merge (30 ngày)
- 486
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Effect-TS/effect
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`@effect/ui-native` (Effect-TS/ui): `kit/VirtualList` `list` part widens `R` to `any`, poisoning enclosing componentsCó thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#11097 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`@effect/ui-native` (Effect-TS/ui): Controlled `input` rejected-edit restore never calls `host.commit()`Có thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#11096 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Effect-TS/effect
Issue tương tự
-
check:failed streams:edit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
iptv-org/iptv#60585 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Critical path skips a child span that ends exactly when the next one startsCó thể đã có người làm @Piyush4801 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jaegertracing/jaeger-ui#4865 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
anthropics/claude-code#112972 ·
-
Type: Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày