New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tiptap/extension-placeholder

Package Overview
Dependencies
Maintainers
6
Versions
192
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/extension-placeholder - npm Package Compare versions

Comparing version 3.0.0-next.4 to 3.0.0-next.5

61

dist/index.d.ts

@@ -1,59 +0,2 @@

import { Editor, Extension } from '@tiptap/core';
import { Node } from '@tiptap/pm/model';
interface PlaceholderOptions {
/**
* **The class name for the empty editor**
* @default 'is-editor-empty'
*/
emptyEditorClass: string;
/**
* **The class name for empty nodes**
* @default 'is-empty'
*/
emptyNodeClass: string;
/**
* **The placeholder content**
*
* You can use a function to return a dynamic placeholder or a string.
* @default 'Write something …'
*/
placeholder: ((PlaceholderProps: {
editor: Editor;
node: Node;
pos: number;
hasAnchor: boolean;
}) => string) | string;
/**
* **Checks if the placeholder should be only shown when the editor is editable.**
*
* If true, the placeholder will only be shown when the editor is editable.
* If false, the placeholder will always be shown.
* @default true
*/
showOnlyWhenEditable: boolean;
/**
* **Checks if the placeholder should be only shown when the current node is empty.**
*
* If true, the placeholder will only be shown when the current node is empty.
* If false, the placeholder will be shown when any node is empty.
* @default true
*/
showOnlyCurrent: boolean;
/**
* **Controls if the placeholder should be shown for all descendents.**
*
* If true, the placeholder will be shown for all descendents.
* If false, the placeholder will only be shown for the current node.
* @default false
*/
includeChildren: boolean;
}
/**
* This extension allows you to add a placeholder to your editor.
* A placeholder is a text that appears when the editor or a node is empty.
* @see https://www.tiptap.dev/api/extensions/placeholder
*/
declare const Placeholder: Extension<PlaceholderOptions, any>;
export { Placeholder, type PlaceholderOptions, Placeholder as default };
import { Placeholder } from '@tiptap/extensions';
export { Placeholder, PlaceholderOptions, Placeholder as default } from '@tiptap/extensions';

@@ -1,65 +0,10 @@

// src/placeholder.ts
import { Extension, isNodeEmpty } from "@tiptap/core";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import { Decoration, DecorationSet } from "@tiptap/pm/view";
var Placeholder = Extension.create({
name: "placeholder",
addOptions() {
return {
emptyEditorClass: "is-editor-empty",
emptyNodeClass: "is-empty",
placeholder: "Write something \u2026",
showOnlyWhenEditable: true,
showOnlyCurrent: true,
includeChildren: false
};
},
addProseMirrorPlugins() {
return [
new Plugin({
key: new PluginKey("placeholder"),
props: {
decorations: ({ doc, selection }) => {
const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
const { anchor } = selection;
const decorations = [];
if (!active) {
return null;
}
const isEmptyDoc = this.editor.isEmpty;
doc.descendants((node, pos) => {
const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
const isEmpty = !node.isLeaf && isNodeEmpty(node);
if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
const classes = [this.options.emptyNodeClass];
if (isEmptyDoc) {
classes.push(this.options.emptyEditorClass);
}
const decoration = Decoration.node(pos, pos + node.nodeSize, {
class: classes.join(" "),
"data-placeholder": typeof this.options.placeholder === "function" ? this.options.placeholder({
editor: this.editor,
node,
pos,
hasAnchor
}) : this.options.placeholder
});
decorations.push(decoration);
}
return this.options.includeChildren;
});
return DecorationSet.create(doc, decorations);
}
}
})
];
}
});
// src/index.ts
import { Placeholder } from "@tiptap/extensions";
import { Placeholder as Placeholder2, PlaceholderOptions } from "@tiptap/extensions";
var index_default = Placeholder;
export {
Placeholder,
Placeholder2 as Placeholder,
PlaceholderOptions,
index_default as default
};
//# sourceMappingURL=index.js.map

2

LICENSE.md
MIT License
Copyright (c) 2024, Tiptap GmbH
Copyright (c) 2025, Tiptap GmbH

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "@tiptap/extension-placeholder",
"description": "placeholder extension for tiptap",
"version": "3.0.0-next.4",
"version": "3.0.0-next.5",
"homepage": "https://tiptap.dev",

@@ -34,8 +34,6 @@ "keywords": [

"devDependencies": {
"@tiptap/core": "^3.0.0-next.4",
"@tiptap/pm": "^3.0.0-next.4"
"@tiptap/extensions": "^3.0.0-next.5"
},
"peerDependencies": {
"@tiptap/core": "^3.0.0-next.1",
"@tiptap/pm": "^3.0.0-next.1"
"@tiptap/extensions": "^3.0.0-next.3"
},

@@ -42,0 +40,0 @@ "repository": {

@@ -1,5 +0,5 @@

import { Placeholder } from './placeholder.js'
import { Placeholder } from '@tiptap/extensions'
export * from './placeholder.js'
export { Placeholder, PlaceholderOptions } from '@tiptap/extensions'
export default Placeholder

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc