Skip to content

Commit

Permalink
feat: adicionada configuração para o tamanho da altura inicial do editor
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelino.braga committed Nov 25, 2024
1 parent c975c03 commit 20395f9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/ExitusEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createHTMLElement } from '@editor/utils'
import { type AnyExtension, Editor, type EditorOptions } from '@tiptap/core'
interface Config {
[key: string]: any
initialHeight?: number
}

export interface ExitusEditorOptions extends EditorOptions {
Expand Down Expand Up @@ -38,6 +39,7 @@ class ExitusEditor extends Editor {
static plugins: PluginClassConstructor[]
static toolbarOrder: string[]
private container: Element
private config?: Config

constructor(options: Partial<ExitusEditorOptions>) {
if (!options.container) {
Expand All @@ -47,6 +49,8 @@ class ExitusEditor extends Editor {
const extensions = loadPluginsRequirements()

super({ ...options, extensions })

this.config = options.config
this.editorInstance = generateUUID()

const toolbarOrder: string[] = [...ExitusEditor.toolbarOrder, ...(options.toolbarOrder ?? [])]
Expand Down Expand Up @@ -83,7 +87,11 @@ class ExitusEditor extends Editor {
editorMain.setAttribute('id', generateUUID())
this.editorMainDiv = editorMain as HTMLDivElement

const editorScroller = createHTMLElement('div', { class: 'editor-scroller' }, [editorMain])
const initialHeight = this.config && this.config?.initialHeight

const editorScroller = createHTMLElement('div', { class: 'editor-scroller', style: initialHeight ? `height: ${initialHeight}px` : '' }, [
editorMain
])

const editorShell = createHTMLElement('div', { class: 'editor-shell' }, [toolbarEditor, editorScroller])

Expand Down
2 changes: 0 additions & 2 deletions src/extensions/katex/katex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//@ts-nocheck
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'

Expand Down
3 changes: 2 additions & 1 deletion src/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
proxyUrl: "https://us-central1-desenvolvimento-271520.cloudfunctions.net/imagem-conversao-base64/proxy",
inline: true,
allowBase64: true,
}
},
initialHeight: 400
}
})

Expand Down
2 changes: 1 addition & 1 deletion src/public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ p {

.editor-main {
position: relative;
min-height: 200px;
min-height: 100%;
width: 24.8cm;
background: #fff;
border-color: var(--border-gray);
Expand Down

0 comments on commit 20395f9

Please sign in to comment.