fix(editor): do not display format bar with embed node (#11371)
Close [BS-2895: 点击inline名字区域不需要显示format toolbar](https://linear.app/affine-design/issue/BS-2895/点击inline名字区域不需要显示format-toolbar)
This commit is contained in:
@@ -202,8 +202,25 @@ export function getCombinedTextStyle(chain: Chain<InitCommandCtx>) {
|
||||
}
|
||||
|
||||
export function isFormatSupported(chain: Chain<InitCommandCtx>) {
|
||||
return handleCurrentSelection(
|
||||
chain,
|
||||
(_type, inlineEditors) => inlineEditors.length > 0
|
||||
);
|
||||
return handleCurrentSelection(chain, (_type, inlineEditors) => {
|
||||
if (inlineEditors.length === 1) {
|
||||
const inlineEditor = inlineEditors[0];
|
||||
const inlineRange = inlineEditor.getInlineRange();
|
||||
|
||||
// support block selection
|
||||
if (!inlineRange) return true;
|
||||
|
||||
if (inlineRange.length !== 1) return true;
|
||||
|
||||
// skip embed node
|
||||
const delta = inlineEditor.getDeltaByRangeIndex(inlineRange.index + 1);
|
||||
if (!delta) return true;
|
||||
|
||||
const isEmbed = inlineEditor.isEmbed(delta);
|
||||
if (isEmbed) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return inlineEditors.length > 0;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user