Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dwertheimer.EventAutomations/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export function validateAutoTimeBlockingConfig(config: AutoTimeBlockingConfig):
// $FlowIgnore
return validatedConfig
} catch (error) {
// console.log(`NPTimeblocking::validateAutoTimeBlockingConfig: ${String(error)}\nInvalid config:\n${JSON.stringify(config)}`)
throw new Error(`${String(error)}`)
}
}
Expand Down
4 changes: 1 addition & 3 deletions dwertheimer.EventAutomations/src/timeblocking-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export function findTimeBlocks(timeMap: IntervalMap, config: { [key: string]: an
let blockStart = timeMap[0]
for (let i = 1; i < timeMap.length; i++) {
const slot = timeMap[i]
// console.log(`findTimeBlocks[${i}]: slot: ${slot.start} ${slot.index} ${slot.busy}}`)

const noBreakInContinuity = slot.index === lastSlot.index + 1 && i <= timeMap.length - 1 && lastSlot.busy === slot.busy
if (noBreakInContinuity) {
lastSlot = slot
Expand Down Expand Up @@ -312,9 +312,7 @@ export function findTimeBlocks(timeMap: IntervalMap, config: { [key: string]: an
if (lastBlock) blocks.push(lastBlock)
}
} else {
// console.log(`findTimeBlocks: timeMap array was empty`)
}
// console.log(`findTimeBlocks: found blocks: ${JSP(blocks)}`)

return blocks
}
Expand Down
1 change: 0 additions & 1 deletion dwertheimer.MathSolver/src/support/solver.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ export function parse(thisLineStr: string, lineIndex: number, cd: CurrentData):
// SOURCE: https://stackoverflow.com/questions/12812902/javascript-regular-expression-matching-cityname // how to take only specific parts
const reg = /(\d*[\.,])?(\d+)(\s?%)(\s+)(of)(\s+)(\d*[\.,])?(\d+\s?)/g
while ((match = reg.exec(strToBeParsed))) {
// console.log(match);
const num = match[1] ? match[1] + match[2] : match[2]
const dest = match[7] ? match[7] + match[8] : match[8]
const sostituzione = (Number(dest) * (Number(num) / 100)).toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const { rollupReactFiles, getRollupConfig } = rollupReactScript
]
// create one single base config with two output options
const config = { ...rollupConfigs[0], ...{ output: [rollupConfigs[0].output, rollupConfigs[1].output] } }
// console.log(JSON.stringify(config, null, 2))

await rollupReactFiles(config, watch, 'dwertheimer.ReactSkeleton: development && production')
// const rollupsProms = rollups.map((obj) => rollupReactFiles({ ...obj, buildMode }, watch, buildMode))
})().catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion dwertheimer.TaskAutomations/src/react/EditableElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const EditableElement = (props) => {
ref: element,
onKeyUp: onMouseUp,
})
// console.log(`WebView: EditableElement elements=`, elements)

return elements
}

