飞书文档的全选js函数
在飞书文档中,按钮control+a,会把文档内容全选,我想用js在页面插入一个按钮,点击按钮来完成这个动作,找到了部分代码,但不知道该怎么改写调用。哪位师兄帮忙指导一下。文档地址https://langgptai.feishu.cn/wiki/RXdbwRyASiShtDky381ciwFEnpe?hideSider=1&hideHeader=1
部分代码如下
`//selectAll(e) 这里传入的e是个对象{source: 'KeyboardSelectAll'}。
selectAll(e) {
let {rootBlockId: n} = this.blockManager;
if ((0,
b.UN)()) {
const e = (0,
b.tO)(this.blockManager);
if (!e)
return;
n = e.id
}
const {children: o} = this.blockManager.getBlockModelByBlockId(n)
, r = (0,
T.mQ)(o.map((e=>e.id)), this.blockManager);
this.setSelection(r, e)
}
setSelection(e) {
let n = arguments.length > 1 && void 0 !== arguments ? arguments : {
source: R.F.ExternalInvoke,
syncBrowser: !0,
force: !1
};
const {syncBrowser: o=!0, force: r=!1, shouldNotify: i=!0} = n;
let s = (0,
l.default)(e);
s = this.mainSelectionType.filterUnValidSelect(s, this.blockManager),
this.extendSelectionTypes.forEach((e=>{
s = e.filterUnValidSelect(s)
}
));
const c = this.getSelection();
if ((0,
d.default)(s, c))
return void (r && this.updateBrowserSelection());
if (!s.length)
return this.clearExtendInternalSelection(c),
this.store.transaction((()=>{
this.setContext(s, n),
this.store.stored = []
}
), o, i),
void (o && this.updateBrowserSelection());
const a = this.store.isBlockSelection(s);
this.mainSelectionType.onBeforeSet(s),
this.extendSelectionTypes.forEach((e=>{
e.onBeforeSet(s)
}
));
const f = [];
a || f.push(s.id),
this.clearExtendInternalSelection(c, f),
this.store.transaction((()=>{
this.setContext(s, n),
this.store.stored = s;
const e = (0,
u.Z)(s.map((e=>e.type)));
if (this.extendSelectionTypes.some((n=>{
const o = n.type === e;
return o && n.addCurrent(s),
o
}
)),
n.source !== R.F.Destroy && a) {
const e = ;
h.ZP.isMobile && e.includes(n.source) && this.setHiddenInputDomReadOnly(!1),
this.setFocusInHiddenInputDom(!0),
h.ZP.isIOS && this.setHiddenInputDomReadOnly(!0)
}
}
), o, i),
n.source !== R.F.Redo && n.source !== R.F.Undo || (0,
g.K)((()=>{
(0,
p.wC)({
actionObject: a ? _.Xu.BLOCK : _.Xu.TEXT,
source: p.PO.content_page,
blockManager: this.blockManager,
actionType: p.uH,
blocks: s,
click: p.uD.hotkey_action
})
}
))
}
e.prototype.getBlockModelByBlockId = function(e) {
return this._blockIdToBlockModel.get(e)
}
`
哥哥不如换个思路
Selector他也是用的dom元素
我们为什么一定要调用官方的
干脆直接调用网页的select全选api函数可能也可以实现? 好的,我去试试,感谢哥哥 李恒道 发表于 2024-7-23 23:26
哥哥不如换个思路
Selector他也是用的dom元素
我们为什么一定要调用官方的
好的,我去试试,感谢哥哥
页:
[1]