๐Ÿ“ฆ n8n-io / codemirror-lang-n8n

n8n expression language support for CodeMirror

โ˜… 3 stars โ‘‚ 4 forks ๐Ÿ‘ 3 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/n8n-io/codemirror-lang-n8n.git
HTTPS git clone https://github.com/n8n-io/codemirror-lang-n8n.git
SSH git clone git@github.com:n8n-io/codemirror-lang-n8n.git
CLI gh repo clone n8n-io/codemirror-lang-n8n
Loading files...
๐Ÿ“„ README.md

codemirror-lang-n8n-expression

n8n expression language support for CodeMirror 6.

Usage

Install n8n expression language support:

npm i codemirror-lang-n8n-expression

Install setup dependencies:

npm i @codemirror/language @lezer/common @lezer/javascript

Set up language support:

import { parserWithMetaData as n8nParser } from 'codemirror-lang-n8n-expression';
import { LanguageSupport, LRLanguage } from '@codemirror/language';
import { parseMixed } from '@lezer/common';
import { parser as jsParser } from '@lezer/javascript';

const n8nPlusJsParser = n8nParser.configure({
	wrap: parseMixed((node) => {
		if (node.type.isTop) return null;

		return node.name === 'Resolvable'
			? { parser: jsParser, overlay: (node) => node.type.name === 'Resolvable' }
			: null;
	}),
});

const n8nLanguage = LRLanguage.define({ parser: n8nPlusJsParser });

export function n8nExpressionLanguageSupport() {
	return new LanguageSupport(n8nLanguage);
}

Author

ยฉ 2022 Ivรกn Ovejero

License

Distributed under the MIT License.