Files
outline/shared/editor/nodes/Doc.ts
Tom MoorandApoorv Mishra f7f1f07716 perf: Utilize plugin state in placeholder plugin (#9283)
* perf: Utilize plugin state in placeholder plugin

* perf: Move textContent calculation out of loop

* Update shared/editor/plugins/PlaceholderPlugin.ts

Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>

* Update PlaceholderPlugin.ts

---------

Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
2025-05-23 14:51:09 -04:00

33 lines
743 B
TypeScript

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