fix: resolve TypeScript errors in frontend build
This commit is contained in:
99
node_modules/@tiptap/extensions/dist/placeholder/index.cjs
generated
vendored
Normal file
99
node_modules/@tiptap/extensions/dist/placeholder/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/placeholder/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
Placeholder: () => Placeholder,
|
||||
preparePlaceholderAttribute: () => preparePlaceholderAttribute
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
// src/placeholder/placeholder.ts
|
||||
var import_core = require("@tiptap/core");
|
||||
var import_state = require("@tiptap/pm/state");
|
||||
var import_view = require("@tiptap/pm/view");
|
||||
var DEFAULT_DATA_ATTRIBUTE = "placeholder";
|
||||
function preparePlaceholderAttribute(attr) {
|
||||
return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
||||
}
|
||||
var Placeholder = import_core.Extension.create({
|
||||
name: "placeholder",
|
||||
addOptions() {
|
||||
return {
|
||||
emptyEditorClass: "is-editor-empty",
|
||||
emptyNodeClass: "is-empty",
|
||||
dataAttribute: DEFAULT_DATA_ATTRIBUTE,
|
||||
placeholder: "Write something \u2026",
|
||||
showOnlyWhenEditable: true,
|
||||
showOnlyCurrent: true,
|
||||
includeChildren: false
|
||||
};
|
||||
},
|
||||
addProseMirrorPlugins() {
|
||||
const dataAttribute = this.options.dataAttribute ? `data-${preparePlaceholderAttribute(this.options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
|
||||
return [
|
||||
new import_state.Plugin({
|
||||
key: new import_state.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 && (0, import_core.isNodeEmpty)(node);
|
||||
if (!node.type.isTextblock) {
|
||||
return this.options.includeChildren;
|
||||
}
|
||||
if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
|
||||
const classes = [this.options.emptyNodeClass];
|
||||
if (isEmptyDoc) {
|
||||
classes.push(this.options.emptyEditorClass);
|
||||
}
|
||||
const decoration = import_view.Decoration.node(pos, pos + node.nodeSize, {
|
||||
class: classes.join(" "),
|
||||
[dataAttribute]: 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 import_view.DecorationSet.create(doc, decorations);
|
||||
}
|
||||
}
|
||||
})
|
||||
];
|
||||
}
|
||||
});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Placeholder,
|
||||
preparePlaceholderAttribute
|
||||
});
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
1
node_modules/@tiptap/extensions/dist/placeholder/index.cjs.map
generated
vendored
Normal file
1
node_modules/@tiptap/extensions/dist/placeholder/index.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
71
node_modules/@tiptap/extensions/dist/placeholder/index.d.cts
generated
vendored
Normal file
71
node_modules/@tiptap/extensions/dist/placeholder/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { Editor, Extension } from '@tiptap/core';
|
||||
import { Node } from '@tiptap/pm/model';
|
||||
|
||||
/**
|
||||
* Prepares the placeholder attribute by ensuring it is properly formatted.
|
||||
* @param attr - The placeholder attribute string.
|
||||
* @returns The prepared placeholder attribute string.
|
||||
*/
|
||||
declare function preparePlaceholderAttribute(attr: string): string;
|
||||
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 data-attribute used for the placeholder label**
|
||||
* Will be prepended with `data-` and converted to kebab-case and cleaned of special characters.
|
||||
* @default 'placeholder'
|
||||
*/
|
||||
dataAttribute: 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, preparePlaceholderAttribute };
|
||||
71
node_modules/@tiptap/extensions/dist/placeholder/index.d.ts
generated
vendored
Normal file
71
node_modules/@tiptap/extensions/dist/placeholder/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { Editor, Extension } from '@tiptap/core';
|
||||
import { Node } from '@tiptap/pm/model';
|
||||
|
||||
/**
|
||||
* Prepares the placeholder attribute by ensuring it is properly formatted.
|
||||
* @param attr - The placeholder attribute string.
|
||||
* @returns The prepared placeholder attribute string.
|
||||
*/
|
||||
declare function preparePlaceholderAttribute(attr: string): string;
|
||||
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 data-attribute used for the placeholder label**
|
||||
* Will be prepended with `data-` and converted to kebab-case and cleaned of special characters.
|
||||
* @default 'placeholder'
|
||||
*/
|
||||
dataAttribute: 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, preparePlaceholderAttribute };
|
||||
71
node_modules/@tiptap/extensions/dist/placeholder/index.js
generated
vendored
Normal file
71
node_modules/@tiptap/extensions/dist/placeholder/index.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// src/placeholder/placeholder.ts
|
||||
import { Extension, isNodeEmpty } from "@tiptap/core";
|
||||
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
||||
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
||||
var DEFAULT_DATA_ATTRIBUTE = "placeholder";
|
||||
function preparePlaceholderAttribute(attr) {
|
||||
return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
||||
}
|
||||
var Placeholder = Extension.create({
|
||||
name: "placeholder",
|
||||
addOptions() {
|
||||
return {
|
||||
emptyEditorClass: "is-editor-empty",
|
||||
emptyNodeClass: "is-empty",
|
||||
dataAttribute: DEFAULT_DATA_ATTRIBUTE,
|
||||
placeholder: "Write something \u2026",
|
||||
showOnlyWhenEditable: true,
|
||||
showOnlyCurrent: true,
|
||||
includeChildren: false
|
||||
};
|
||||
},
|
||||
addProseMirrorPlugins() {
|
||||
const dataAttribute = this.options.dataAttribute ? `data-${preparePlaceholderAttribute(this.options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
|
||||
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 (!node.type.isTextblock) {
|
||||
return this.options.includeChildren;
|
||||
}
|
||||
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(" "),
|
||||
[dataAttribute]: 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);
|
||||
}
|
||||
}
|
||||
})
|
||||
];
|
||||
}
|
||||
});
|
||||
export {
|
||||
Placeholder,
|
||||
preparePlaceholderAttribute
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@tiptap/extensions/dist/placeholder/index.js.map
generated
vendored
Normal file
1
node_modules/@tiptap/extensions/dist/placeholder/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user