@@ -3,6 +3,47 @@ import {styled} from "goober";
33
44import Quill from 'quill' ;
55import './quill.css' ;
6+ import hljs from 'highlight.js' ;
7+ import './hljs.css' ;
8+
9+ const CODE_LANGUAGES = [
10+ { key : 'plain' , label : 'Plain' } ,
11+ { key : 'asciidoc' , label : 'Asciidoc' } ,
12+ { key : 'bash' , label : 'Bash' } ,
13+ { key : 'c' , label : 'C' } ,
14+ { key : 'cpp' , label : 'C++' } ,
15+ { key : 'csharp' , label : 'C#' } ,
16+ { key : 'css' , label : 'CSS' } ,
17+ { key : 'csv' , label : 'CSV' } ,
18+ { key : 'diff' , label : 'Diff' } ,
19+ { key : 'elixir' , label : 'Elixir' } ,
20+ { key : 'go' , label : 'Go' } ,
21+ { key : 'html' , label : 'HTML' } ,
22+ { key : 'java' , label : 'Java' } ,
23+ { key : 'javascript' , label : 'JavaScript' } ,
24+ { key : 'json' , label : 'JSON' } ,
25+ { key : 'jsx' , label : 'JSX' } ,
26+ { key : 'kotlin' , label : 'Kotlin' } ,
27+ { key : 'lua' , label : 'Lua' } ,
28+ { key : 'markdown' , label : 'Markdown' } ,
29+ { key : 'nix' , label : 'Nix' } ,
30+ { key : 'perl' , label : 'Perl' } ,
31+ { key : 'php' , label : 'PHP' } ,
32+ { key : 'python' , label : 'Python' } ,
33+ { key : 'ruby' , label : 'Ruby' } ,
34+ { key : 'rust' , label : 'Rust' } ,
35+ { key : 'scss' , label : 'SCSS' } ,
36+ { key : 'shell' , label : 'Shell' } ,
37+ { key : 'solidity' , label : 'Solidity' } ,
38+ { key : 'sql' , label : 'SQL' } ,
39+ { key : 'swift' , label : 'Swift' } ,
40+ { key : 'toml' , label : 'TOML' } ,
41+ { key : 'tsx' , label : 'TSX' } ,
42+ { key : 'typescript' , label : 'TypeScript' } ,
43+ { key : 'xml' , label : 'XML' } ,
44+ { key : 'yaml' , label : 'YAML' } ,
45+ { key : 'zig' , label : 'Zig' } ,
46+ ] ;
647import { MarkdownShortcuts } from "./quill-markdown" ;
748import snApi from "sn-extension-api" ;
849import { getPreviewText } from "./utils" ;
@@ -22,6 +63,8 @@ Quill.register(DividerBlot as any, true);
2263
2364const icons = Quill . import ( 'ui/icons' ) as Record < string , string > ;
2465icons . divider = '<svg viewBox="0 0 18 18" class="ql-fill"><rect height="2" width="14" x="2" y="8"></rect></svg>' ;
66+ // https://github.com/slab/quill/pull/3917
67+ icons [ 'code-block' ] = '<svg viewBox="0 0 18 18" transform="scale(0.8)"> <polyline class="ql-even ql-stroke" points="5 7 3 9 5 11" transform="scale(0.9)"></polyline> <polyline class="ql-even ql-stroke" points="13 7 15 9 13 11" transform="scale(0.9)"></polyline> <line class="ql-stroke" x1="10" x2="8" y1="5" y2="13" transform="scale(0.9)"></line> <path d="M0.868784,12.949447v4.05075l16.147395-.000001v-16.098555c0,0-2.647404,0-3.782006,0" fill="none" stroke-linecap="round" stroke-linejoin="round" class="ql-stroke" style="stroke-width: 2;"></path></svg>' ;
2568
2669const Container = styled ( 'div' ) `
2770 position: absolute;
@@ -40,7 +83,7 @@ const QuillEditor = () => {
4083 readOnly : snApi . locked ,
4184 modules : {
4285 toolbar : [
43- [ { 'font' : Font . whitelist } , { 'header' : '1' } , { 'header' : '2' } , 'bold' , 'italic' , 'underline' , 'strike' , 'blockquote' , 'code' , 'link' , 'image' , 'divider' , { 'list' : 'ordered' } , { 'list' : 'bullet' } , { 'align' : [ ] } , { 'color' : [ ] } , { 'background' : [ ] } , 'clean' ] ,
86+ [ { 'font' : Font . whitelist } , { 'header' : '1' } , { 'header' : '2' } , 'bold' , 'italic' , 'underline' , 'strike' , 'blockquote' , 'code' , 'code-block' , ' link', 'image' , 'divider' , { 'list' : 'ordered' } , { 'list' : 'bullet' } , { 'align' : [ ] } , { 'color' : [ ] } , { 'background' : [ ] } , 'clean' ] ,
4487 ] ,
4588 keyboard : {
4689 bindings : {
@@ -57,6 +100,7 @@ const QuillEditor = () => {
57100 }
58101 } ,
59102 markdown : { } ,
103+ syntax : { hljs, languages : CODE_LANGUAGES } ,
60104 } ,
61105 theme : 'snow' ,
62106 } ) ;
0 commit comments