Expand Down
1 change: 0 additions & 1 deletion dwertheimer.TaskAutomations/src/react/ThemedSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ const colourStyles = {
// option: (styles) => ({ ...styles, backgroundColor: NP_THEME.base.backgroundColor, color: NP_THEME.base.textColor ?? 'black' }),
// option: (styles, { data, isDisabled, isFocused, isSelected }) => {
option: (styles, { isDisabled, isSelected }) => {
// console.log('option', styles, data, isDisabled, isFocused, isSelected)
return {
...styles,
// backgroundColor: isDisabled ? undefined : isSelected ? bgColor.css() : isFocused ? bgColor.alpha(0.1).css() : bgColor.css(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const { rollupReactFiles, getCommandLineOptions, getRollupConfig } = rollupReact
]
// create one single base config with two output options
const config = { ...rollupConfigs[0], ...{ output: [rollupConfigs[0].output, rollupConfigs[1].output] } }
// console.log(JSON.stringify(config, null, 2))

await rollupReactFiles(config, watch, 'TaskAutomations: development && production')
// const rollupsProms = rollups.map((obj) => rollupReactFiles({ ...obj, buildMode }, watch, buildMode))
})()
4 changes: 2 additions & 2 deletions dwertheimer.TaskSorting/__tests__/sortTasks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ describe(`${PLUGIN_NAME}`, () => {
// output order is the reverse of that order
// Note that types will be unreliable because rawContent is being pasted
// so we're just checking the content
// console.log(`sortTasks result`, result)

expect(result[8].content).toEqual('6-checklistCancelled')
expect(result[7].content).toEqual('5-cancelled')
expect(result[6].content).toEqual('4-checklistDone')
Expand Down Expand Up @@ -579,7 +579,7 @@ describe(`${PLUGIN_NAME}`, () => {
const shouldBe = `${p.rawContent}`
const newContent = `${result[i].rawContent}`
// uncomment the following line if this test is failing and it will give you more clues on how far it got
// console.log(`sortTasks: [${i}]: (result) ${newContent} ${newContent === shouldBe ? '===' : ' !== '} "${shouldBe}" (expected)`)

// Put breakpoint on the expect and compare the objects in the debugger
expect(newContent).toMatch(shouldBe)
})
Expand Down
27 changes: 12 additions & 15 deletions helpers/HTMLView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
// Last updated 2025-05-31 by @jgclark
// ---------------------------------------------------------
import showdown from 'showdown' // for Markdown -> HTML from https://github.com/showdownjs/showdown
import {
hasFrontMatter
} from '@helpers/NPFrontMatter'
import { hasFrontMatter } from '@helpers/NPFrontMatter'
import { getFolderFromFilename } from '@helpers/folders'
import { clo, logDebug, logError, logInfo, logWarn, JSP, timer } from '@helpers/dev'
import { getStoredWindowRect, isHTMLWindowOpen, storeWindowRect } from '@helpers/NPWindows'
Expand Down Expand Up @@ -86,7 +84,7 @@ export function getCallbackCodeString(jsFunctionName: string, commandName: strin
.replace("%%commandName%%", commandName)
.replace("%%pluginID%%", pluginID)
.replace("%%commandArgs%%", () => JSON.stringify(commandArgs)); //This is important because it works around problems with $$ in commandArgs
// console.log(\`${jsFunctionName}: Sending command "\$\{commandName\}" to NotePlan: "\$\{pluginID\}" with args: \$\{JSON.stringify(commandArgs)\}\`);

console.log(\`window.${jsFunctionName}: Sending code: "\$\{code\}"\`)
if (window.webkit) {
window.webkit.messageHandlers.jsBridge.postMessage({
Expand All @@ -101,7 +99,6 @@ export function getCallbackCodeString(jsFunctionName: string, commandName: strin
`
}


/**
* Convert a note's content to HTML and include any images as base64
* @param {string} content
Expand Down Expand Up @@ -164,22 +161,22 @@ export async function getNoteContentAsHTML(content: string, note: TNote): Promis
tasklists: true,
metadata: false, // otherwise metadata is swallowed
requireSpaceBeforeHeadingText: true,
simpleLineBreaks: true // Makes this GFM style. TODO: make an option?
simpleLineBreaks: true, // Makes this GFM style. TODO: make an option?
}
const converter = new showdown.Converter(converterOptions)
let body = converter.makeHtml(lines.join(`\n`))
body = `<style>img { background: white; max-width: 100%; max-height: 100%; }</style>${body}` // fix for bug in showdown

const imgTagRegex = /<img src=\"(.*?)\"/g
const matches = [...body.matchAll(imgTagRegex)]
const noteDirPath = getFolderFromFilename(note.filename)

for (const match of matches) {
const imagePath = match[1]
try {
// Handle both absolute and relative paths
let fullPath = `../../../Notes/${noteDirPath}/${decodeURI(imagePath)}`
if(fullPath.endsWith('.drawing')) {
if (fullPath.endsWith('.drawing')) {
fullPath = fullPath.replace('.drawing', '.png')
}
const data = await DataStore.loadData(fullPath, false)
Expand Down Expand Up @@ -237,14 +234,12 @@ export async function getNoteContentAsHTML(content: string, note: TNote): Promis
modifiedLines.push(line)
}
return modifiedLines.join('\n')

} catch (error) {
logError('getNoteContentAsHTML', error.message)
return '<conversion error>'
}
}


/**
* This function creates the webkit console.log/error handler for HTML messages to get back to NP console.log
* @returns {string} - the javascript (without a tag)
Expand Down Expand Up @@ -566,7 +561,10 @@ export async function showHTMLV2(body: string, opts: HtmlWindowOptions): Promise
try {
const screenWidth = NotePlan.environment.screenWidth
const screenHeight = NotePlan.environment.screenHeight
logDebug('HTMLView / showHTMLV2', `starting with customId ${opts.customId ?? ''} and reuseUsersWindowRect ${String(opts.reuseUsersWindowRect) ?? '??'} for screen dimensions ${screenWidth}x${screenHeight}`)
logDebug(
'HTMLView / showHTMLV2',
`starting with customId ${opts.customId ?? ''} and reuseUsersWindowRect ${String(opts.reuseUsersWindowRect) ?? '??'} for screen dimensions ${screenWidth}x${screenHeight}`,
)

// Assemble the parts of the HTML into a single string
const fullHTMLStr = assembleHTMLParts(body, opts)
Expand All @@ -592,8 +590,8 @@ export async function showHTMLV2(body: string, opts: HtmlWindowOptions): Promise
winOptions = {
x: opts.x ?? (screenWidth - (screenWidth - (opts.paddingWidth ?? 0) * 2)) / 2,
y: opts.y ?? (screenHeight - (screenHeight - (opts.paddingHeight ?? 0) * 2)) / 2,
width: opts.width ?? (screenWidth - (opts.paddingWidth ?? 0) * 2),
height: opts.height ?? (screenHeight - (opts.paddingHeight ?? 0) * 2),
width: opts.width ?? screenWidth - (opts.paddingWidth ?? 0) * 2,
height: opts.height ?? screenHeight - (opts.paddingHeight ?? 0) * 2,
shouldFocus: opts.shouldFocus,
id: cId, // don't need both ... but trying to work out which is the current one for the API
windowId: cId,
Expand All @@ -603,7 +601,6 @@ export async function showHTMLV2(body: string, opts: HtmlWindowOptions): Promise
// logDebug('showHTMLV2', `- Trying to use user's saved Rect from pref for ${cId}`)
const storedRect = getStoredWindowRect(cId)
if (storedRect) {

winOptions = {
x: storedRect.x,
y: storedRect.y,
Expand Down
3 changes: 1 addition & 2 deletions helpers/NPFrontMatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export function setFrontMatterVars(note: CoreNoteFields, varObj: { [string]: str
logDebug(`setFrontMatterVars`, `- BEFORE ensureFM: hasFrontmatter:${String(noteHasFrontMatter(note) || '')} note has ${note.paragraphs.length} lines`)
const hasFM = ensureFrontmatter(note, true, title)
logDebug('note.paragraphs', `- AFTER ensureFM has ${note.paragraphs.length} lines, that starts:`)
// console.log(note.paragraphs.slice(0, 7).map(p => p.content).join('\n'))

if (!hasFM) {
throw new Error(`setFrontMatterVars: Could not add front matter to note which has no title. Note should have a title, or you should pass in a title in the varObj.`)
}
Expand All @@ -364,7 +364,6 @@ export function setFrontMatterVars(note: CoreNoteFields, varObj: { [string]: str
removeFrontMatter(note)
writeFrontMatter(note, changedAttributes)
logDebug('setFrontMatterVars', `- ENDING with ${note.paragraphs.length} lines, that starts:`)
// console.log(note.paragraphs.slice(0, 7).map(p => p.content).join('\n'))
} else {
logError('setFrontMatterVars', `- could not change frontmatter for note "${note.filename || ''}" because it has no frontmatter.`)
}
Expand Down
1 change: 0 additions & 1 deletion helpers/NPdev.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function logAllEnvironmentSettings(): void {
// TODO: don't know why this is no longer working for me:
clo(NotePlan.environment, 'NotePlan.environment:')
// TODO: when the following simple case *is* working:
// console.log(NotePlan.environment.platform)
} else {
logWarn('logAllEnvironmentSettings', `NotePlan.environment not available until NP 3.3.2.`)
}
Expand Down
1 change: 0 additions & 1 deletion helpers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export function validateConfigProperties(config: { [string]: mixed }, validation
// failed += 'No validations provided'
}
if (failed !== '') {
// console.log(`Config failed minimum validation spec!\n>${failed}`)
throw new Error(failed)
} else {
return config
Expand Down
5 changes: 2 additions & 3 deletions helpers/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ export function getAllPropertyNames(inObj: interface { [string]: mixed }): Array
export const getFilteredProps = (object: any): Array<string> => {
const ignore = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'propertyIsEnumerable', 'isPrototypeOf']
if (typeof object !== 'object' || Array.isArray(object)) {
// console.log(`getFilteredProps improper type: ${typeof object}`)
return []
}
return getAllPropertyNames(object).filter((prop) => !/(^__)|(constructor)/.test(prop) && !ignore.includes(prop))
Expand Down Expand Up @@ -751,15 +750,15 @@ export function logTimer(functionName: string, startTime: Date, explanation: str
if (warningThreshold && difference > warningThreshold) {
// const msg = `${dt().padEnd(19)} | ⏱️ ⚠️ ${functionName} | ${output}`
const msg = `⏱️ ⚠️ ${output}`
// console.log(msg)

log(functionName, msg, 'DEBUG')
} else {
const pluginSettings = typeof DataStore !== 'undefined' ? DataStore.settings : null
// const timerSetting = pluginSettings['_logTimer'] ?? false
if (pluginSettings && pluginSettings.hasOwnProperty('_logTimer') && pluginSettings['_logTimer'] === true) {
// const msg = `${dt().padEnd(19)} | ⏱️ ${functionName} | ${output}`
const msg = `⏱️ ${output}`
// console.log(msg)

log(functionName, msg, 'DEBUG')
}
}
Expand Down
24 changes: 21 additions & 3 deletions helpers/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,30 @@ constructor(iterable ?: Iterable < [string, TVal] >) {
}
}

<<<<<<< Updated upstream
set(key: string, value: TVal): this {
const keyLowerCase = typeof key === 'string' ? key.toLowerCase() : key
if (!this.#keysMap.has(keyLowerCase)) {
this.#keysMap.set(keyLowerCase, key) // e.g. 'test': 'TEst'
// console.log(`new map entry: public '${keyLowerCase}' and private '${key}'`)
||||||| Stash base
set(key: string, value: TVal): this {
const keyLowerCase = typeof key === 'string' ? key.toLowerCase() : key
if (!this.#keysMap.has(keyLowerCase)) {
this.#keysMap.set(keyLowerCase, key) // e.g. 'test': 'TEst'
// console.log(`new map entry: public '${keyLowerCase}' and private '${key}'`)
}
super.set(keyLowerCase, value) // set main Map to use 'test': value
return this
=======
set(key: string, value: TVal): this {
const keyLowerCase = typeof key === 'string' ? key.toLowerCase() : key
if (!this.#keysMap.has(keyLowerCase)) {
this.#keysMap.set(keyLowerCase, key) // e.g. 'test': 'TEst'
}
super.set(keyLowerCase, value) // set main Map to use 'test': value
return this
>>>>>>> Stashed changes
}
super.set(keyLowerCase, value) // set main Map to use 'test': value
return this
Expand Down Expand Up @@ -257,7 +276,7 @@ export function createOpenOrDeleteNoteCallbackUrl(
const paramStr = isLineLink ? 'noteTitle' : isFilename ? `filename` : paramType === 'date' ? `noteDate` : `noteTitle`
const xcb = `noteplan://x-callback-url/${isDeleteNote ? 'deleteNote' : 'openNote'}?${paramStr}=`
const head = heading && heading.length ? encodePlusParens(heading.replace('#', '')) : ''
// console.log(`createOpenOrDeleteNoteCallbackUrl: ${xcb}${titleOrFilename}${head ? `&heading=${head}` : ''}`)

const encodedTitleOrFilename = encodePlusParens(titleOrFilename)
const openAs = openType && ['subWindow', 'splitView', 'useExistingSubWindow'].includes(openType) ? `&${openType}=yes` : ''
let retVal = ''
Expand Down Expand Up @@ -392,7 +411,6 @@ export function createPrettyRunPluginLink(linkText: string, pluginID: string, co
* @tests available
*/
export function getStringFromList(list: $ReadOnlyArray<string>, search: string): string {
// console.log(`getsearchFromList for: ${search}`)
const res = list.filter((m) => m === search)
return res.length > 0 ? res[0] : ''
}
Expand Down Expand Up @@ -457,7 +475,7 @@ export async function getTagParamsFromString(paramString: string, wantedParam: s
}
// $FlowIgnore(incompatible-type) as can produce 'any'
const paramObj: {} = await json5.parse(paramString)
// console.log(typeof paramObj)

if (typeof paramObj !== 'object') {
throw new Error('JSON5 parsing did not return an object')
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ export function filterOutParasInExcludeFolders(paras: Array<TParagraph>, exclude
const thisNoteFilename = p.note?.filename ?? 'error'
const thisNoteFolder = getFolderFromFilename(thisNoteFilename)
const isInWantedFolder = (includeCalendar && p.noteType === 'Calendar') || wantedFolders.includes(thisNoteFolder)
// console.log(`${thisNoteFilename} isInWantedFolder = ${String(isInWantedFolder)}`)

return isInWantedFolder
})
return parasFiltered
Expand Down
1 change: 0 additions & 1 deletion helpers/react/ThemedSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ const colourStyles = {
// option: (styles: StyleObject) => ({ ...styles, backgroundColor: NP_THEME.base.backgroundColor, color: NP_THEME.base.textColor ?? 'black' }),
// option: (styles, { data, isDisabled, isFocused, isSelected }) => {
option: (styles: StyleObject, { isDisabled, isSelected }) => {
// console.log('option', styles, data, isDisabled, isFocused, isSelected)
return {
...styles,
// backgroundColor: isDisabled ? undefined : isSelected ? bgColor.css() : isFocused ? bgColor.alpha(0.1).css() : bgColor.css(),
Expand Down
8 changes: 4 additions & 4 deletions helpers/sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export const isTask = (para: TParagraph): boolean => TASK_TYPES.indexOf(para.typ
* @param {Array<string>} field list - property array, e.g. ['date', 'title']
* @returns {Function} callback function for sort()
*/
export const fieldSorter = (fields: Array<string>): Function =>
export const fieldSorter =
(fields: Array<string>): Function =>
(a: string, b: string) =>
fields
.map((_field) => {
Expand Down Expand Up @@ -246,7 +247,7 @@ export function getSortableTask(para: TParagraph): SortableParagraphSubset {
type: para.type,
calculatedType: calculateParagraphType(para),
}
// console.log(`new: ${index}: indents:${para.indents} ${para.rawContent}`)

task.priority = getNumericPriority(task)
return task
}
Expand All @@ -267,7 +268,7 @@ export function getTasksByType(paragraphs: $ReadOnlyArray<TParagraph>, ignoreInd
// logDebug('getTasksByType', `${para.lineIndex}: ${para.type}`)
if (isTask || (!ignoreIndents && para.indents > lastParent.indents)) {
// const content = para.content // Not used
// console.log(`found: ${index}: ${para.type}: ${para.content}`)

try {
const task: SortableParagraphSubset = getSortableTask(para)
if (!ignoreIndents && para.indents > lastParent.indents) {
Expand All @@ -283,7 +284,6 @@ export function getTasksByType(paragraphs: $ReadOnlyArray<TParagraph>, ignoreInd
logError('getTasksByType', `${error.message}: ${para.content}, ${index}`)
}
} else {
// console.log(`\t\tSkip: ${para.content}`) //not a task
}
}

Expand Down
Loading
Loading