PHP 8.2.30
Preview: deleteTableWhenAllCellsSelected.ts Size: 833 B
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/@tiptap/extension-table/src/utilities/deleteTableWhenAllCellsSelected.ts

import { findParentNodeClosestToPos, KeyboardShortcutCommand } from '@tiptap/core'

import { isCellSelection } from './isCellSelection.js'

export const deleteTableWhenAllCellsSelected: KeyboardShortcutCommand = ({ editor }) => {
  const { selection } = editor.state

  if (!isCellSelection(selection)) {
    return false
  }

  let cellCount = 0
  const table = findParentNodeClosestToPos(selection.ranges[0].$from, node => {
    return node.type.name === 'table'
  })

  table?.node.descendants(node => {
    if (node.type.name === 'table') {
      return false
    }

    if (['tableCell', 'tableHeader'].includes(node.type.name)) {
      cellCount += 1
    }
  })

  const allCellsSelected = cellCount === selection.ranges.length

  if (!allCellsSelected) {
    return false
  }

  editor.commands.deleteTable()

  return true
}

Directory Contents

Dirs: 0 × Files: 5

Name Size Perms Modified Actions
354 B lrw-r--r-- 2026-02-28 00:28:08
Edit Download
1.06 KB lrw-r--r-- 2026-02-28 00:28:18
Edit Download
833 B lrw-r--r-- 2026-02-28 00:28:24
Edit Download
505 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
167 B lrw-r--r-- 2026-02-28 00:28:36
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).