Skip to content

Commit

Permalink
chore: correções
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelino.braga committed Jul 11, 2024
1 parent b91261b commit 1279c8d
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 234 deletions.
7 changes: 1 addition & 6 deletions src/editor/toolbar/Toolbar.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Button, type ButtonConfig, type ButtonEventProps, Dropdown, type DropdownConfig, type DropDownEventProps } from '@editor/ui'
import { Button, type ButtonConfig, Dropdown, type DropdownConfig, type DropDownEventProps } from '@editor/ui'
import type ExitusEditor from '@src/ExitusEditor'

import { type Tool } from './Tool'

type ConfigStorage = {
[key: string]: { toolbarButtonConfig: object | object[] }
}

export interface ToolbarConfig {
toolbarOrder: string[]
configStorage: {
Expand Down
10 changes: 3 additions & 7 deletions src/extensions/bold/BoldPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Plugin } from '@editor/Plugin'
import { Button, type ButtonEventProps } from '@editor/ui'
import { type ButtonEventProps } from '@editor/ui'
import bold from '@icons/bold.svg'
import { type AnyExtension } from '@tiptap/core'
import Bold from '@tiptap/extension-bold'
Expand All @@ -14,16 +14,12 @@ export class BoldPlugin extends Plugin {
}

init() {
const config = {
this.editor.toolbar.setButton('bold', {
icon: bold,
click: this.toggleBold,
checkActive: BoldPlugin.pluginName,
tooltip: 'Negrito (Ctrl + B)'
}
const button = new Button(this.editor, config)
button.setParentToolbar(this.editor.toolbar)
button.bind('click', config.click)
this.editor.toolbar.setTool('bold', button)
})
}

toggleBold({ editor, button }: ButtonEventProps) {
Expand Down
33 changes: 0 additions & 33 deletions src/extensions/history/history.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/extensions/image/imageView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export class ImageView implements NodeView {
const imageUrlRegex = /(https?:\/\/.*\.(?:png|jpg|jpeg|gif|bmp|webp|svg))/i

if (this.conversionServiceUrl !== null && imageUrlRegex.test(node.attrs.src)) {
console.log(node.attrs.src, imageUrlRegex.test(node.attrs.src))

this.urlToBase64(node.attrs.src)
}

Expand Down
70 changes: 2 additions & 68 deletions src/extensions/katex/katex.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,10 @@
//@ts-nocheck
import { type ButtonEventProps } from '@editor/ui'
import { Node } from '@tiptap/core'
// eslint-disable-next-line import-helpers/order-imports
import { Fragment } from '@tiptap/pm/model'
import '../../../node_modules/katex/dist/katex.min.css'

import '../../../node_modules/katex/dist/katex.css'

import { KatexBalloon, KatexView } from './index'

function click({ editor, button }: ButtonEventProps) {
const { pos } = editor.state.selection.$anchor

const main = editor.view.dom.getBoundingClientRect()
const { bottom, left } = editor.view.coordsAtPos(pos)

if (button.active()) {
return
}

button.on()

const confirmButtonCallback = (katexBalloon: KatexBalloon) => {
const { input, checkboxDisplay } = katexBalloon
if (input.value === '') return
editor.commands.insertContentAt(pos, `<span class="math-tex ${checkboxDisplay.checked ? 'katex-display' : ''}">${input.value}</span>`, {
updateSelection: true,
parseOptions: {
preserveWhitespace: true
}
})
cancelButtonCallback(katexBalloon)
}

const cancelButtonCallback = (katexBalloon: KatexBalloon) => {
button.off()
editor.editorMainDiv.removeChild(katexBalloon.getBalloon())
}

const balloon = new KatexBalloon(
editor,
{
latexFormula: '',
display: false
},
confirmButtonCallback,
cancelButtonCallback,
'float'
)

const focus = () => {
button.off()
editor.off('focus', focus)
try {
editor.editorMainDiv.removeChild(balloon.getBalloon())
} catch (e) {}
}

editor.on('focus', focus)

editor.editorMainDiv.appendChild(balloon.getBalloon())
balloon.balloon.setPosition(left - main.left, bottom - main.y)
}
import { KatexView } from './index'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand All @@ -83,16 +27,6 @@ export const Katex = Node.create({

draggable: true,

/* addStorage() {
return {
toolbarButtonConfig: {
icon: formula,
click: click,
checkActive: this.name,
tooltip: 'Fórmula matemática - Latex'
}
}
}, */
parseHTML() {
return [
{
Expand Down
2 changes: 0 additions & 2 deletions src/extensions/listitem/ListItemPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export class ListItemPlugin extends Plugin {
}

createDropDownContent(dropdown: Dropdown) {
console.log(dropdown)

const dropdownContent = document.createElement('div')
dropdownContent.className = 'ex-dropdownList-content'

Expand Down
3 changes: 0 additions & 3 deletions src/extensions/mathtype/MathTypePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class MathTypePlugin extends Plugin {
}

openEditor(editorType: string | null) {
//return ({ editor }) => {
try {
const integration = this.integration
if (editorType == null) {
Expand All @@ -70,7 +69,6 @@ export class MathTypePlugin extends Plugin {
} catch (e) {
console.error(e)
}
//}
}

createMathTypeIntegration() {
Expand All @@ -91,7 +89,6 @@ export class MathTypePlugin extends Plugin {
language: 'pt_br'
}
})
//getExtensionStorage(editor).currentInstances.set(editor.editorInstance, integration)

window.WirisPlugin = {
Core,
Expand Down
14 changes: 1 addition & 13 deletions src/extensions/mathtype/mathtype-integration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable camelcase */
//@ts-nocheck
import { deleteSelectedNode } from '@editor/utils'
import { type Editor } from '@tiptap/core'
Expand All @@ -8,17 +9,6 @@ import Parser from '@wiris/mathtype-html-integration-devkit/src/parser'
import Telemeter from '@wiris/mathtype-html-integration-devkit/src/telemeter'
import Util from '@wiris/mathtype-html-integration-devkit/src/util'

function getExtensionOptions(editor: Editor, extensionName: string) {
// Find the extension in the editor schema
const extension = editor.extensionManager.extensions.find(ext => ext.name === extensionName)

if (!extension) {
return null
}

// Return the extension's options
return extension.options
}
export class ExitusEditorIntegration extends IntegrationModel {
integrationFolderName: string
editor: Editor
Expand Down Expand Up @@ -202,8 +192,6 @@ export class ExitusEditorIntegration extends IntegrationModel {
toolbar: this.core.modalDialog.contentManager.toolbar,
size: mathml?.length
}
//console.log(payload)

// Remove desired null keys.
Object.keys(payload).forEach(key => {
if (key === 'mathml_origin' || key === 'editor_origin') !payload[key] ? delete payload[key] : {}
Expand Down
1 change: 0 additions & 1 deletion src/extensions/table/TableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function clickHandler(tableView: TableView) {
const target = event.target as HTMLElement

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

Expand Down
2 changes: 0 additions & 2 deletions src/extensions/table/prosemirror-tables/src/columnresizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,9 @@ function handleMouseDown(
view,
pluginState.activeHandle,
).getBoundingClientRect();
//console.log(table);

const cell = view.state.doc.nodeAt(pluginState.activeHandle)!;
const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);
//console.log(table.width, width, 860 - (table.width - width));

view.dispatch(
view.state.tr.setMeta(columnResizingPluginKey, {
Expand Down
30 changes: 0 additions & 30 deletions src/extensions/table/table.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,16 @@
//@ts-nocheck
import { Button, type ButtonEventProps, Dropdown } from '@editor/ui'
import { mergeAttributes } from '@tiptap/core'
import { findParentNodeOfType } from 'prosemirror-utils'

import type ExitusEditor from '../../ExitusEditor'

import { createColGroup, Table } from './extension-table/src'
import { TableView } from './TableView'

function showTableGridDropdown({ dropdown }) {
if (dropdown.isOpen) {
removeSelectionFromGridButtons(dropdown)
dropdown.off()
} else {
dropdown.on()
}
}

declare module '@tiptap/core' {
interface Commands<ReturnType> {
setTableBorder: () => ReturnType
}
}

function tableDropDown({ editor }: ButtonEventProps) {
const dropdown = new Dropdown(editor, {
events: {
open: showTableGridDropdown
}
})

dropdown.setDropDownContent(createDropDownContent(editor, dropdown))

window.addEventListener('click', function (event: Event) {
event.stopPropagation()
if (dropdown.isOpen) {
dropdown.off()
}
})
return dropdown
}

export function cssParaObj(cssString: string): { [key: string]: string } {
const styles: { [key: string]: string } = {}

Expand Down
66 changes: 0 additions & 66 deletions src/extensions/textAlign/textAlign.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
}
},
"include": ["src/**/*", "declaration.d.ts"],
"exclude": ["src/devmain.ts", "node_modules", "dist"]
"exclude": ["src/devmain.ts", "node_modules", "dist", "src/assets/**/*"]
}
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const CopyWebpackPlugin = require('copy-webpack-plugin')
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
Expand Down

0 comments on commit 1279c8d

Please sign in to comment.