luwes / luwes/craft-codemirror

JavaScript JSON mode

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17
Forks
10
PR merge metrics
No merged PRs in 30d

Description

CodeMirror JavaScript mode supports additional configuration options, allowing to display json, json-ld and typescript ([doc](https://codemirror.net/5/mode/javascript/))

I need the JSON mode, not sure how this could be configured right now.

CodeMirror supports using mime types as mode values, and then it automatically maps to correct mode, setting `application/json` is internally replaced with `json: true, mode: javascript` but setting mime type in the plugin config does not works correctly as it tries to load a js file `mode/application/json.js` that actually is not there.

This could be fixed by using the same mode resolving logic that CodeMirror has - https://github.com/codemirror/codemirror5/blob/e84384b4210bc35300994de07c6333666f2a5c9e/src/modes.js#L20C1-L20C1 and https://github.com/codemirror/codemirror5/blob/e84384b4210bc35300994de07c6333666f2a5c9e/mode/javascript/javascript.js#L953

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the plugin config resolves and loads a mode when given a MIME type. Compare that behavior with CodeMirror’s src/modes.js and mode/javascript/javascript.js logic for application/json; done means JSON, JSON-LD, and TypeScript modes resolve without attempting to load a nonexistent mode/application/json.js file.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.