Skip to content

Commit

Permalink
refact: substituiçõa de [key: string]: any } para Record.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelinombb committed Sep 8, 2024
1 parent 73a41a1 commit 5d083ca
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
8 changes: 2 additions & 6 deletions src/editor/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ export interface PluginInterface {
destroy(): void
}

export interface Config {
[key: string]: any
}

export class Plugin implements PluginInterface {
config: Config
config: Record<string, string>
constructor(
readonly editor: ExitusEditor,
config: Config
config: Record<string, string>
) {
this.config = config
}
Expand Down
8 changes: 4 additions & 4 deletions src/editor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type Node } from '@tiptap/pm/model'
import { TextSelection } from '@tiptap/pm/state'
import { Fragment } from 'prosemirror-model'

export function createHTMLElement<T = Element>(tagName: string, attributes: { [x: string]: string }, childrens?: Element[]): T {
export function createHTMLElement<T = Element>(tagName: string, attributes: Record<string, string>, childrens?: Element[]): T {
// Create the element
const element = document.createElement(tagName)

Expand Down Expand Up @@ -105,8 +105,8 @@ export function getNodeBoundingClientRect(editor: Editor, nodePos: number) {
return null
}

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

// Remover espaços em branco desnecessários
cssString = cssString.replace(/\s*:\s*/g, ':').replace(/\s*;\s*/g, ';')
Expand All @@ -125,7 +125,7 @@ export function cssParaObj(cssString: string): { [key: string]: string } {
return styles
}

export function objParaCss(styles: { [key: string]: string }): string {
export function objParaCss(styles: Record<string, string>): string {
let cssString = ''

for (const property in styles) {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/colar-questao/ColarQuestaoPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ColarQuestaoPlugin extends Plugin {
init() {}

getColarQuestao() {
const nodes: { [key: string]: string } = {}
const nodes: Record<string, string> = {}
const nodeType = 'colarQuestao'

const traverse = (node: Node) => {
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/table/TableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export class TableView implements NodeView {
tableWrapper: HTMLElement
contentDOM: HTMLElement
getPos: boolean | (() => number)
tableStyle: { [key: string]: string }
tableWrapperStyle: { [key: string]: string }
tableStyle: Record<string, string>
tableWrapperStyle: Record<string, string>

constructor(node: ProseMirrorNode, editor: Editor, getPos: boolean | (() => number)) {
this.node = node
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type NodeType, type Schema } from '@tiptap/pm/model'

export function getTableNodeTypes(schema: Schema): { [key: string]: NodeType } {
export function getTableNodeTypes(schema: Schema): Record<string, NodeType> {
if (schema.cached.tableNodeTypes) {
return schema.cached.tableNodeTypes
}

const roles: { [key: string]: NodeType } = {}
const roles: Record<string, NodeType> = {}

Object.keys(schema.nodes).forEach(type => {
const nodeType = schema.nodes[type]
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 @@ -9,9 +9,9 @@ import { TableView } from './TableView'
declare module '@tiptap/core' {
interface Commands<ReturnType> {
tableCustom: {
setTableBorder: (styles: { [key: string]: any }) => ReturnType
setWrapperStyle: (styles: { [key: string]: any }) => ReturnType
setTableStyle: (styles: { [key: string]: any }) => ReturnType
setTableBorder: (styles: Record<string, any>) => ReturnType
setWrapperStyle: (styles: Record<string, any>) => ReturnType
setTableStyle: (styles: Record<string, any>) => ReturnType
}
}
}
Expand Down

0 comments on commit 5d083ca

Please sign in to comment.