Files
outline/shared/editor/nodes/Doc.ts
T
Tom Moor 8c716b173a chore: Update editor generics (#12247)
* chore: Update editor generics

* fix: Address PR review on editor generics

- Restore null-guard on Link click handler so anchors aren't inert when no onClickLink is provided
- Mark onClickLink optional in LinkOptions and openLink command to match runtime
- Remove dead `collapsed` option from HeadingOptions
- Make ToggleBlock dictionary optional and restore optional-chained access for server-side schema instantiation

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-02 18:54:27 -04:00

42 lines
947 B
TypeScript

import isNull from "lodash/isNull";
import type { NodeSpec } from "prosemirror-model";
import { PlaceholderPlugin } from "../plugins/PlaceholderPlugin";
import Node from "./Node";
/**
* Options for the Doc node.
*/
type DocOptions = {
/** Placeholder text shown when the document is empty. */
placeholder: string;
};
export default class Doc extends Node<DocOptions> {
get name() {
return "doc";
}
get schema(): NodeSpec {
return {
content: "block+",
};
}
get plugins() {
return [
new PlaceholderPlugin([
{
condition: ({ $start, parent, node, state, textContent }) =>
textContent === "" &&
!isNull(parent) &&
parent.type === state.doc.type &&
parent.childCount === 1 &&
node.childCount === 0 &&
$start.index($start.depth - 1) === 0,
text: this.options.placeholder,
},
]),
];
}
}