简体   繁体   English

可以对RunKit进行样式设置吗?

[英]Is it possible to style RunKit?

Are there any possible ways to customize the styling of RunKit ( https://runkit.com )? 有什么可能的方法来自定义RunKit( https://runkit.com )的样式? Like make the background of the editor to dark theme. 就像使编辑器的背景以深色为主题。

I tried injecting styles to the RunKit iframe but it does not work. 我尝试将样式注入RunKit iframe,但是它不起作用。 Looking for any suggestions or any solutions. 寻找任何建议或解决方案。

1. Summary 1.总结

Use RunKit theme maker . 使用RunKit主题制作器

It not documented for June 2019. 它没有记录在2019年6月。


2. Demonstration 2.示范

Gutter line numbers in left side has a bad visible. 左侧的装订线行号可见不好。

之前

I edit Text parameter in theme-maker. 我在主题编辑器中编辑Text参数。

文本

后

(But besides line numbers RunKit also change text color of my notebook.) (但是,除了行号,RunKit还会更改笔记本的文本颜色。)


3. Disclaimer 3.免责声明

Data of this answer were relevant in June 2019 and may be obsolete in the future. 该答案的数据与2019年6月相关,将来可能已过时。

Method of this answer is uncomfortable, and I very hope that in the future there will be another. 这个答案的方法令人不舒服,我非常希望将来还会有另一种方法。


4. Note 4.注意

You can't overwrite embed RunKit and any another iframe styles of another domain via CSS: 您无法通过CSS覆盖嵌入RunKit和其他域的其他iframe样式:


5. Sources 5.资料来源

5.1. 5.1。 Without styles 没有样式

I attach RunKit to existing element . 将RunKit附加到现有元素

<script src="https://embed.runkit.com" data-element-id="KiraRunkit"></script>
<article>
    <pre id="KiraRunkit">
        var stringSimilarity = require('string-similarity')

        var similarity = stringSimilarity.compareTwoStrings('Кира', 'Кирк');
    </pre>
</article>
body
    height 100%
    overflow hidden
    background-color sienna

article
    margin-left 2rem
    margin-right 2rem

// [INFO] Responsive iframe:
// https://medium.com/@mahbub_hemel/how-to-make-your-video-iframe-responsive-a8c5fda821ba
#KiraRunkit
    width 100%
    position relative

iframe
    width 100%
    height 100%
    position absolute
    /* [INFO] Instead of frameborder — http://stackoverflow.com/a/10831379/5951529 */
    border 0

5.2. 5.2。 With styles 随着风格

I programmaticaly create a notebook . 我以编程方式创建一个笔记本 Options: 选项:

  • element — HTML element, for which you will apply RunKit. element — HTML元素,您将对其应用RunKit。
  • source — full source of your RunKit notebook; source -RunKit笔记本的完整来源; use \\n for line breaking. 使用\\n换行。
  • syntaxTheme — theme, that you create. syntaxTheme —您创建的主题。

JavaScript code you find in your theme-maker page . 您可以在主题创建者页面中找到的JavaScript代码。

<script src="https://embed.runkit.com"></script>
<article>
    <div id="KiraRunkit"></div>
</article>
body
    height 100%
    overflow hidden
    background-color sienna

article
    margin-left 2rem
    margin-right 2rem

// [INFO] Responsive iframe:
// https://medium.com/@mahbub_hemel/how-to-make-your-video-iframe-responsive-a8c5fda821ba
#KiraRunkit
    width 100%
    position relative

iframe
    width 100%
    height 100%
    position absolute
    /* [INFO] Instead of frameborder — http://stackoverflow.com/a/10831379/5951529 */
    border 0
##########
# RunKit #
##########
# Run npm code online in browser:
# https://runkit.com
# Needs use theme-maker, that change styles:
# https://runkit.com/docs/theme-maker
notebook = RunKit.createNotebook(
    # [NOTE] Id required, class will not work
    element: document.getElementById('KiraRunkit')
    # [NOTE] You need paste here content of your RunKit notebook even if it big:
    source: 'var stringSimilarity = require(\'string-similarity\')\n\n\
                var similarity = stringSimilarity.compareTwoStrings(\'Кира\', \'Кирк\');'
    # [INFO] https://runkit.com/docs/theme-maker/untilted-2jxk2crve1p7 theme
    syntaxTheme: 'untilted-028u85ijnoyr')

6. Problems 6.问题

You can have these problems, when you edit your theme via theme-maker : 当您通过theme-maker编辑主题时,可能会遇到以下问题:

  1. If you need set exact color, You have to work hard, that make it in theme-maker. 如果需要设置准确的颜色,则必须努力工作,这可以使它成为主题制作者。
  2. After the second and subsequent theme editions, changes may not display. 在第二版和后续主题版本之后,更改可能不会显示。
  3. Read notes in CoffeeScript file from previous section, that read about another limits. 阅读上一节中CoffeeScript文件中的注释,该注释了解其他限制。

7. Extra links 7.额外链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM