Skip to content

Commit

Permalink
feat: 💄 node+ improvements
Browse files Browse the repository at this point in the history
- Mardown mode (now default as it support most html too)
- Added a CSS editor
- "Purify" input to avoid script embedding in notes...
  • Loading branch information
melMass committed Dec 5, 2023
1 parent c43a661 commit 4b29395
Show file tree
Hide file tree
Showing 4 changed files with 589 additions and 110 deletions.
49 changes: 49 additions & 0 deletions web/comfy_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@

import { app } from '../../scripts/app.js'

// - crude uuid
export function makeUUID() {
let dt = new Date().getTime()
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (dt + Math.random() * 16) % 16 | 0
dt = Math.floor(dt / 16)
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)
})
return uuid
}

// - log utilities

function createLogger(emoji, color, consoleMethod = 'log') {
return function (message, ...args) {
if (window.MTB?.DEBUG) {
console[consoleMethod](
`%c${emoji} ${message}`,
`color: ${color};`,
...args
)
}
}
}

export const infoLogger = createLogger('ℹ️', 'yellow')
export const warnLogger = createLogger('⚠️', 'orange', 'warn')
export const errorLogger = createLogger('🔥', 'red', 'error')
export const successLogger = createLogger('✅', 'green')

export const log = (...args) => {
if (window.MTB?.DEBUG) {
console.debug(...args)
Expand Down Expand Up @@ -159,6 +189,25 @@ export const dynamic_connection = (
}
}

export function calculateTotalChildrenHeight(parentElement) {
let totalHeight = 0

for (const child of parentElement.children) {
const style = window.getComputedStyle(child)

// Get height as an integer (without 'px')
const height = parseInt(style.height, 10)

// Get vertical margin as integers
const marginTop = parseInt(style.marginTop, 10)
const marginBottom = parseInt(style.marginBottom, 10)

// Sum up height and vertical margins
totalHeight += height + marginTop + marginBottom
}

return totalHeight
}
/**
* Appends a callback to the extra menu options of a given node type.
* @param {*} nodeType
Expand Down
Loading

0 comments on commit 4b29395

Please sign in to comment.