Files
claudia-docs-web/node_modules/@tiptap/extensions/dist/selection/index.js

36 lines
1008 B
JavaScript

// src/selection/selection.ts
import { Extension, isNodeSelection } from "@tiptap/core";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import { Decoration, DecorationSet } from "@tiptap/pm/view";
var Selection = Extension.create({
name: "selection",
addOptions() {
return {
className: "selection"
};
},
addProseMirrorPlugins() {
const { editor, options } = this;
return [
new Plugin({
key: new PluginKey("selection"),
props: {
decorations(state) {
if (state.selection.empty || editor.isFocused || !editor.isEditable || isNodeSelection(state.selection) || editor.view.dragging) {
return null;
}
return DecorationSet.create(state.doc, [
Decoration.inline(state.selection.from, state.selection.to, {
class: options.className
})
]);
}
}
})
];
}
});
export {
Selection
};
//# sourceMappingURL=index.js.map