add toString to Selection

This commit is contained in:
Muki Kiboigo
2026-01-16 00:55:27 -08:00
parent 992a8e8774
commit 80dd590e8f

View File

@@ -378,6 +378,11 @@ pub fn collapse(self: *Selection, _node: ?*Node, _offset: ?u32, page: *Page) !vo
self._direction = .none; self._direction = .none;
} }
pub fn toString(self: *const Selection, page: *Page) ![]const u8 {
const range = self._range orelse return "";
return try range.toString(page);
}
pub const JsApi = struct { pub const JsApi = struct {
pub const bridge = js.Bridge(Selection); pub const bridge = js.Bridge(Selection);
@@ -412,6 +417,7 @@ pub const JsApi = struct {
pub const selectAllChildren = bridge.function(Selection.selectAllChildren, .{}); pub const selectAllChildren = bridge.function(Selection.selectAllChildren, .{});
pub const setBaseAndExtent = bridge.function(Selection.setBaseAndExtent, .{ .dom_exception = true }); pub const setBaseAndExtent = bridge.function(Selection.setBaseAndExtent, .{ .dom_exception = true });
pub const setPosition = bridge.function(Selection.collapse, .{}); pub const setPosition = bridge.function(Selection.collapse, .{});
pub const toString = bridge.function(Selection.toString, .{});
}; };
const testing = @import("../../testing.zig"); const testing = @import("../../testing.zig");