"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/focus/index.ts var index_exports = {}; __export(index_exports, { Focus: () => Focus }); module.exports = __toCommonJS(index_exports); // src/focus/focus.ts var import_core = require("@tiptap/core"); var import_state = require("@tiptap/pm/state"); var import_view = require("@tiptap/pm/view"); var Focus = import_core.Extension.create({ name: "focus", addOptions() { return { className: "has-focus", mode: "all" }; }, addProseMirrorPlugins() { return [ new import_state.Plugin({ key: new import_state.PluginKey("focus"), props: { decorations: ({ doc, selection }) => { const { isEditable, isFocused } = this.editor; const { anchor } = selection; const decorations = []; if (!isEditable || !isFocused) { return import_view.DecorationSet.create(doc, []); } let maxLevels = 0; if (this.options.mode === "deepest") { doc.descendants((node, pos) => { if (node.isText) { return; } const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1; if (!isCurrent) { return false; } maxLevels += 1; }); } let currentLevel = 0; doc.descendants((node, pos) => { if (node.isText) { return false; } const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1; if (!isCurrent) { return false; } currentLevel += 1; const outOfScope = this.options.mode === "deepest" && maxLevels - currentLevel > 0 || this.options.mode === "shallowest" && currentLevel > 1; if (outOfScope) { return this.options.mode === "deepest"; } decorations.push( import_view.Decoration.node(pos, pos + node.nodeSize, { class: this.options.className }) ); }); return import_view.DecorationSet.create(doc, decorations); } } }) ]; } }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Focus }); //# sourceMappingURL=index.cjs.map