Skip to content

Commit

Permalink
quase lá do balão nas tabelas
Browse files Browse the repository at this point in the history
  • Loading branch information
skaduhs5232 committed Apr 29, 2024
1 parent f6ea413 commit c6e718f
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions src/extensions/table/TableView.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
import { Toolbar } from '@editor/toolbar'
import arrowDropDown from '@icons/arrow-drop-down-line.svg'
import tableCell from '@icons/merge-tableCells.svg'
Expand All @@ -15,14 +16,12 @@ import { Balloon } from '../../editor/ui/Balloon'

function clickHandler(table: TableView) {
table.tableWrapper.addEventListener('click', event => {
//event.stopPropagation()
console.log('jkadfs')
const balloonMenu = table.tableWrapper.querySelector('.baloon-menu') as HTMLElement
console.log(balloonMenu)

table.updateAttributes({
ballonActive: true
})
///table.classList.add('ex-selected')
/* const balloonMenu = table.querySelector('.baloon-menu') as HTMLElement
console.log(balloonMenu)

if (balloonMenu) {
if (balloonMenu.style.display === 'none') {
Expand All @@ -33,18 +32,22 @@ function clickHandler(table: TableView) {
window.addEventListener('click', function (event) {
const target = event.target as HTMLElement

if (!target.matches('.tableWrapper')) {
balloonMenu.style.display = 'none'
table.classList.remove('ex-selected')
if (target.closest('.tableWrapper') == null) {
console.log(target.closest('.tableWrapper'))

table.updateAttributes({
ballonActive: false
})
table.tableWrapper.classList.remove('ex-selected')
}
}) */
})
})
}

export function updateColumns(
node: ProseMirrorNode,
colgroup: Element,
table: Element,
table: HTMLElement,
cellMinWidth: number,
overrideCol?: number,
overrideValue?: any
Expand All @@ -70,8 +73,8 @@ export function updateColumns(
if (!nextDOM) {
colgroup.appendChild(document.createElement('col')).style.width = cssWidth
} else {
if (nextDOM.style.width !== cssWidth) {
nextDOM.style.width = cssWidth
if ((nextDOM as HTMLElement).style.width !== cssWidth) {
;(nextDOM as HTMLElement).style.width = cssWidth
}

nextDOM = nextDOM.nextSibling
Expand Down Expand Up @@ -103,7 +106,7 @@ export class TableView implements NodeView {
balloon: Balloon
editor: Editor
tableWrapper: HTMLElement
contentDOM: Element
contentDOM: HTMLElement

constructor(node: ProseMirrorNode, editor: Editor) {
this.node = node
Expand All @@ -114,8 +117,8 @@ export class TableView implements NodeView {

this.table = this.tableWrapper.appendChild(document.createElement('table'))
this.colgroup = this.table.appendChild(document.createElement('colgroup'))
this.contentDOM = this.table.appendChild(document.createElement('tbody')) as HTMLElement
console.log('sdlkfd')
this.contentDOM = this.table.appendChild(document.createElement('tbody'))
console.log('TableView')

const configStorage = {
celumnsTable: {
Expand Down Expand Up @@ -148,7 +151,7 @@ export class TableView implements NodeView {
tableStarred: {
toolbarButtonConfig: {
icon: starredTable + arrowDropDown,
label: 'Aumentar e diminuir imagem',
label: 'editar tabela',
events: {
click: null
}
Expand All @@ -157,7 +160,7 @@ export class TableView implements NodeView {
cellStarred: {
toolbarButtonConfig: {
icon: starredCell + arrowDropDown,
label: 'Aumentar e diminuir imagem',
label: 'editar celula',
events: {
click: null
}
Expand All @@ -173,10 +176,7 @@ export class TableView implements NodeView {
this.balloon = new Balloon(editor, toolbar)

this.tableWrapper.appendChild(this.balloon.render())
const balloonMenu = this.tableWrapper.querySelector('.baloon-menu') as HTMLElement
console.log(node)

balloonMenu.style.display = node.attrs.ballonActive ? 'block' : 'none'
this.dom.appendChild(this.tableWrapper)

clickHandler(this)
Expand All @@ -190,10 +190,10 @@ export class TableView implements NodeView {
if (node.type !== this.node.type) {
return false
}
//console.log(node.attrs)
console.log(node.attrs)
this.balloon.ballonMenu.style.display = node.attrs.ballonActive ? 'block' : 'none'

this.node = node
//updateColumns(node, this.colgroup, this.table, this.cellMinWidth)

return true
}
Expand All @@ -202,3 +202,9 @@ export class TableView implements NodeView {
return mutation.type === 'attributes' && (mutation.target === this.table || this.colgroup.contains(mutation.target))
}
}

export class baloesTable extends TableView {
constructor(node: ProseMirrorNode, editor: Editor) {
super(node, editor)
}
}

0 comments on commit c6e718f

Please sign in to comment.