holoviz / panel
1
"""
2
Defines custom AcePlot bokeh model to render Ace editor.
3
"""
4 7
from bokeh.core.properties import String, Override, Dict, Any, List, Bool, Enum, Nullable
5 7
from bokeh.models import HTMLBox
6

7 7
from ..io.resources import bundled_files
8 7
from ..util import classproperty
9 7
from .enums import ace_themes
10

11

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

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

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

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

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

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

49 7
    code = String()
50

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

53 7
    filename = Nullable(String())
54

55 7
    language = String()
56

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

59 7
    readonly = Bool(default=False)
60

61 7
    print_margin = Bool(default=False)
62

63 7
    height = Override(default=300)
64

65 7
    width = Override(default=300)

Read our documentation on viewing source code .

Loading