@tiptap/extension-placeholder 2.11.7 → 3.0.0-beta.1

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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, Tiptap GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # @tiptap/extension-placeholder
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/extension-placeholder.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-placeholder)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-placeholder.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/extension-placeholder.svg)](https://www.npmjs.com/package/@tiptap/extension-placeholder)
5
6
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
7
 
7
8
  ## Introduction
8
- Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
+
10
+ Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
9
11
 
10
12
  ## Official Documentation
13
+
11
14
  Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
15
 
13
16
  ## License
17
+
14
18
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs CHANGED
@@ -1,72 +1,34 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@tiptap/core');
6
- var state = require('@tiptap/pm/state');
7
- var view = require('@tiptap/pm/view');
8
-
9
- /**
10
- * This extension allows you to add a placeholder to your editor.
11
- * A placeholder is a text that appears when the editor or a node is empty.
12
- * @see https://www.tiptap.dev/api/extensions/placeholder
13
- */
14
- const Placeholder = core.Extension.create({
15
- name: 'placeholder',
16
- addOptions() {
17
- return {
18
- emptyEditorClass: 'is-editor-empty',
19
- emptyNodeClass: 'is-empty',
20
- placeholder: 'Write something …',
21
- showOnlyWhenEditable: true,
22
- showOnlyCurrent: true,
23
- includeChildren: false,
24
- };
25
- },
26
- addProseMirrorPlugins() {
27
- return [
28
- new state.Plugin({
29
- key: new state.PluginKey('placeholder'),
30
- props: {
31
- decorations: ({ doc, selection }) => {
32
- const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
33
- const { anchor } = selection;
34
- const decorations = [];
35
- if (!active) {
36
- return null;
37
- }
38
- const isEmptyDoc = this.editor.isEmpty;
39
- doc.descendants((node, pos) => {
40
- const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
41
- const isEmpty = !node.isLeaf && core.isNodeEmpty(node);
42
- if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
43
- const classes = [this.options.emptyNodeClass];
44
- if (isEmptyDoc) {
45
- classes.push(this.options.emptyEditorClass);
46
- }
47
- const decoration = view.Decoration.node(pos, pos + node.nodeSize, {
48
- class: classes.join(' '),
49
- 'data-placeholder': typeof this.options.placeholder === 'function'
50
- ? this.options.placeholder({
51
- editor: this.editor,
52
- node,
53
- pos,
54
- hasAnchor,
55
- })
56
- : this.options.placeholder,
57
- });
58
- decorations.push(decoration);
59
- }
60
- return this.options.includeChildren;
61
- });
62
- return view.DecorationSet.create(doc, decorations);
63
- },
64
- },
65
- }),
66
- ];
67
- },
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Placeholder: () => import_extensions2.Placeholder,
24
+ default: () => index_default
68
25
  });
