-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Describe the bug
When I try to add a code block (using triple backticks, tildes, or indented code) to a note in the Local Notes addon, LocalWP crashes with the following error:
TypeError: languageDefinition.bind is not a function
This happens regardless of whether I specify a language (e.g., sh, shell, js) or leave it blank.
As a result, it is currently impossible to add code snippets or ASCII directory trees to notes.
To Reproduce
-
Open the Notes addon in LocalWP.
-
Add a new note with the following content (or any code block):
root/ |-- folder-1 |-- folder-2 |-- long-folder-name-for-giggles |-- scrapers \-- api-testing -
Save the note.
-
Observe that LocalWP shows an error popup (see screenshot) and the note is not saved.
Expected behavior
The note should render the code block as preformatted text, preserving whitespace and formatting, without crashing.
Screenshots
Environment
- LocalWP version: Version 9.2.5+6810
- Notes addon version: 1.2.2
- OS: Microsoft Windows 11 Pro, 10.0.26100 Build 26100
Additional context
- This occurs with any codefenced block (triple backticks, triple tildes, or indented code).
- Specifying a language (e.g.,
sh,shell,js) does not prevent the error. - Inline code (single backticks) works fine.
- The error appears to originate in the Markdown rendering pipeline, specifically when handling code block language definitions.
Relevant code (from repo):
// src/Note.jsx
import { InnerPaneSidebarContentItem, Markdown } from '@getflywheel/local-components';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
<Markdown src={this.props.body} />
</InnerPaneSidebarContentItem>;Stack trace (from error popup):
TypeError: languageDefinition.bind is not a function
Stack Trace:
in P
in div
in Root
in ReactMarkdown
in w
in div
in Unknown
in Note
in div
in Unknown
in div
in Unknown
in Notes
in div
in Unknown
in O
in e
in o
in Unknown
in e
in div
in o
in Unknown
in main
in l
in e
in o
in Unknown
in e
in Ca
in div
in Unknown
in Unknown
in e
in o
in Unknown
in e
in Unknown
in K
in withRouter(K)
in t
in MobXProvider
in Unknown
Suggested fix
Update the Markdown rendering logic to:
- Gracefully handle missing or unknown language definitions for code blocks.
- Default to plain text highlighting if the specified language is not found.
- Check that
languageDefinitionis a function before calling.bind().
According to Perplexity AI, The bug is in the Markdown component (or its syntax highlighting integration) in @getflywheel/local-components.
It should check if the language definition is a function before calling .bind(), or default to "plaintext" if the language is missing.
Example Fix (for maintainers):
const languageDef = getLanguageDefinition(language) || getLanguageDefinition('plaintext');
if (typeof languageDef === 'function') {
// safe to bind
}
Workaround
Currently, the only workaround is to avoid codefenced blocks, which makes it hard to share code or directory structures in notes.