小编Jam*_*son的帖子

在选定区域插入新节点时,Slate.js 抛出错误

相关代码块:

        <Slate editor={editor} value={value} onChange={value => {
            setValue(value);

            const { selection } = editor;
            // if nothing is currently selected under the cursor
            if (selection && Range.isCollapsed(selection)) {
                const [start] = Range.edges(selection);
                // if the two characters beforce the cursor are {{, select them and replace with a template block
                const before = Editor.before(editor, start, {distance: 2})
                const beforeRange = before && Editor.range(editor, before, start)
                const beforeText = beforeRange && Editor.string(editor, beforeRange)
                const beforeMatch = beforeText && beforeText.match(/\{\{/);
                if (beforeMatch) …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs slatejs

5
推荐指数
1
解决办法
8880
查看次数

在没有jQuery的情况下复制jQuery slideToggle

由于Anki不支持jQuery,我如何在这个特定文档上转换jQuery,以便在vanilla JS中生成相同的效果,或者纯粹在CSS3中生成(特别是+按钮,并且在单击列表项时)?

$(document).ready(function () {
    $("#show-pronunciation").on("click", function () {
        $(".pronunciation").slideToggle();
    });
    $("li").on("click", function () {
        $(this).find("dl").slideToggle();
    });
});
Run Code Online (Sandbox Code Playgroud)
body {
    font-family: Avenir, Futura, sans-serif;
    background-color: #f7f7f7;
}

.definitions dl {
    border-left: 2px solid #ff1919;
    padding-left: 5px;    
}

dt {
    font-weight: bold;
}

dd {
    margin-left: 1em;
}

.main {
    margin: 20px 20px 0 20px;
    border: transparent;
    border-radius: 5px;
    /*padding: 15px 10px 5px 10px;*/
    border-collapse: collapse;
    background-color: #FF4C4C;
    padding-bottom: 5px;
}

.header {
    border-radius: 5px;
    padding: 5px;
    background-color: white;
}

.content …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery anki

3
推荐指数
1
解决办法
6299
查看次数

标签 统计

javascript ×2

anki ×1

css ×1

html ×1

jquery ×1

reactjs ×1

slatejs ×1

typescript ×1