1
"""
2
Defines custom AcePlot bokeh model to render Ace editor.
3
"""
4 7
from __future__ import absolute_import, division, unicode_literals
5

6 7
from bokeh.core.properties import String, Override, Dict, Any, List, Bool, Enum
7 7
from bokeh.models import HTMLBox
8

9 7
from ..util import classproperty, bundled_files
10 7
from .enums import ace_themes
11

12

13 7
class AcePlot(HTMLBox):
14
    """
15
    A Bokeh model that wraps around a Ace editor and renders it inside
16
    a Bokeh plot.
17
    """
18

19 7
    __javascript_raw__ = [
20
        'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ace.js',
21
        'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ext-language_tools.js',
22
        'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ext-modelist.js'
23
    ]
24

25 7
    __tarball__ = {
26
        'tar': 'https://registry.npmjs.org/ace-builds/-/ace-builds-1.4.11.tgz',
27
        'src': 'package/src-min/',
28
        'dest': 'ajax/libs/1.4.11',
29
        'exclude': ['snippets']
30
    }
31

32 7
    @classproperty
33 2
    def __javascript__(cls):
34 7
        return bundled_files(cls)
35

36 7
    @classproperty
37 2
    def __js_skip__(cls):
38 0
        return {'ace': cls.__javascript__}
39

40 7
    __js_require__ = {
41
        'paths': {
42
            ('ace', ('ace/ace', 'ace/ext-language_tools')): '//cdnjs.cloudflare.com/ajax/libs/ace/1.4.7'},
43
        'exports': {'ace': 'ace'},
44
        'shim': {
45
            'ace/ext-language_tools': { 'deps': ["ace/ace"] },
46
            'ace/ext-modelist': { 'deps': ["ace/ace"] }
47
        }
48
    }
49

50 7
    code = String()
51

52 7
    theme = Enum(ace_themes, default='chrome')
53

54 7
    filename = String()
55

56 7
    language = String()
57

58 7
    annotations = List(Dict(String, Any), default=[])
59

60 7
    readonly = Bool(default=False)
61

62 7
    print_margin = Bool(default=False)
63

64 7
    height = Override(default=300)
65

66 7
    width = Override(default=300)

Read our documentation on viewing source code .

Loading