-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
140 lines (137 loc) · 6.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html>
<head>
<!--OGP -->
<meta property="og:title" content="青空文庫エディター">
<meta property="og:type" content="website">
<meta property="og:url" content="https://kyukyunyorituryo.github.io/AozoraEditor/">
<meta property="og:image" content="https://kyukyunyorituryo.github.io/AozoraEditor/document_syorui_pen.png">
<meta property="og:site_name" content="青空文庫エディター">
<meta property="og:description" content="青空文庫エディターでテキストを編集してEPUB作成などに使う">
<!--Twitterカード -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@99nyorituryo">
<meta name="twitter:creator" content="@99nyorituryo">
<meta name="twitter:title" content="青空文庫エディター">
<meta name="twitter:description" content="青空文庫エディターでテキストを編集してEPUB作成などに使う">
<meta name="twitter:image:src" content="https://kyukyunyorituryo.github.io/AozoraEditor/document_syorui_pen.png">
<style>
div.mce-edit-area {
background: #FFF;
filter: none;
padding: 10px;
}
</style>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-J8FW91ELEL"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-J8FW91ELEL');
</script>
<script src="./dist/turndown.js"></script>
<script src='aozora.js'></script>
<script src="tinymce/tinymce.min.js" referrerpolicy="origin"></script>
<script>
tinymce.init({
selector: '#text', language: "ja",
font_formats: "明朝系=MS P明朝,ヒラギノ明朝 Pro W3,serif; ゴシック系=MS Pゴシック,Osaka,ヒラギノ角ゴ Pro W3,sans-serif",
convert_newlines_to_brs: true,
plugins: ['advlist', 'autolink',
'lists', 'link', 'image', 'charmap', 'preview', 'anchor', 'searchreplace', 'visualblocks',
'fullscreen', 'insertdatetime', 'media', 'help', 'wordcount', 'code', 'codesample', 'save', 'furigana', 'tcy', 'tateyoko'
],
toolbar1: 'undo redo | formatpainter casechange blocks | furigana tcy tateyoko bold italic underline strikethrough blockquote subscript superscript h1 h2 image fullscreen link code codesample preview| ',
toolbar2: 'alignleft aligncenter alignright alignjustify | ' +
'bullist numlist checklist outdent indent | removeformat | help',
formats: {
underline: { inline: 'u', exact: true },
/*
bold: {inline: 'span', 'classes': 'bold'},
italic: {inline: 'span', 'classes': 'italic'},
underline: {inline: 'span', 'classes': 'em-line-outside'},
strikethrough: {inline: 'span', 'classes': 'line-through'},
subscript: {inline: 'span', 'classes': 'sub'},
superscript: {inline: 'span', 'classes': 'super'},
h1: {block: 'h1', 'classes': 'font-1em50'},
h2: {block: 'h2', 'classes': 'font-1em30'},
h3: {block: 'h3', 'classes': 'font-1em10'},
alignright: {block: 'div', 'classes': 'btm', wrapper: true},
*/
tcy: { inline: 'span', 'classes': 'tcy' }
},
content_css: "style/book-style.css",
body_class: "hltr"
});</script>
<script>
function convertToAozora() {
options = {
"headingTop": "h1",
"bulletListMarker": "● ",
"codeBlockStyle": "indented",
"boldDelimiter": "太字",
"strongDelimiter": "太字",
"emDelimiter": "斜体",
"italicDelimiter": "斜体"
}
var turndownService = new window.TurndownService(options)
text = tinyMCE.get("text").getContent();
text2 = text.replace(/<p> <\/p>/g, "<p><br></p>");
value = turndownService.turndown(text2)
document.getElementById("view").value = value
}
</script>
<script>
function convertToHtml() {
aozora_text = document.getElementById("view").value
html = AozoraText2Html(aozora_text)
tinymce.activeEditor.setContent(html);
}
</script>
<script>
async function fileopen() {
[fileHandle] = await window.showOpenFilePicker();
const file = await fileHandle.getFile();
const fileContents = await file.text();
document.getElementById("view").value=fileContents;
}
async function filewrite() {
const writable = await fileHandle.createWritable();
await writable.write(document.getElementById("view").value);
await writable.close();
}
</script>
</head>
<body>
<h2>青空文庫エディター</h2>
<a href="https://github.com/kyukyunyorituryo/AozoraEditor"><p>Githubで公開中</p></a>
<textarea id="text"><h1>見出し1</h1>
<h2>見出し2</h2>
<p>ふりがな</p>
<p><ruby>漢字<rt>かんじ</rt></ruby></p>
<p>縦中横</p>
<p><span class="tcy">12</span>月<span class="tcy">12</span>日</p>
<p>挿絵</p>
<p><img src="test.png" alt="テスト画像"></p>
<p>hr区切り</p>
<hr>
<p>linkタグ</p>
<p><a href="https://kyukyunyorituryo.github.io/">https://kyukyunyorituryo.github.io/</a></p>
<p>リストタグ</p>
<ul>
<li>リスト1</li>
<li>リスト2</li>
</ul>
<p> </p>
<p><strong>太字</strong><p><span class="em-sesame">傍点</span></p><p><span class="em-line">傍線</span></p><p><em>斜体</em></p><p><u>下線</u></p><p><s>打ち消し</s></p><p>下<sub>付き</sub></p><p>上<sup>付き</sup></p></textarea>
<button onclick="convertToAozora()">青空文庫変換</button>
<button onclick="convertToHtml()">エディターへ出力</button>
<h2>青空文庫</h2>
<textarea id="view" rows="10" cols="110"></textarea>
<p></p>
<button onclick="fileopen()">ファイルの読み込み</button>
<button onclick="filewrite()">保存</button>
</body><p>
<a href="https://github.com/gearsns/AozoraJavaScriptParser">AozoraJavaScriptParser</a>を使用しています。</p>
</html>