Skip to content

Commit

Permalink
bug-fiz\\ finalização pickr
Browse files Browse the repository at this point in the history
  • Loading branch information
skaduhs5232 committed Jun 13, 2024
1 parent 7185230 commit 4e3d3e0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
23 changes: 14 additions & 9 deletions src/editor/ui/Dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface DropdownConfig {
[key: string]: (obj: DropDownEventProps) => void
}
classes: string[]
fecha: boolean
}

export class Dropdown implements Tool {
Expand All @@ -21,8 +22,10 @@ export class Dropdown implements Tool {
dropdownContent!: HTMLElement
config: DropdownConfig = {
classes: [],
events: {}
events: {},
fecha: true
}

button!: Button
editor: ExitusEditor
parentToolbar!: Toolbar
Expand Down Expand Up @@ -72,16 +75,18 @@ export class Dropdown implements Tool {
render() {
this.button.bind('click', ({ editor, event, button }) => {
this.config.events['open']({ editor, event, button, dropdown: this })

const close = (event: Event) => {
const target = event.target as HTMLElement
if (!target.closest('.ex-dropdown')) {
this.off()
window.removeEventListener('click', close)
if (this.config.fecha) {
const close = (event: Event) => {
const target = event.target as HTMLElement
if (!target.closest('.ex-dropdown')) {
this.off()
window.removeEventListener('click', close)
console.log('dsfgfds')
}
}
}

window.addEventListener('click', close)
window.addEventListener('click', close)
}
})

this.dropdownContentContainer.appendChild(this.dropdownContent)
Expand Down
9 changes: 6 additions & 3 deletions src/extensions/table/TableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ function clickHandler(tableView: TableView) {

function clickOutside(event: Event) {
const target = event.target as HTMLElement

if (target.closest('.pcr-app') !== null) {
console.log(target.closest('.pcr-app'))
return
}

if (target.closest('.tableWrapper') == null) {
tableView.balloon.hide()
tableView.tableWrapper.classList.remove('ex-selected')
Expand All @@ -41,13 +47,10 @@ function clickCellHandler(tableView: TableView) {
function clickOutside(event: Event) {
const target = event.target as HTMLElement

// Verifica se o clique foi dentro do menu do Pickr
if (target.closest('.pcr-app') !== null) {
// O clique foi dentro do Pickr, então não faz nada
return
}

// Verifica se o clique foi fora do menu balloon
if (target.closest('.balloon-menu') == null) {
tableView.tableCellBalloon.off()
window.removeEventListener('click', clickOutside)
Expand Down
19 changes: 15 additions & 4 deletions src/extensions/table/itensModalTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export function criaTabelaModal(style: any) {
events: {
open: showDropdown
},
classes: ['ex-dropdown-balloonModal']
classes: ['ex-dropdown-balloonModal'],
fecha: false
})
dropdown.setDropDownContent(new ItensModalTable(editor, style).render())
return dropdown
Expand All @@ -84,7 +85,6 @@ export class ItensModalTable {

this.selectInput = document.createElement('select')
this.selectInput.style.width = '80px'
this.selectInput.style.marginRight = '14.4px'

const borderStyles = {
'sem borda': 'none',
Expand All @@ -105,7 +105,7 @@ export class ItensModalTable {
this.selectInput.appendChild(option)
})

const [size = '', border = 'none', color = ''] = (this.style.border ?? '').split(' ')
const [size = '', border = 'none'] = (this.style.border ?? '').split(' ')

this.selectInput.value = border

Expand Down Expand Up @@ -148,6 +148,7 @@ export class ItensModalTable {
})

this.selectInput.addEventListener('change', () => {
this.toggleBorderInputs()
this.aplicarEstiloBorda()
})

Expand All @@ -162,7 +163,7 @@ export class ItensModalTable {
const borderColorElement = document.createElement('div')
borderColorElement.className = 'color-picker-border'

bloco1.append(bordaLabel, this.selectInput, borderColorElement, this.larguraBloco1)
bloco1.append(bordaLabel, this.selectInput, this.larguraBloco1, borderColorElement)
dropdownContent.appendChild(bloco1)

const corFundoLabel = document.createElement('strong')
Expand All @@ -182,6 +183,7 @@ export class ItensModalTable {
this.cellBorderColorPickr = createPickrInstance('.color-picker-border', () => {
this.cellBorderColorPickr?.hide()
})
this.cellBorderColorPickr.disable()

this.cellBackgroundColorPickr = createPickrInstance('.color-picker-background', () => {
this.cellBackgroundColorPickr?.hide()
Expand Down Expand Up @@ -276,6 +278,7 @@ export class ItensModalTable {
this.aplicarEstiloBorda(borderColor)
this.aplicarEstiloCelulas(backgroundColor)
this.aplicarDimensoesTabela()
fecharDropdownsAbertos()
})
botaoConfirma.className = 'ex-botaoSalvar'
botaoConfirma.appendChild(iconConfirma)
Expand Down Expand Up @@ -312,6 +315,14 @@ export class ItensModalTable {
}
}

private toggleBorderInputs() {
const isBorderNone = this.selectInput.value === 'none'
this.larguraBloco1.disabled = isBorderNone
this.larguraBloco1.style.cursor = isBorderNone ? 'not-allowed' : 'default'
this.cellBorderColorPickr.setColor(isBorderNone ? 'rgba(0, 0, 0, 0)' : this.cellBorderColorPickr.getColor().toRGBA().toString())
this.cellBorderColorPickr?.enable()
}

private aplicarEstiloCelulas(cor: string = '') {
if (cor) {
this.editor.commands.setTableStyle({
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { TableView } from './TableView'
function onSelectTableRowColumn(event): EventListener {
const onColumn = parseInt(event.target.getAttribute('data-column'))
const onRow = parseInt(event.target.getAttribute('data-row'))
const indicator = document.querySelector('.ex-indicator')
if (indicator) {
const indicators = document.querySelectorAll('.ex-indicator')
indicators.forEach(indicator => {
indicator.textContent = `${onRow} × ${onColumn}`
}
})

const buttons = event.target.parentNode.querySelectorAll('button') as HTMLCollectionOf<HTMLButtonElement>

Expand Down
6 changes: 4 additions & 2 deletions src/public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
flex-direction: row;
flex-wrap: nowrap;
z-index: 3 !important;
width: 360px;
width: 22em;
}

.ex-dropdown-baloon {
Expand Down Expand Up @@ -791,7 +791,9 @@ display: none;


.ex-bolinha-baixo {
transform: translate(543px,calc(-50% - 0.5px));
bottom: 0;
transform: translate(0,calc(50% - 1.5px));
left: 90%;
margin: 0 0;
}

Expand Down

0 comments on commit 4e3d3e0

Please sign in to comment.