在飞书文档中,按钮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[1] ? arguments[1] : {
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[0].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[0];
return o && n.addCurrent(s[0]),
o
}
)),
n.source !== R.F.Destroy && a) {
const e = [R.F.Backspace, R.F.Redo, R.F.Undo, R.F.EditControl];
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[n.source.toLowerCase()],
blocks: s,
click: p.uD.hotkey_action
})
}
))
}
e.prototype.getBlockModelByBlockId = function(e) {
return this._blockIdToBlockModel.get(e)
}
`