You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A modern, feature-rich text editor for TiddlyWiki5 based on CodeMirror 6, providing syntax highlighting, intelligent autocompletion, code folding, linting, and extensive customization options.
// Get/set contentengine.getText()// Get full document textengine.setText(text)// Set document textengine.getLine(n)// Get line n (1-based)engine.getLineCount()// Get number of linesengine.getRange(from,to)// Get text in rangeengine.replaceRange(from,to,text)// Replace range with textengine.insert(text,pos)// Insert text at position
Selection & Cursor
engine.getCursor()// Get cursor positionengine.setCursor(pos)// Set cursor positionengine.getSelection()// Get selection infoengine.setSelection(anchor,head)// Set selectionengine.selectAll()// Select all textengine.replaceSelection(text)// Replace selection
History
engine.undo()// Undo last changeengine.redo()// Redo last undone changeengine.canUndo()// Check if undo availableengine.canRedo()// Check if redo available
engine.foldAt(pos)// Fold at positionengine.unfoldAt(pos)// Unfold at positionengine.foldAll()// Fold all regionsengine.unfoldAll()// Unfold all regionsengine.toggleFold(pos)// Toggle fold stateengine.isFoldable(pos)// Check if foldableengine.getFoldedRanges()// Get folded ranges
Search
engine.openSearch()// Open search panelengine.closeSearch()// Close search panelengine.findNext()// Find next matchengine.findPrevious()// Find previous matchengine.replaceNext()// Replace next matchengine.replaceAll()// Replace all matches
Navigation
engine.navigateToTiddler(title)// Navigate to tiddlerengine.openTiddlerInNewWindow(title)// Open in new windowengine.getLinkAtCursor()// Get link under cursor
Snippets
engine.getUserSnippets()// Get user-defined snippetsengine.getSnippets(contentType)// Get snippets for content typeengine.insertUserSnippet(trigger)// Insert snippet by triggerengine.clearSnippetCache()// Clear snippet cache
Linting
engine.lint()// Force lint checkengine.nextDiagnostic()// Go to next issueengine.previousDiagnostic()// Go to previous issue
Configuration
engine.setLineNumbers(show)// Show/hide line numbersengine.setLineWrapping(wrap)// Enable/disable wrappingengine.setHighlightActiveLine(show)// Enable/disable active lineengine.setFoldGutter(show)// Show/hide fold gutterengine.setTheme(themeName)// Change themeengine.reconfigure(key,extension)// Reconfigure compartment
Developer Guide
Creating a Plugin
Plugins use the module-type: codemirror6-plugin format:
/*\title: $:/plugins/yourname/myplugin/plugin.jstype: application/javascriptmodule-type: codemirror6-plugin\*/(function(){"use strict";exports.plugin={// Required: Unique plugin namename: "my-plugin",// Optional: Descriptiondescription: "My custom plugin",// Optional: Load order (higher = earlier, default: 0)priority: 50,// Optional: Conditional loadingcondition: function(context){// Return true to load, false to skipreturncontext.tiddlerType==="text/vnd.tiddlywiki";},// Optional: Initialize with CM6 core referenceinit: function(cm6Core){this._core=cm6Core;},// Optional: Register compartments for dynamic configregisterCompartments: function(){return{myFeature: newthis._core.state.Compartment()};},// Required: Return CodeMirror 6 extensionsgetExtensions: function(context){return[// Your CM6 extensions];},// Optional: Add methods to engine APIextendAPI: function(engine,context){return{myMethod: function(){returnengine.getText();}};},// Optional: Register event handlersregisterEvents: function(engine,context){return{settingsChanged: function(settings){if(settings.myFeature!==undefined){engine.reconfigure("myFeature",settings.myFeature ? myExtension : []);}}};}};})();
# Install dependencies
npm install
# Build everything (ESM, CJS, types, TiddlyWiki plugin)
npm run build
# Build individual targets
npm run build:parser # Parser only (dist/parser.js)
npm run build:codemirror # Full bundle (dist/index.js)
npm run build:tiddlywiki # TiddlyWiki plugin (plugins/lang-tiddlywiki/)# Development
npm run dev # Watch mode with rebuilds# Clean
npm run clean # Remove dist/ directory# Test
npm test# Run test suite
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
About
The source code for lang-tiddlywiki and TW5's CM6 lang-* plugins