mirror of
https://github.com/outline/outline.git
synced 2025-12-21 10:39:41 -06:00
@@ -174,12 +174,12 @@ export default function SelectionToolbar(props: Props) {
|
||||
const { isTemplate, rtl, canComment, canUpdate, ...rest } = props;
|
||||
const { state } = view;
|
||||
const { selection } = state;
|
||||
const isDividerSelection = isNodeActive(state.schema.nodes.hr)(state);
|
||||
|
||||
if ((readOnly && !canComment) || isDragging) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isDividerSelection = isNodeActive(state.schema.nodes.hr)(state);
|
||||
const colIndex = getColumnIndex(state);
|
||||
const rowIndex = getRowIndex(state);
|
||||
const isTableSelection = colIndex !== undefined && rowIndex !== undefined;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeType } from "prosemirror-model";
|
||||
import { EditorState } from "prosemirror-state";
|
||||
import { EditorState, NodeSelection } from "prosemirror-state";
|
||||
import { Primitive } from "utility-types";
|
||||
import { findParentNode } from "./findParentNode";
|
||||
|
||||
@@ -25,12 +25,24 @@ export const isNodeActive =
|
||||
return false;
|
||||
}
|
||||
|
||||
let nodeWithPos;
|
||||
const { from, to } = state.selection;
|
||||
const nodeWithPos = findParentNode(
|
||||
|
||||
if (
|
||||
state.selection instanceof NodeSelection &&
|
||||
state.selection.node.type === type &&
|
||||
state.selection.node.hasMarkup(type, {
|
||||
...state.selection.node.attrs,
|
||||
...attrs,
|
||||
})
|
||||
) {
|
||||
nodeWithPos = { pos: from, node: state.selection.node };
|
||||
}
|
||||
|
||||
nodeWithPos ??= findParentNode(
|
||||
(node) =>
|
||||
node.type === type &&
|
||||
(!attrs ||
|
||||
Object.keys(attrs).every((key) => node.attrs[key] === attrs[key]))
|
||||
(!attrs || node.hasMarkup(type, { ...node.attrs, ...attrs }))
|
||||
)(state.selection);
|
||||
|
||||
if (!nodeWithPos) {
|
||||
|
||||
Reference in New Issue
Block a user