markedjs实现完整markdown可视化可扩展编辑器代码

代码语言:html

所属分类:其他

代码描述:markedjs实现完整markdown可视化可扩展编辑器代码

代码标签: marked 完整 markdown 可视化 可扩展 编辑器 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>强大的 Markdown 编辑器</title>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/marked.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/purify.js"></script>
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.4.0.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            height: 100vh;
            overflow: hidden;
            background: #f5f5f5;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        .header h1 {
            font-size: 1.5em;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .toolbar {
            background: white;
            padding: 10px 20px;
            border-bottom: 1px solid #ddd;
            display: flex;
            gap: 5px;
            flex-wrap: wrap;
            box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        }

        .toolbar button {
            padding: 8px 12px;
            border: 1px solid #ddd;
            background: white;
            cursor: pointer;
            border-radius: 5px;
            transition: all 0.3s;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .toolbar button:hover {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }

        .toolbar button i {
            font-size: 16px;
        }

        .toolbar .divider {
            width: 1px;
            background: #ddd;
            margin: 0 5px;
        }

        .container {
            display: flex;
            height: calc(100vh - 120px);
        }

        .editor-pane, .preview-pane {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: white;
            margin: 10px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            overflow: hidden;
        }

        .pane-header {
            padding: 10px 15px;
            background: #f8f9fa;
            border-bottom: 2px solid #667eea;
            font-weight: bold;
            color: #333;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .pane-header .word-count {
            font-size: 0.85em;
            color: #666;
            font-weight: normal;
        }

        textarea {
            flex: 1;
            padding: 20px;
            border: none;
            outline: none;
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 14px;
            line-height: 1.6;
            resize: none;
            background: #fafafa;
        }

        .preview {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            line-height: 1.8;
        }

        /* Markdown 样式 */
        .preview h1 {
            font-size: 2em;
            margin: 0.5em 0;
            padding-bottom: 0.3em;
            border-bottom: 2px solid #eee;
            color: #333;
        }

        .preview h2 {
            font-size: 1.6em;
            margin: 0.5em 0;
            padding-bottom: 0.2em;
            border-bottom: 1px solid #eee;
            color: #444;
        }

        .preview h3 {
            font-size: 1.3em;
            margin: 0.5em 0;
            color: #555;
        }

        .preview h4, .preview h5, .preview h6 {
            margin: 0.5em 0;
            color: #666;
        }

        .preview p {
            margin: 1em 0;
            color: #333;
        }

        .preview code {
            background: #f4f4f4;
            padding: 2px 6px;
            border-radius: 3px;
            font-family: 'Consolas', 'Monaco', monospace;
            color: #e83e8c;
            font-size: 0.9em;
        }

        .preview pre {
            background: #2d2d2d;
            color: #f8f8f2;
            padding: 15px;
            border-radius: 5px;
            overflow-x: auto;
            margin: 1em 0;
        }

        .preview pre code {
            background: none;
            color: inherit;
            padding: 0;
        }

        .preview blockquote {
            border-left: 4px solid #667eea;
            padding-left: 15px;
            margin: 1em 0;
            color: #666;
            background: #f9f9f9;
            padding: 10px 15px;
            border-radius: 0 5px 5px 0;
        }

        .preview ul, .preview ol {
            margin: 1em 0;
            padding-left: 2em;
        }

        .preview li {.........完整代码请登录后点击上方下载按钮下载查看

网友评论0