@prosekit/extensions 0.7.17 → 0.7.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1706,9 +1706,10 @@ export declare type ModClickPreventionExtension = PlainExtension;
1706
1706
 
1707
1707
  export declare interface PlaceholderOptions {
1708
1708
  /**
1709
- * The placeholder text to use.
1709
+ * The placeholder to use. It can be a static string or a function that
1710
+ * receives the current editor state and returns a string.
1710
1711
  */
1711
- placeholder: string;
1712
+ placeholder: string | ((state: EditorState) => string);
1712
1713
  /**
1713
1714
  * By default, the placeholder text will be shown whenever the current text
1714
1715
  * cursor is in an empty text node. If you only want to show the placeholder
@@ -5,18 +5,21 @@ import { Decoration, DecorationSet } from "@prosekit/pm/view";
5
5
  function definePlaceholder(options) {
6
6
  return definePlugin(createPlaceholderPlugin(options));
7
7
  }
8
- function createPlaceholderPlugin(options) {
8
+ function createPlaceholderPlugin({
9
+ placeholder,
10
+ strategy = "block"
11
+ }) {
9
12
  return new Plugin({
10
13
  key: new PluginKey("prosekit-placeholder"),
11
14
  props: {
12
15
  decorations: (state) => {
13
- if (options.strategy === "doc" && !isDocEmpty(state.doc)) {
16
+ if (strategy === "doc" && !isDocEmpty(state.doc)) {
14
17
  return null;
15
18
  }
16
19
  if (isInCodeBlock(state.selection)) {
17
20
  return null;
18
21
  }
19
- const placeholderText = options.placeholder;
22
+ const placeholderText = typeof placeholder === "function" ? placeholder(state) : placeholder;
20
23
  const deco = createPlaceholderDecoration(state, placeholderText);
21
24
  if (!deco) {
22
25
  return null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.7.17",
4
+ "version": "0.7.18",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -214,7 +214,7 @@
214
214
  "prosemirror-highlight": "^0.9.0",
215
215
  "prosemirror-search": "^1.0.0",
216
216
  "prosemirror-tables": "^1.5.0",
217
- "shiki": "^1.16.2",
217
+ "shiki": "^1.17.7",
218
218
  "@prosekit/core": "^0.7.11",
219
219
  "@prosekit/pm": "^0.1.8"
220
220
  },
@@ -239,17 +239,17 @@
239
239
  }
240
240
  },
241
241
  "devDependencies": {
242
- "@vitest/browser": "^2.0.5",
242
+ "@vitest/browser": "^2.1.2",
243
243
  "just-pick": "^4.2.0",
244
244
  "loro-crdt": "^0.16.12",
245
245
  "loro-prosemirror": "^0.0.7",
246
- "tsup": "^8.2.4",
246
+ "tsup": "^8.3.0",
247
247
  "type-fest": "^4.26.1",
248
- "typescript": "^5.5.4",
249
- "vitest": "^2.0.5",
248
+ "typescript": "^5.6.2",
249
+ "vitest": "^2.1.2",
250
250
  "y-prosemirror": "^1.2.12",
251
251
  "y-protocols": "^1.0.6",
252
- "yjs": "^13.6.18",
252
+ "yjs": "^13.6.19",
253
253
  "@prosekit/dev": "0.0.0"
254
254
  },
255
255
  "scripts": {