question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using not depended to codemirror.js

See original GitHub issue

Without loading codemirror, color picker cannot be initiated

//include colorpicker js file and css file then=>

var ColorPicker = CodeMirrorColorPicker.ColorPicker;
var colorpicker = new ColorPicker({
    color: 'blue', // init color code 
    type : 'palette' // or 'sketch',  default type is 'chromedevtool'
})

this throws an error “Uncaught ReferenceError: CodeMirrorColorPicker is not defined”

To make it accessible I added one line to the end of ColorPicker method in the js file.

var index = _extends({}, Util, ColorPicker);
// added this line -->
window.CMColorPicker=ColorPicker.ColorPicker;
//--
return index;

and then tried


 var colorpicker = new CMColorPicker({
        color: 'blue',  
        position: 'inline',   
        container : $('color-container'),
        type : 'ring'
    });

This makes it work, But some types displayed distorted. please see attached file. This is how “ring” type is displayed.

screenshot_1

By the way I think this is one of the best color picker tool on the web. Great job!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
easylogiccommented, Oct 8, 2018

@zortext

haha my mistake.

see to below code

        var picker = CodeMirrorColorPicker.create({
            type: 'ring', 
            ......
        });

you must use function named by create to making for multi type colorpicker.

CodeMirrorColorPicker.ColorPicker is default colorpicker that has a ‘chromedevtool’ type

0reactions
zortextcommented, Oct 8, 2018

I found the issue. new CodeMirrorColorPicker.create() works fine new CodeMirrorColorPicker.ColorPicker() causes the issue.

https://codepen.io/anon/pen/EdNbEQ

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using not depended to codemirror.js · Issue #24 - GitHub
To make it accessible I added one line to the end of ColorPicker method in the js file. ... var colorpicker = new...
Read more >
CodeMirror 5 User Manual
CodeMirror works with language-specific modes. Modes are JavaScript programs that help color (and optionally indent) text written in a given language. The ...
Read more >
Reference Manual - CodeMirror
Not to be confused with EditorView.editable , which controls whether the editor's DOM is set to be editable (and thus focusable). static phrases:...
Read more >
CodeMirror System Guide
System Guide. This is the guide to the CodeMirror editor system. It provides a prose description of the system's functionality. For the item-by-item ......
Read more >
Cannot get CodeMirror to work when using require()
Hi, I installed CodeMirror via npm and cannot get it to work properbly when using require(). I've tried using this code: var js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found