继续操作前请注册或者登录。

你正在訪問的內容是外部程式的映像位址,僅用於使用者加速訪問,本站無法保證其可靠性。當前的連結位址(單點即可複製)為 https://greasyfork.org.cn/zh-CN/scripts/502637-summernote-to-markdown-for-kanka/discussions/318961,源站連結 點此以跳轉

Summernote to Markdown for Kanka

Adds bidirectional Markdown conversion to Kanka editors

< 脚本 Summernote to Markdown for Kanka 的反馈

提问 / 留言

§
发布于:2026-01-09

Hello! Love this script but it doesn't on Chrome (I'm on Vivaldi).

The script likely isn't working in Vivaldi because the summernote.init event may fire before your Tampermonkey script executes, or Vivaldi's timing differs from Firefox.

You can make it work on Chrome with following check at the end tho:

// ==UserScript==
// @name         Summernote to Markdown for Kanka
// @namespace    http://tampermonkey.net/
// @license      MIT
// @version      1.1
// @description  Adds bidirectional Markdown conversion to Kanka editors
// @author       Salvatos
// @match        https://app.kanka.io/*
// @icon         https://www.google.com/s2/favicons?domain=kanka.io
// @require      https://cdnjs.cloudflare.com/ajax/libs/showdown/2.1.0/showdown.min.js
// @grant        none
// @run-at       document-end
// ==/UserScript==

function initMarkdownEditor() {
    // Set up Showdown converter
    var converter = new showdown.Converter({
        simpleLineBreaks: true,
        simplifiedAutoLink: true,
        strikethrough: true,
        tables: true,
        underline: true
    });

    // Add HTML
    var mdInput = `<details>
    <summary class="text-center text-lg cursor-pointer">Markdown Editor <sup style="font-variant: all-small-caps;font-weight: 600">Experimental!</sup></summary>
    <p>The following field converts the Summernote entry above to Markdown in real time. Changes made to it are also reflected back to the editor.</p>
    <textarea id="markdown-input" name="markdown" rows="5" class="w-full html-editor"></textarea>
    </details>`;

    document.querySelector(".note-editor").insertAdjacentHTML("afterend", mdInput);
    mdInput = document.getElementById("markdown-input");
    document.querySelector(".note-editor").style.marginBottom = "0";

    // Populate MD on load
    mdInput.value = converter.makeMarkdown(document.getElementById("entry").value);

    // Add change event to textarea
    mdInput.addEventListener('input', function( e ) {
        document.querySelector(".html-editor").value = document.querySelector(".note-editable").innerHTML = document.querySelector(".note-codable").value = converter.makeHtml(mdInput.value);
    });

    // Add change event to Summernote
    $('.html-editor').on('summernote.change.codeview', function(we, contents, $editable) {
        mdInput.value = converter.makeMarkdown(contents);
    });
}

// Try to initialize immediately if Summernote already loaded
if ($('.html-editor').data('summernote')) {
    initMarkdownEditor();
} else {
    // Otherwise wait for init event
    $('.html-editor').on('summernote.init', initMarkdownEditor);
}

Maybe you'll find that helpful, cheers!

发布留言

登录以发布留言。