mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
* 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>
33 lines
743 B
TypeScript
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,
|
|
},
|
|
]),
|
|
];
|
|
}
|
|
}
|