69
-
70
- exports.Placeholder = Placeholder;
71
- exports.default = Placeholder;
72
- //# sourceMappingURL=index.cjs.map
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_extensions = require("@tiptap/extensions");
28
+ var import_extensions2 = require("@tiptap/extensions");
29
+ var index_default = import_extensions.Placeholder;
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ Placeholder
33
+ });
34
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/placeholder.ts"],"sourcesContent":["import { Editor, Extension, isNodeEmpty } from '@tiptap/core'\nimport { Node as ProsemirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport interface PlaceholderOptions {\n /**\n * **The class name for the empty editor**\n * @default 'is-editor-empty'\n */\n emptyEditorClass: string\n\n /**\n * **The class name for empty nodes**\n * @default 'is-empty'\n */\n emptyNodeClass: string\n\n /**\n * **The placeholder content**\n *\n * You can use a function to return a dynamic placeholder or a string.\n * @default 'Write something …'\n */\n placeholder:\n | ((PlaceholderProps: {\n editor: Editor\n node: ProsemirrorNode\n pos: number\n hasAnchor: boolean\n }) => string)\n | string\n\n /**\n * See https://github.com/ueberdosis/tiptap/pull/5278 for more information.\n * @deprecated This option is no longer respected and this type will be removed in the next major version.\n */\n considerAnyAsEmpty?: boolean\n\n /**\n * **Checks if the placeholder should be only shown when the editor is editable.**\n *\n * If true, the placeholder will only be shown when the editor is editable.\n * If false, the placeholder will always be shown.\n * @default true\n */\n showOnlyWhenEditable: boolean\n\n /**\n * **Checks if the placeholder should be only shown when the current node is empty.**\n *\n * If true, the placeholder will only be shown when the current node is empty.\n * If false, the placeholder will be shown when any node is empty.\n * @default true\n */\n showOnlyCurrent: boolean\n\n /**\n * **Controls if the placeholder should be shown for all descendents.**\n *\n * If true, the placeholder will be shown for all descendents.\n * If false, the placeholder will only be shown for the current node.\n * @default false\n */\n includeChildren: boolean\n}\n\n/**\n * This extension allows you to add a placeholder to your editor.\n * A placeholder is a text that appears when the editor or a node is empty.\n * @see https://www.tiptap.dev/api/extensions/placeholder\n */\nexport const Placeholder = Extension.create<PlaceholderOptions>({\n name: 'placeholder',\n\n addOptions() {\n return {\n emptyEditorClass: 'is-editor-empty',\n emptyNodeClass: 'is-empty',\n placeholder: 'Write something …',\n showOnlyWhenEditable: true,\n showOnlyCurrent: true,\n includeChildren: false,\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('placeholder'),\n props: {\n decorations: ({ doc, selection }) => {\n const active = this.editor.isEditable || !this.options.showOnlyWhenEditable\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!active) {\n return null\n }\n\n const isEmptyDoc = this.editor.isEmpty\n\n doc.descendants((node, pos) => {\n const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize\n const isEmpty = !node.isLeaf && isNodeEmpty(node)\n\n if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {\n const classes = [this.options.emptyNodeClass]\n\n if (isEmptyDoc) {\n classes.push(this.options.emptyEditorClass)\n }\n\n const decoration = Decoration.node(pos, pos + node.nodeSize, {\n class: classes.join(' '),\n 'data-placeholder':\n typeof this.options.placeholder === 'function'\n ? this.options.placeholder({\n editor: this.editor,\n node,\n pos,\n hasAnchor,\n })\n : this.options.placeholder,\n })\n\n decorations.push(decoration)\n }\n\n return this.options.includeChildren\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":["Extension","Plugin","PluginKey","isNodeEmpty","Decoration","DecorationSet"],"mappings":";;;;;;;;AAmEA;;;;AAIG;AACU,MAAA,WAAW,GAAGA,cAAS,CAAC,MAAM,CAAqB;AAC9D,IAAA,IAAI,EAAE,aAAa;IAEnB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,gBAAgB,EAAE,iBAAiB;AACnC,YAAA,cAAc,EAAE,UAAU;AAC1B,YAAA,WAAW,EAAE,mBAAmB;AAChC,YAAA,oBAAoB,EAAE,IAAI;AAC1B,YAAA,eAAe,EAAE,IAAI;AACrB,YAAA,eAAe,EAAE,KAAK;SACvB;KACF;IAED,qBAAqB,GAAA;QACnB,OAAO;AACL,YAA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OAAO,CAAC,WAAW,CAAC;4CACzB,MAAM,EAAE,IAAI,CAAC,MAAM;4CACnB,IAAI;4CACJ,GAAG;4CACH,SAAS;yCACV;AACD,0CAAE,IAAI,CAAC,OAAO,CAAC,WAAW;AAC/B,iCAAA,CAAC;AAEF,gCAAA,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;;AAG9B,4BAAA,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe;AACrC,yBAAC,CAAC;wBAEF,OAAOC,kBAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC;qBAC9C;AACF,iBAAA;aACF,CAAC;SACH;KACF;AACF,CAAA;;;;;"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Placeholder } from '@tiptap/extensions'\n\nexport type { PlaceholderOptions } from '@tiptap/extensions'\nexport { Placeholder } from '@tiptap/extensions'\n\nexport default Placeholder\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA4B;AAG5B,IAAAA,qBAA4B;AAE5B,IAAO,gBAAQ;","names":["import_extensions"]}
@@ -0,0 +1,2 @@
1
+ import { Placeholder } from '@tiptap/extensions';
2
+ export { Placeholder, PlaceholderOptions, Placeholder as default } from '@tiptap/extensions';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import { Placeholder } from './placeholder.js';
2
- export * from './placeholder.js';
3
- export default Placeholder;
4
- //# sourceMappingURL=index.d.ts.map
1
+ import { Placeholder } from '@tiptap/extensions';
2
+ export { Placeholder, PlaceholderOptions, Placeholder as default } from '@tiptap/extensions';
package/dist/index.js CHANGED
@@ -1,67 +1,9 @@
1
- import { Extension, isNodeEmpty } from '@tiptap/core';
2
- import { Plugin, PluginKey } from '@tiptap/pm/state';
3
- import { Decoration, DecorationSet } from '@tiptap/pm/view';
4
-
5
- /**
6
- * This extension allows you to add a placeholder to your editor.
7
- * A placeholder is a text that appears when the editor or a node is empty.
8
- * @see https://www.tiptap.dev/api/extensions/placeholder
9
- */
10
- const Placeholder = Extension.create({
11
- name: 'placeholder',
12
- addOptions() {
13
- return {
14
- emptyEditorClass: 'is-editor-empty',
15
- emptyNodeClass: 'is-empty',
16
- placeholder: 'Write something …',
17
- showOnlyWhenEditable: true,
18
- showOnlyCurrent: true,
19
- includeChildren: false,
20
- };
21
- },
22
- addProseMirrorPlugins() {
23
- return [
24
- new Plugin({
25
- key: new PluginKey('placeholder'),
26
- props: {
27
- decorations: ({ doc, selection }) => {
28
- const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
29
- const { anchor } = selection;
30
- const decorations = [];
31
- if (!active) {
32
- return null;
33
- }
34
- const isEmptyDoc = this.editor.isEmpty;
35
- doc.descendants((node, pos) => {
36
- const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
37
- const isEmpty = !node.isLeaf && isNodeEmpty(node);
38
- if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
39
- const classes = [this.options.emptyNodeClass];
40
- if (isEmptyDoc) {
41
- classes.push(this.options.emptyEditorClass);
42
- }
43
- const decoration = Decoration.node(pos, pos + node.nodeSize, {
44
- class: classes.join(' '),
45
- 'data-placeholder': typeof this.options.placeholder === 'function'
46
- ? this.options.placeholder({
47
- editor: this.editor,
48
- node,
49
- pos,
50
- hasAnchor,
51
- })
52
- : this.options.placeholder,
53
- });
54
- decorations.push(decoration);
55
- }
56
- return this.options.includeChildren;
57
- });
58
- return DecorationSet.create(doc, decorations);
59
- },
60
- },
61
- }),
62
- ];
63
- },
64
- });
65
-
66
- export { Placeholder, Placeholder as default };
67
- //# sourceMappingURL=index.js.map
1
+ // src/index.ts
2
+ import { Placeholder } from "@tiptap/extensions";
3
+ import { Placeholder as Placeholder2 } from "@tiptap/extensions";
4
+ var index_default = Placeholder;
5
+ export {
6
+ Placeholder2 as Placeholder,
7
+ index_default as default
8
+ };
9
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/placeholder.ts"],"sourcesContent":["import { Editor, Extension, isNodeEmpty } from '@tiptap/core'\nimport { Node as ProsemirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport interface PlaceholderOptions {\n /**\n * **The class name for the empty editor**\n * @default 'is-editor-empty'\n */\n emptyEditorClass: string\n\n /**\n * **The class name for empty nodes**\n * @default 'is-empty'\n */\n emptyNodeClass: string\n\n /**\n * **The placeholder content**\n *\n * You can use a function to return a dynamic placeholder or a string.\n * @default 'Write something …'\n */\n placeholder:\n | ((PlaceholderProps: {\n editor: Editor\n node: ProsemirrorNode\n pos: number\n hasAnchor: boolean\n }) => string)\n | string\n\n /**\n * See https://github.com/ueberdosis/tiptap/pull/5278 for more information.\n * @deprecated This option is no longer respected and this type will be removed in the next major version.\n */\n considerAnyAsEmpty?: boolean\n\n /**\n * **Checks if the placeholder should be only shown when the editor is editable.**\n *\n * If true, the placeholder will only be shown when the editor is editable.\n * If false, the placeholder will always be shown.\n * @default true\n */\n showOnlyWhenEditable: boolean\n\n /**\n * **Checks if the placeholder should be only shown when the current node is empty.**\n *\n * If true, the placeholder will only be shown when the current node is empty.\n * If false, the placeholder will be shown when any node is empty.\n * @default true\n */\n showOnlyCurrent: boolean\n\n /**\n * **Controls if the placeholder should be shown for all descendents.**\n *\n * If true, the placeholder will be shown for all descendents.\n * If false, the placeholder will only be shown for the current node.\n * @default false\n */\n includeChildren: boolean\n}\n\n/**\n * This extension allows you to add a placeholder to your editor.\n * A placeholder is a text that appears when the editor or a node is empty.\n * @see https://www.tiptap.dev/api/extensions/placeholder\n */\nexport const Placeholder = Extension.create<PlaceholderOptions>({\n name: 'placeholder',\n\n addOptions() {\n return {\n emptyEditorClass: 'is-editor-empty',\n emptyNodeClass: 'is-empty',\n placeholder: 'Write something …',\n showOnlyWhenEditable: true,\n showOnlyCurrent: true,\n includeChildren: false,\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('placeholder'),\n props: {\n decorations: ({ doc, selection }) => {\n const active = this.editor.isEditable || !this.options.showOnlyWhenEditable\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!active) {\n return null\n }\n\n const isEmptyDoc = this.editor.isEmpty\n\n doc.descendants((node, pos) => {\n const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize\n const isEmpty = !node.isLeaf && isNodeEmpty(node)\n\n if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {\n const classes = [this.options.emptyNodeClass]\n\n if (isEmptyDoc) {\n classes.push(this.options.emptyEditorClass)\n }\n\n const decoration = Decoration.node(pos, pos + node.nodeSize, {\n class: classes.join(' '),\n 'data-placeholder':\n typeof this.options.placeholder === 'function'\n ? this.options.placeholder({\n editor: this.editor,\n node,\n pos,\n hasAnchor,\n })\n : this.options.placeholder,\n })\n\n decorations.push(decoration)\n }\n\n return this.options.includeChildren\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;;;AAmEA;;;;AAIG;AACU,MAAA,WAAW,GAAG,SAAS,CAAC,MAAM,CAAqB;AAC9D,IAAA,IAAI,EAAE,aAAa;IAEnB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,gBAAgB,EAAE,iBAAiB;AACnC,YAAA,cAAc,EAAE,UAAU;AAC1B,YAAA,WAAW,EAAE,mBAAmB;AAChC,YAAA,oBAAoB,EAAE,IAAI;AAC1B,YAAA,eAAe,EAAE,IAAI;AACrB,YAAA,eAAe,EAAE,KAAK;SACvB;KACF;IAED,qBAAqB,GAAA;QACnB,OAAO;AACL,YAAA,IAAI,MAAM,CAAC;AACT,gBAAA,GAAG,EAAE,IAAI,SAAS,CAAC,aAAa,CAAC;AACjC,gBAAA,KAAK,EAAE;oBACL,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAI;AAClC,wBAAA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AA,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;;AAG9B,4BAAA,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe;AACrC,yBAAC,CAAC;wBAEF,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC;qBAC9C;AACF,iBAAA;aACF,CAAC;SACH;KACF;AACF,CAAA;;;;"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Placeholder } from '@tiptap/extensions'\n\nexport type { PlaceholderOptions } from '@tiptap/extensions'\nexport { Placeholder } from '@tiptap/extensions'\n\nexport default Placeholder\n"],"mappings":";AAAA,SAAS,mBAAmB;AAG5B,SAAS,eAAAA,oBAAmB;AAE5B,IAAO,gBAAQ;","names":["Placeholder"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-placeholder",
3
3
  "description": "placeholder extension for tiptap",
4
- "version": "2.11.7",
4
+ "version": "3.0.0-beta.1",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,34 +15,34 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/index.d.ts",
18
+ "types": {
19
+ "import": "./dist/index.d.ts",
20
+ "require": "./dist/index.d.cts"
21
+ },
19
22
  "import": "./dist/index.js",
20
23
  "require": "./dist/index.cjs"
21
24
  }
22
25
  },
23
26
  "main": "dist/index.cjs",
24
27
  "module": "dist/index.js",
25
- "umd": "dist/index.umd.js",
26
28
  "types": "dist/index.d.ts",
27
29
  "files": [
28
30
  "src",
29
31
  "dist"
30
32
  ],
31
33
  "devDependencies": {
32
- "@tiptap/core": "^2.11.7",
33
- "@tiptap/pm": "^2.11.7"
34
+ "@tiptap/extensions": "^3.0.0-beta.1"
34
35
  },
35
36
  "peerDependencies": {
36
- "@tiptap/core": "^2.7.0",
37
- "@tiptap/pm": "^2.7.0"
37
+ "@tiptap/extensions": "^3.0.0-beta.0"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
41
41
  "url": "https://github.com/ueberdosis/tiptap",
42
- "directory": "packages/extension-placeholder"
42
+ "directory": "packages-deprecated/extension-placeholder"
43
43
  },
44
44
  "scripts": {
45
- "clean": "rm -rf dist",
46
- "build": "npm run clean && rollup -c"
45
+ "build": "tsup",
46
+ "lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
47
47
  }
48
- }
48
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { Placeholder } from './placeholder.js'
1
+ import { Placeholder } from '@tiptap/extensions'
2
2
 
3
- export * from './placeholder.js'
3
+ export type { PlaceholderOptions } from '@tiptap/extensions'
4
+ export { Placeholder } from '@tiptap/extensions'
4
5
 
5
6
  export default Placeholder
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,cAAc,kBAAkB,CAAA;AAEhC,eAAe,WAAW,CAAA"}
package/dist/index.umd.js DELETED
@@ -1,74 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/state'), require('@tiptap/pm/view')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/state', '@tiptap/pm/view'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-placeholder"] = {}, global.core, global.state, global.view));
5
- })(this, (function (exports, core, state, view) { 'use strict';
6
-
7
- /**
8
- * This extension allows you to add a placeholder to your editor.
9
- * A placeholder is a text that appears when the editor or a node is empty.
10
- * @see https://www.tiptap.dev/api/extensions/placeholder
11
- */
12
- const Placeholder = core.Extension.create({
13
- name: 'placeholder',
14
- addOptions() {
15
- return {
16
- emptyEditorClass: 'is-editor-empty',
17
- emptyNodeClass: 'is-empty',
18
- placeholder: 'Write something …',
19
- showOnlyWhenEditable: true,
20
- showOnlyCurrent: true,
21
- includeChildren: false,
22
- };
23
- },
24
- addProseMirrorPlugins() {
25
- return [
26
- new state.Plugin({
27
- key: new state.PluginKey('placeholder'),
28
- props: {
29
- decorations: ({ doc, selection }) => {
30
- const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
31
- const { anchor } = selection;
32
- const decorations = [];
33
- if (!active) {
34
- return null;
35
- }
36
- const isEmptyDoc = this.editor.isEmpty;
37
- doc.descendants((node, pos) => {
38
- const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
39
- const isEmpty = !node.isLeaf && core.isNodeEmpty(node);
40
- if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
41
- const classes = [this.options.emptyNodeClass];
42
- if (isEmptyDoc) {
43
- classes.push(this.options.emptyEditorClass);
44
- }
45
- const decoration = view.Decoration.node(pos, pos + node.nodeSize, {
46
- class: classes.join(' '),
47
- 'data-placeholder': typeof this.options.placeholder === 'function'
48
- ? this.options.placeholder({
49
- editor: this.editor,
50
- node,
51
- pos,
52
- hasAnchor,
53
- })
54
- : this.options.placeholder,
55
- });
56
- decorations.push(decoration);
57
- }
58
- return this.options.includeChildren;
59
- });
60
- return view.DecorationSet.create(doc, decorations);
61
- },
62
- },
63
- }),
64
- ];
65
- },
66
- });
67
-
68
- exports.Placeholder = Placeholder;
69
- exports.default = Placeholder;
70
-
71
- Object.defineProperty(exports, '__esModule', { value: true });
72
-
73
- }));
74
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/placeholder.ts"],"sourcesContent":["import { Editor, Extension, isNodeEmpty } from '@tiptap/core'\nimport { Node as ProsemirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport interface PlaceholderOptions {\n /**\n * **The class name for the empty editor**\n * @default 'is-editor-empty'\n */\n emptyEditorClass: string\n\n /**\n * **The class name for empty nodes**\n * @default 'is-empty'\n */\n emptyNodeClass: string\n\n /**\n * **The placeholder content**\n *\n * You can use a function to return a dynamic placeholder or a string.\n * @default 'Write something …'\n */\n placeholder:\n | ((PlaceholderProps: {\n editor: Editor\n node: ProsemirrorNode\n pos: number\n hasAnchor: boolean\n }) => string)\n | string\n\n /**\n * See https://github.com/ueberdosis/tiptap/pull/5278 for more information.\n * @deprecated This option is no longer respected and this type will be removed in the next major version.\n */\n considerAnyAsEmpty?: boolean\n\n /**\n * **Checks if the placeholder should be only shown when the editor is editable.**\n *\n * If true, the placeholder will only be shown when the editor is editable.\n * If false, the placeholder will always be shown.\n * @default true\n */\n showOnlyWhenEditable: boolean\n\n /**\n * **Checks if the placeholder should be only shown when the current node is empty.**\n *\n * If true, the placeholder will only be shown when the current node is empty.\n * If false, the placeholder will be shown when any node is empty.\n * @default true\n */\n showOnlyCurrent: boolean\n\n /**\n * **Controls if the placeholder should be shown for all descendents.**\n *\n * If true, the placeholder will be shown for all descendents.\n * If false, the placeholder will only be shown for the current node.\n * @default false\n */\n includeChildren: boolean\n}\n\n/**\n * This extension allows you to add a placeholder to your editor.\n * A placeholder is a text that appears when the editor or a node is empty.\n * @see https://www.tiptap.dev/api/extensions/placeholder\n */\nexport const Placeholder = Extension.create<PlaceholderOptions>({\n name: 'placeholder',\n\n addOptions() {\n return {\n emptyEditorClass: 'is-editor-empty',\n emptyNodeClass: 'is-empty',\n placeholder: 'Write something …',\n showOnlyWhenEditable: true,\n showOnlyCurrent: true,\n includeChildren: false,\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('placeholder'),\n props: {\n decorations: ({ doc, selection }) => {\n const active = this.editor.isEditable || !this.options.showOnlyWhenEditable\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!active) {\n return null\n }\n\n const isEmptyDoc = this.editor.isEmpty\n\n doc.descendants((node, pos) => {\n const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize\n const isEmpty = !node.isLeaf && isNodeEmpty(node)\n\n if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {\n const classes = [this.options.emptyNodeClass]\n\n if (isEmptyDoc) {\n classes.push(this.options.emptyEditorClass)\n }\n\n const decoration = Decoration.node(pos, pos + node.nodeSize, {\n class: classes.join(' '),\n 'data-placeholder':\n typeof this.options.placeholder === 'function'\n ? this.options.placeholder({\n editor: this.editor,\n node,\n pos,\n hasAnchor,\n })\n : this.options.placeholder,\n })\n\n decorations.push(decoration)\n }\n\n return this.options.includeChildren\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":["Extension","Plugin","PluginKey","isNodeEmpty","Decoration","DecorationSet"],"mappings":";;;;;;EAmEA;;;;EAIG;AACU,QAAA,WAAW,GAAGA,cAAS,CAAC,MAAM,CAAqB;EAC9D,IAAA,IAAI,EAAE,aAAa;MAEnB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,gBAAgB,EAAE,iBAAiB;EACnC,YAAA,cAAc,EAAE,UAAU;EAC1B,YAAA,WAAW,EAAE,mBAAmB;EAChC,YAAA,oBAAoB,EAAE,IAAI;EAC1B,YAAA,eAAe,EAAE,IAAI;EACrB,YAAA,eAAe,EAAE,KAAK;WACvB;OACF;MAED,qBAAqB,GAAA;UACnB,OAAO;EACL,YAAA,IAAIC,YAAM,CAAC;EACT,gBAAA,GAAG,EAAE,IAAIC,eAAS,CAAC,aAAa,CAAC;EACjC,gBAAA,KAAK,EAAE;sBACL,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAI;EAClC,wBAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB;EAC3E,wBAAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS;0BAC5B,MAAM,WAAW,GAAiB,EAAE;0BAEpC,IAAI,CAAC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;eACF,CAAC;WACH;OACF;EACF,CAAA;;;;;;;;;;;"}
@@ -1,62 +0,0 @@
1
- import { Editor, Extension } from '@tiptap/core';
2
- import { Node as ProsemirrorNode } from '@tiptap/pm/model';
3
- export interface PlaceholderOptions {
4
- /**
5
- * **The class name for the empty editor**
6
- * @default 'is-editor-empty'
7
- */
8
- emptyEditorClass: string;
9
- /**
10
- * **The class name for empty nodes**
11
- * @default 'is-empty'
12
- */
13
- emptyNodeClass: string;
14
- /**
15
- * **The placeholder content**
16
- *
17
- * You can use a function to return a dynamic placeholder or a string.
18
- * @default 'Write something …'
19
- */
20
- placeholder: ((PlaceholderProps: {
21
- editor: Editor;
22
- node: ProsemirrorNode;
23
- pos: number;
24
- hasAnchor: boolean;
25
- }) => string) | string;
26
- /**
27
- * See https://github.com/ueberdosis/tiptap/pull/5278 for more information.
28
- * @deprecated This option is no longer respected and this type will be removed in the next major version.
29
- */
30
- considerAnyAsEmpty?: boolean;
31
- /**
32
- * **Checks if the placeholder should be only shown when the editor is editable.**
33
- *
34
- * If true, the placeholder will only be shown when the editor is editable.
35
- * If false, the placeholder will always be shown.
36
- * @default true
37
- */
38
- showOnlyWhenEditable: boolean;
39
- /**
40
- * **Checks if the placeholder should be only shown when the current node is empty.**
41
- *
42
- * If true, the placeholder will only be shown when the current node is empty.
43
- * If false, the placeholder will be shown when any node is empty.
44
- * @default true
45
- */
46
- showOnlyCurrent: boolean;
47
- /**
48
- * **Controls if the placeholder should be shown for all descendents.**
49
- *
50
- * If true, the placeholder will be shown for all descendents.
51
- * If false, the placeholder will only be shown for the current node.
52
- * @default false
53
- */
54
- includeChildren: boolean;
55
- }
56
- /**
57
- * This extension allows you to add a placeholder to your editor.
58
- * A placeholder is a text that appears when the editor or a node is empty.
59
- * @see https://www.tiptap.dev/api/extensions/placeholder
60
- */
61
- export declare const Placeholder: Extension<PlaceholderOptions, any>;
62
- //# sourceMappingURL=placeholder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"placeholder.d.ts","sourceRoot":"","sources":["../src/placeholder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAe,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAI1D,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAA;IAExB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAA;IAEtB;;;;;OAKG;IACH,WAAW,EACP,CAAC,CAAC,gBAAgB,EAAE;QAClB,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,eAAe,CAAA;QACrB,GAAG,EAAE,MAAM,CAAA;QACX,SAAS,EAAE,OAAO,CAAA;KACnB,KAAK,MAAM,CAAC,GACb,MAAM,CAAA;IAEV;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B;;;;;;OAMG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAE7B;;;;;;OAMG;IACH,eAAe,EAAE,OAAO,CAAA;IAExB;;;;;;OAMG;IACH,eAAe,EAAE,OAAO,CAAA;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,oCAkEtB,CAAA"}
@@ -1,139 +0,0 @@
1
- import { Editor, Extension, isNodeEmpty } from '@tiptap/core'
2
- import { Node as ProsemirrorNode } from '@tiptap/pm/model'
3
- import { Plugin, PluginKey } from '@tiptap/pm/state'
4
- import { Decoration, DecorationSet } from '@tiptap/pm/view'
5
-
6
- export interface PlaceholderOptions {
7
- /**
8
- * **The class name for the empty editor**
9
- * @default 'is-editor-empty'
10
- */
11
- emptyEditorClass: string
12
-
13
- /**
14
- * **The class name for empty nodes**
15
- * @default 'is-empty'
16
- */
17
- emptyNodeClass: string
18
-
19
- /**
20
- * **The placeholder content**
21
- *
22
- * You can use a function to return a dynamic placeholder or a string.
23
- * @default 'Write something …'
24
- */
25
- placeholder:
26
- | ((PlaceholderProps: {
27
- editor: Editor
28
- node: ProsemirrorNode
29
- pos: number
30
- hasAnchor: boolean
31
- }) => string)
32
- | string
33
-
34
- /**
35
- * See https://github.com/ueberdosis/tiptap/pull/5278 for more information.
36
- * @deprecated This option is no longer respected and this type will be removed in the next major version.
37
- */
38
- considerAnyAsEmpty?: boolean
39
-
40
- /**
41
- * **Checks if the placeholder should be only shown when the editor is editable.**
42
- *
43
- * If true, the placeholder will only be shown when the editor is editable.
44
- * If false, the placeholder will always be shown.
45
- * @default true
46
- */
47
- showOnlyWhenEditable: boolean
48
-
49
- /**
50
- * **Checks if the placeholder should be only shown when the current node is empty.**
51
- *
52
- * If true, the placeholder will only be shown when the current node is empty.
53
- * If false, the placeholder will be shown when any node is empty.
54
- * @default true
55
- */
56
- showOnlyCurrent: boolean
57
-
58
- /**
59
- * **Controls if the placeholder should be shown for all descendents.**
60
- *
61
- * If true, the placeholder will be shown for all descendents.
62
- * If false, the placeholder will only be shown for the current node.
63
- * @default false
64
- */
65
- includeChildren: boolean
66
- }
67
-
68
- /**
69
- * This extension allows you to add a placeholder to your editor.
70
- * A placeholder is a text that appears when the editor or a node is empty.
71
- * @see https://www.tiptap.dev/api/extensions/placeholder
72
- */
73
- export const Placeholder = Extension.create<PlaceholderOptions>({
74
- name: 'placeholder',
75
-
76
- addOptions() {
77
- return {
78
- emptyEditorClass: 'is-editor-empty',
79
- emptyNodeClass: 'is-empty',
80
- placeholder: 'Write something …',
81
- showOnlyWhenEditable: true,
82
- showOnlyCurrent: true,
83
- includeChildren: false,
84
- }
85
- },
86
-
87
- addProseMirrorPlugins() {
88
- return [
89
- new Plugin({
90
- key: new PluginKey('placeholder'),
91
- props: {
92
- decorations: ({ doc, selection }) => {
93
- const active = this.editor.isEditable || !this.options.showOnlyWhenEditable
94
- const { anchor } = selection
95
- const decorations: Decoration[] = []
96
-
97
- if (!active) {
98
- return null
99
- }
100
-
101
- const isEmptyDoc = this.editor.isEmpty
102
-
103
- doc.descendants((node, pos) => {
104
- const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize
105
- const isEmpty = !node.isLeaf && isNodeEmpty(node)
106
-
107
- if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
108
- const classes = [this.options.emptyNodeClass]
109
-
110
- if (isEmptyDoc) {
111
- classes.push(this.options.emptyEditorClass)
112
- }
113
-
114
- const decoration = Decoration.node(pos, pos + node.nodeSize, {
115
- class: classes.join(' '),
116
- 'data-placeholder':
117
- typeof this.options.placeholder === 'function'
118
- ? this.options.placeholder({
119
- editor: this.editor,
120
- node,
121
- pos,
122
- hasAnchor,
123
- })
124
- : this.options.placeholder,
125
- })
126
-
127
- decorations.push(decoration)
128
- }
129
-
130
- return this.options.includeChildren
131
- })
132
-
133
- return DecorationSet.create(doc, decorations)
134
- },
135
- },
136
- }),
137
- ]
138
- },
139
- })