codemirror-sfmc
v0.1.0
Published
CodeMirror 6 extensions for Salesforce Marketing Cloud templates (HTML with AMPscript / SSJS): highlighting theme, completion wired to sfmc-language-lsp.
Maintainers
Readme
codemirror-sfmc
CodeMirror 6 extensions for Salesforce Marketing Cloud HTML templates: embedded AMPscript and SSJS highlighting and autocompletion powered by sfmc-language-lsp.
Usage
Install CodeMirror 6 (@codemirror/state, @codemirror/view, and your preferred basic setup, e.g. the codemirror meta-package) then add:
import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { sfmcTemplateExtensions } from 'codemirror-sfmc';
const state = EditorState.create({
doc: '<html>%%=Concat("a","b")=%%</html>',
extensions: [
/* your basic keymap / line numbers here */
...sfmcTemplateExtensions(),
],
});
new EditorView({ state, parent: document.body });Language detection matches the VS Code extension: AMPscript markers (%%[, %%=, language="ampscript") take priority over <script runat="server"> for SSJS.
Exports
sfmcTemplateExtensions()— highlight plugin + theme + autocompletion.sfmcTemplateHighlightPlugin,sfmcEditorTheme,sfmcAutocomplete()— compose your own stack.codemirror-sfmc/detect—detectTemplateLanguageand helpers without pulling in@codemirror/*(for thin browser bundles).
License
MIT — see LICENSE.
