diff --git a/blocks.test.ts b/blocks.test.ts index 361a167..5c827ae 100644 --- a/blocks.test.ts +++ b/blocks.test.ts @@ -375,6 +375,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://scrapbox.io/help-jp/ブラケティング", + "space": " ", "title": "外部プロジェクトリンク(scrapbox.io)", "content": "外部プロジェクトリンク(scrapbox.io) https://scrapbox.io/help-jp/ブラケティング", @@ -384,6 +385,48 @@ const lines: Line[] = [{ "children": "外部プロジェクトリンク(scrapbox.io) https://scrapbox.io/help-jp/ブラケティング", }, +}, { + "id": "676646f11280f000000d134a", + "text": + "生のURLもリンクとして認識される:https://example.com 空白を末尾に入れれば、それ以降の文字列をURLから切り離せる", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767911, + "updated": 1734767912, + "section": { "number": 2, "start": false, "end": false }, + "nodes": ["生のURLもリンクとして認識される:", { + "type": "url", + "unit": { + "content": "https://example.com", + "whole": "https://example.com", + }, + "children": "https://example.com", + }, " 空白を末尾に入れれば、それ以降の文字列をURLから切り離せる"], +}, { + "id": "676647221280f000000d134b", + "text": + "`[]`で囲めば、[https://example.com]のように空白を入れずに文章をつなげられる", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767912, + "updated": 1734767912, + "section": { "number": 2, "start": false, "end": false }, + "nodes": [ + { + "type": "code", + "unit": { "whole": "`[]`", "content": "[]" }, + "children": "[]", + }, + "で囲めば、", + { + "type": "urlLink", + "unit": { + "link": "https://example.com", + "content": "https://example.com", + "whole": "[https://example.com]", + }, + "children": "https://example.com", + }, + "のように空白を入れずに文章をつなげられる", + ], }, { "id": "61fe3cbf7838e300001888ec", "text": "", @@ -438,6 +481,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://example.com/", + "space": " ", "title": "外部サイトリンク", "content": "外部サイトリンク https://example.com/", "whole": "[外部サイトリンク https://example.com/]", @@ -466,6 +510,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://twitter.com/shokai/status/1480481768247549954", + "space": " ", "title": "Twitterのリンク", "content": "https://twitter.com/shokai/status/1480481768247549954 Twitterのリンク", @@ -522,6 +567,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://github.com/", + "space": " ", "title": "GitHubのリンク", "content": "https://github.com/ GitHubのリンク", "whole": "[https://github.com/ GitHubのリンク]", @@ -547,6 +593,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://ja.wikipedia.org", + "space": " ", "title": "ウィキペディアのリンク", "content": "https://ja.wikipedia.org ウィキペディアのリンク", "whole": "[https://ja.wikipedia.org ウィキペディアのリンク]", @@ -575,6 +622,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://www.mhlw.go.jp/content/10900000/000622211.pdf", + "space": " ", "title": "PDFへのリンク", "content": "https://www.mhlw.go.jp/content/10900000/000622211.pdf PDFへのリンク", @@ -603,6 +651,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://www.amazon.co.jp", + "space": " ", "title": "Amazonのリンク", "content": "Amazonのリンク https://www.amazon.co.jp", "whole": "[Amazonのリンク https://www.amazon.co.jp]", @@ -651,6 +700,7 @@ const lines: Line[] = [{ "indent": 1, "start": true, "end": false, + "hasCursor": false, }, }, { "id": "61dd289e7838e30000dc9cb6", @@ -665,6 +715,7 @@ const lines: Line[] = [{ "indent": 1, "start": false, "end": true, + "hasCursor": false, }, }, { "id": "61dd6e581280f00000ab09bc", @@ -687,6 +738,7 @@ const lines: Line[] = [{ "indent": 1, "start": true, "end": false, + "hasCursor": false, }, }, { "id": "61dd6e641280f00000ab09be", @@ -701,6 +753,7 @@ const lines: Line[] = [{ "indent": 1, "start": false, "end": true, + "hasCursor": false, }, }, { "id": "61dd6e721280f00000ab09bf", @@ -723,6 +776,7 @@ const lines: Line[] = [{ "indent": 2, "start": true, "end": false, + "hasCursor": false, }, }, { "id": "61dd6e911280f00000ab09c1", @@ -737,6 +791,7 @@ const lines: Line[] = [{ "indent": 2, "start": false, "end": false, + "hasCursor": false, }, }, { "id": "61dd6e961280f00000ab09c2", @@ -751,6 +806,7 @@ const lines: Line[] = [{ "indent": 2, "start": false, "end": true, + "hasCursor": false, }, }, { "id": "61dd6e9a1280f00000ab09c3", @@ -773,6 +829,7 @@ const lines: Line[] = [{ "indent": 2, "start": true, "end": false, + "hasCursor": false, }, }, { "id": "61dd6eba1280f00000ab09c5", @@ -787,6 +844,7 @@ const lines: Line[] = [{ "indent": 2, "start": false, "end": true, + "hasCursor": false, }, }, { "id": "61dfadbd1280f00000faf8db", @@ -833,6 +891,7 @@ const lines: Line[] = [{ "indent": 3, "start": true, "end": false, + "hasCursor": false, }, }, { "id": "61dfaddc1280f00000faf8df", @@ -847,6 +906,7 @@ const lines: Line[] = [{ "indent": 3, "start": false, "end": false, + "hasCursor": false, }, }, { "id": "61dfade41280f00000faf8e0", @@ -861,6 +921,7 @@ const lines: Line[] = [{ "indent": 3, "start": false, "end": true, + "hasCursor": false, }, }, { "id": "61dfadea1280f00000faf8e1", @@ -891,6 +952,7 @@ const lines: Line[] = [{ "indent": 3, "start": true, "end": false, + "hasCursor": false, }, }, { "id": "61dfae051280f00000faf8e4", @@ -905,6 +967,7 @@ const lines: Line[] = [{ "indent": 3, "start": false, "end": false, + "hasCursor": false, }, }, { "id": "61dfae0b1280f00000faf8e5", @@ -919,6 +982,7 @@ const lines: Line[] = [{ "indent": 3, "start": false, "end": false, + "hasCursor": false, }, }, { "id": "61dfae0b1280f00000faf8e6", @@ -933,6 +997,7 @@ const lines: Line[] = [{ "indent": 3, "start": false, "end": false, + "hasCursor": false, }, }, { "id": "61dfae2b1280f00000faf8e7", @@ -947,6 +1012,7 @@ const lines: Line[] = [{ "indent": 3, "start": false, "end": true, + "hasCursor": false, }, }, { "id": "624de2ed1280f0000050bebd", @@ -1502,6 +1568,90 @@ const lines: Line[] = [{ "unit": { "content": "太字", "whole": "[[太字]]" }, "children": "太字", }, +}, { + "id": "641e8df61280f00000780bf8", + "text": " [[[リンク]入り太字[イドバタニシ.icon]]]", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1679724022, + "updated": 1734767936, + "section": { "number": 7, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " [[[リンク]入り太字[イドバタニシ.icon]]]", + "tag": " ", + "content": "[[[リンク]入り太字[イドバタニシ.icon]]]", + }, + "children": { + "type": "strong", + "unit": { + "content": "[リンク]入り太字[イドバタニシ.icon]", + "whole": "[[[リンク]入り太字[イドバタニシ.icon]]]", + }, + "children": [ + { + "type": "link", + "unit": { + "page": "リンク", + "content": "リンク", + "whole": "[リンク]", + }, + "children": "リンク", + }, + "入り太字", + { + "type": "icon", + "unit": { + "page": "イドバタニシ", + "size": 1, + "content": "イドバタニシ.icon", + "whole": "[イドバタニシ.icon]", + }, + "children": "イドバタニシ.icon", + }, + ], + }, + }, +}, { + "id": "641e8ddd1280f00000780bf7", + "text": " [[[リンク]とアイコンは書き込めるが、[* 文字装飾]は書き込めない]]", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1679723997, + "updated": 1734767932, + "section": { "number": 7, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": + " [[[リンク]とアイコンは書き込めるが、[* 文字装飾]は書き込めない]]", + "tag": " ", + "content": + "[[[リンク]とアイコンは書き込めるが、[* 文字装飾]は書き込めない]]", + }, + "children": [ + "[[", + { + "type": "link", + "unit": { "page": "リンク", "content": "リンク", "whole": "[リンク]" }, + "children": "リンク", + }, + "とアイコンは書き込めるが、", + { + "type": "deco", + "unit": { + "whole": "[* 文字装飾]", + "content": "文字装飾", + "deco": "*", + "strong": 1, + "italic": false, + "strike": false, + "underline": false, + }, + "children": "文字装飾", + }, + "は書き込めない]]", + ], + }, }, { "id": "61fe44d77838e300001888f2", "text": "[- 取り消し線]", @@ -1574,6 +1724,29 @@ const lines: Line[] = [{ "unit": { "whole": "`インラインコード`", "content": "インラインコード" }, "children": "インラインコード", }, +}, { + "id": "676669ad1280f000000d1356", + "text": " `\\`をescapeできる`", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767914, + "updated": 1734767914, + "section": { "number": 7, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " `\\`をescapeできる`", + "tag": " ", + "content": "`\\`をescapeできる`", + }, + "children": { + "type": "code", + "unit": { + "whole": "`\\`をescapeできる`", + "content": "\\`をescapeできる", + }, + "children": "\\`をescapeできる", + }, + }, }, { "id": "624de33e1280f0000050bf08", "text": ">引用文", @@ -1581,6 +1754,7 @@ const lines: Line[] = [{ "created": 1649271613, "updated": 1649271613, "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, "nodes": { "type": "quote", "unit": { "whole": ">引用文", "tag": ">", "content": "引用文" }, @@ -1593,6 +1767,7 @@ const lines: Line[] = [{ "created": 1649271613, "updated": 1649272895, "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, "nodes": { "type": "indent", "unit": { @@ -1622,14 +1797,206 @@ const lines: Line[] = [{ }], }, }, +}, { + "id": "641e8dce1280f00000780bf6", + "text": " > 中には[リンク]や[$ \\text{数式}]も書けます", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1679723982, + "updated": 1679723995, + "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, + "nodes": { + "type": "indent", + "unit": { + "whole": " > 中には[リンク]や[$ \\text{数式}]も書けます", + "tag": " ", + "content": "> 中には[リンク]や[$ \\text{数式}]も書けます", + }, + "children": { + "type": "quote", + "unit": { + "whole": "> 中には[リンク]や[$ \\text{数式}]も書けます", + "tag": "> ", + "content": "中には[リンク]や[$ \\text{数式}]も書けます", + }, + "children": [ + "中には", + { + "type": "link", + "unit": { + "page": "リンク", + "content": "リンク", + "whole": "[リンク]", + }, + "children": "リンク", + }, + "や", + { + "type": "deco-formula", + "unit": { + "whole": "[$ \\text{数式}]", + "content": "$ \\text{数式}", + "formula": "\\text{数式}", + }, + "children": "$ \\text{数式}", + }, + "も書けます", + ], + }, + }, +}, { + "id": "676641c61280f000000d1346", + "text": " >\t中に箇条書きを書く", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734754759, + "updated": 1734754772, + "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, + "nodes": { + "type": "indent", + "unit": { + "whole": " >\t中に箇条書きを書く", + "tag": " ", + "content": ">\t中に箇条書きを書く", + }, + "children": { + "type": "quote", + "unit": { + "whole": ">\t中に箇条書きを書く", + "tag": ">", + "content": "\t中に箇条書きを書く", + }, + "children": { + "type": "indent", + "unit": { + "whole": "\t中に箇条書きを書く", + "tag": "\t", + "content": "中に箇条書きを書く", + }, + "children": "中に箇条書きを書く", + }, + }, + }, +}, { + "id": "676641d31280f000000d1347", + "text": " >\t\tタブ or 半角スペース or 全角スペースでインデントできる", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734754772, + "updated": 1734755190, + "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, + "nodes": { + "type": "indent", + "unit": { + "whole": " >\t\tタブ or 半角スペース or 全角スペースでインデントできる", + "tag": " ", + "content": ">\t\tタブ or 半角スペース or 全角スペースでインデントできる", + }, + "children": { + "type": "quote", + "unit": { + "whole": ">\t\tタブ or 半角スペース or 全角スペースでインデントできる", + "tag": ">", + "content": "\t\tタブ or 半角スペース or 全角スペースでインデントできる", + }, + "children": { + "type": "indent", + "unit": { + "whole": "\t\tタブ or 半角スペース or 全角スペースでインデントできる", + "tag": "\t\t", + "content": "タブ or 半角スペース or 全角スペースでインデントできる", + }, + "children": "タブ or 半角スペース or 全角スペースでインデントできる", + }, + }, + }, +}, { + "id": "676641dc1280f000000d1348", + "text": " > \t\t", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734755175, + "updated": 1734755177, + "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, + "nodes": { + "type": "indent", + "unit": { "whole": " > \t\t", "tag": " ", "content": "> \t\t" }, + "children": { + "type": "quote", + "unit": { "whole": "> \t\t", "tag": "> ", "content": "\t\t" }, + "children": { + "type": "indent", + "unit": { "whole": "\t\t", "tag": "\t\t", "content": "" }, + "children": "", + }, + }, + }, +}, { + "id": "6766435a1280f000000d1349", + "text": " >   ", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734755178, + "updated": 1734755180, + "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, + "nodes": { + "type": "indent", + "unit": { "whole": " >   ", "tag": " ", "content": ">   " }, + "children": { + "type": "quote", + "unit": { "whole": ">   ", "tag": ">", "content": "   " }, + "children": { + "type": "indent", + "unit": { "whole": "   ", "tag": "   ", "content": "" }, + "children": "", + }, + }, + }, +}, { + "id": "676666341280f000000d1352", + "text": " > ", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767913, + "updated": 1734767913, + "section": { "number": 7, "start": false, "end": false }, + "quoteLine": true, + "nodes": { + "type": "indent", + "unit": { "whole": " > ", "tag": " ", "content": "> " }, + "children": { + "type": "quote", + "unit": { "whole": "> ", "tag": "> ", "content": " " }, + "children": { + "type": "indent", + "unit": { "whole": " ", "tag": " ", "content": "" }, + "children": "", + }, + }, + }, }, { "id": "624de33e1280f0000050bf0a", "text": "? Helpfeel", - "userId": "5ef2bdebb60650001e1280f0", + "userId": "661b6e882a96e9002371b3c2", "created": 1649271613, - "updated": 1649271613, + "updated": 1714902875, "section": { "number": 7, "start": false, "end": false }, "helpfeel": { "prefix": "?", "entry": "Helpfeel" }, +}, { + "id": "6637575d71b3c20000e3f965", + "text": "\tcss:code.helpfeel", + "userId": "661b6e882a96e9002371b3c2", + "created": 1714902877, + "updated": 1714902887, + "section": { "number": 7, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": "\tcss:code.helpfeel", + "tag": "\t", + "content": "css:code.helpfeel", + }, + "children": "css:code.helpfeel", + }, }, { "id": "624de33e1280f0000050bf0b", "text": "$ コマンド", @@ -1638,6 +2005,22 @@ const lines: Line[] = [{ "updated": 1671920664, "section": { "number": 7, "start": false, "end": false }, "cli": { "prefix": "$", "command": "コマンド" }, +}, { + "id": "6637570471b3c20000e3f964", + "text": "\tcss: .text.cli(%と同じ)", + "userId": "661b6e882a96e9002371b3c2", + "created": 1714902788, + "updated": 1714902819, + "section": { "number": 7, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": "\tcss: .text.cli(%と同じ)", + "tag": "\t", + "content": "css: .text.cli(%と同じ)", + }, + "children": "css: .text.cli(%と同じ)", + }, }, { "id": "624de33e1280f0000050bf0c", "text": "% コマンド", @@ -1648,16 +2031,16 @@ const lines: Line[] = [{ "cli": { "prefix": "%", "command": "コマンド" }, }, { "id": "624de33e1280f0000050bf0d", - "text": "[ ]: [空白記法]", - "userId": "5ef2bdebb60650001e1280f0", + "text": "[ ]: [空白記法]", + "userId": "661b6e882a96e9002371b3c2", "created": 1649271613, - "updated": 1649271632, + "updated": 1714902849, "section": { "number": 7, "start": false, "end": false }, "nodes": [ { "type": "blank", - "unit": { "content": " ", "whole": "[ ]" }, - "children": " ", + "unit": { "content": " ", "whole": "[ ]" }, + "children": " ", }, ": ", { @@ -1670,6 +2053,14 @@ const lines: Line[] = [{ "children": "空白記法", }, ], +}, { + "id": "6766693c1280f000000d1355", + "text": " % コマンド", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767913, + "updated": 1734767913, + "section": { "number": 7, "start": false, "end": false }, + "cli": { "prefix": "%", "command": "コマンド" }, }, { "id": "61fe45047838e300001888f7", "text": "", @@ -2634,6 +3025,31 @@ const lines: Line[] = [{ "children": "ルビ記法", }], }, +}, { + "id": "6637543771b3c20000e679fe", + "text": " \tあまり使われてない?[bsahd.icon]", + "userId": "661b6e882a96e9002371b3c2", + "created": 1714902071, + "updated": 1714902079, + "section": { "number": 8, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " \tあまり使われてない?[bsahd.icon]", + "tag": " \t", + "content": "あまり使われてない?[bsahd.icon]", + }, + "children": ["あまり使われてない?", { + "type": "icon", + "unit": { + "page": "bsahd", + "size": 1, + "content": "bsahd.icon", + "whole": "[bsahd.icon]", + }, + "children": "bsahd.icon", + }], + }, }, { "id": "61dd26c07838e300002ff25c", "text": " `>`: [> abcABC123あいう]", @@ -3254,6 +3670,162 @@ const lines: Line[] = [{ "children": "行内で小さくするUserCSS", }, }, +}, { + "id": "6637563b71b3c20000e3f962", + "text": "\t`+!`: [+! abcABC123あいう]", + "userId": "661b6e882a96e9002371b3c2", + "created": 1714902586, + "updated": 1714902613, + "section": { "number": 8, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": "\t`+!`: [+! abcABC123あいう]", + "tag": "\t", + "content": "`+!`: [+! abcABC123あいう]", + }, + "children": [ + { + "type": "code", + "unit": { "whole": "`+!`", "content": "+!" }, + "children": "+!", + }, + ": ", + { + "type": "deco", + "unit": { + "whole": "[+! abcABC123あいう]", + "content": "abcABC123あいう", + "deco": "+!", + "strong": 0, + "italic": false, + "strike": false, + "underline": false, + }, + "children": "abcABC123あいう", + }, + ], + }, +}, { + "id": "6637565771b3c20000e3f963", + "text": "\t\t[明朝体記法]", + "userId": "661b6e882a96e9002371b3c2", + "created": 1714902615, + "updated": 1714902618, + "section": { "number": 8, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": "\t\t[明朝体記法]", + "tag": "\t\t", + "content": "[明朝体記法]", + }, + "children": { + "type": "link", + "unit": { + "page": "明朝体記法", + "content": "明朝体記法", + "whole": "[明朝体記法]", + }, + "children": "明朝体記法", + }, + }, +}, { + "id": "66ed230571b3c20000fb24f5", + "text": " `+_`:[+_ abcABC123あいう]", + "userId": "661b6e882a96e9002371b3c2", + "created": 1726817030, + "updated": 1726817440, + "section": { "number": 8, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " `+_`:[+_ abcABC123あいう]", + "tag": " ", + "content": "`+_`:[+_ abcABC123あいう]", + }, + "children": [ + { + "type": "code", + "unit": { "whole": "`+_`", "content": "+_" }, + "children": "+_", + }, + ":", + { + "type": "deco", + "unit": { + "whole": "[+_ abcABC123あいう]", + "content": "abcABC123あいう", + "deco": "+_", + "strong": 0, + "italic": false, + "strike": false, + "underline": true, + }, + "children": "abcABC123あいう", + }, + ], + }, +}, { + "id": "66ed234d71b3c20000fb24f8", + "text": " \t`_+`:[_+ abcABC123あいう]", + "userId": "661b6e882a96e9002371b3c2", + "created": 1726817107, + "updated": 1726817452, + "section": { "number": 8, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " \t`_+`:[_+ abcABC123あいう]", + "tag": " \t", + "content": "`_+`:[_+ abcABC123あいう]", + }, + "children": [ + { + "type": "code", + "unit": { "whole": "`_+`", "content": "_+" }, + "children": "_+", + }, + ":", + { + "type": "deco", + "unit": { + "whole": "[_+ abcABC123あいう]", + "content": "abcABC123あいう", + "deco": "_+", + "strong": 0, + "italic": false, + "strike": false, + "underline": true, + }, + "children": "abcABC123あいう", + }, + ], + }, +}, { + "id": "66ed231e71b3c20000fb24f7", + "text": " \t[文法エラー・警告をIDE風に表示するUserCSS]", + "userId": "661b6e882a96e9002371b3c2", + "created": 1726817055, + "updated": 1726817065, + "section": { "number": 8, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " \t[文法エラー・警告をIDE風に表示するUserCSS]", + "tag": " \t", + "content": "[文法エラー・警告をIDE風に表示するUserCSS]", + }, + "children": { + "type": "link", + "unit": { + "page": "文法エラー・警告をIDE風に表示するUserCSS", + "content": "文法エラー・警告をIDE風に表示するUserCSS", + "whole": "[文法エラー・警告をIDE風に表示するUserCSS]", + }, + "children": "文法エラー・警告をIDE風に表示するUserCSS", + }, + }, }, { "id": "61dd314f7838e30000494402", "text": "未使用", @@ -4102,6 +4674,7 @@ const lines: Line[] = [{ "type": "urlLink", "unit": { "link": "https://scrapbox.io/help-jp/ブラケティング", + "space": " ", "title": "タイトルつきリンク", "content": "タイトルつきリンク https://scrapbox.io/help-jp/ブラケティング", @@ -4410,12 +4983,19 @@ const lines: Line[] = [{ }, }, { "id": "61df899e7838e300001de3a2", - "text": "[イドバタニシ.icon] アイコン", - "userId": "60fb0a79f3364000237838e3", + "text": "`[イドバタニシ.icon]`[イドバタニシ.icon] アイコン", + "userId": "5ef2bdebb60650001e1280f0", "created": 1642039710, - "updated": 1642039710, + "updated": 1734767912, "section": { "number": 10, "start": false, "end": false }, "nodes": [{ + "type": "code", + "unit": { + "whole": "`[イドバタニシ.icon]`", + "content": "[イドバタニシ.icon]", + }, + "children": "[イドバタニシ.icon]", + }, { "type": "icon", "unit": { "page": "イドバタニシ", @@ -4425,6 +5005,65 @@ const lines: Line[] = [{ }, "children": "イドバタニシ.icon", }, " アイコン"], +}, { + "id": "676659471280f000000d134d", + "text": "`[イドバタニシ.icon*3]`[イドバタニシ.icon*3]繰り返しアイコン", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767912, + "updated": 1734767912, + "section": { "number": 10, "start": false, "end": false }, + "nodes": [{ + "type": "code", + "unit": { + "whole": "`[イドバタニシ.icon*3]`", + "content": "[イドバタニシ.icon*3]", + }, + "children": "[イドバタニシ.icon*3]", + }, { + "type": "icon", + "unit": { + "page": "イドバタニシ", + "size": 3, + "content": "イドバタニシ.icon*3", + "whole": "[イドバタニシ.icon*3]", + }, + "children": "イドバタニシ.icon*3", + }, "繰り返しアイコン"], +}, { + "id": "6766594f1280f000000d134e", + "text": + "`[イドバタニシ.iconx3]`[イドバタニシ.iconx3]繰り返しアイコン(`x`も可)", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767912, + "updated": 1734767912, + "section": { "number": 10, "start": false, "end": false }, + "nodes": [ + { + "type": "code", + "unit": { + "whole": "`[イドバタニシ.iconx3]`", + "content": "[イドバタニシ.iconx3]", + }, + "children": "[イドバタニシ.iconx3]", + }, + { + "type": "icon", + "unit": { + "page": "イドバタニシ", + "size": 3, + "content": "イドバタニシ.iconx3", + "whole": "[イドバタニシ.iconx3]", + }, + "children": "イドバタニシ.iconx3", + }, + "繰り返しアイコン(", + { + "type": "code", + "unit": { "whole": "`x`", "content": "x" }, + "children": "x", + }, + "も可)", + ], }, { "id": "61df899e7838e300001de3a3", "text": "[イドバタニシ.icon*1000]繰り返しアイコン (最大1000個)", @@ -5428,11 +6067,11 @@ const lines: Line[] = [{ }, }, }, { - "id": "61dd29347838e30000dc9cc8", + "id": "6766634e1280f000000d134f", "text": " Youtube再生リスト", "userId": "5ef2bdebb60650001e1280f0", - "created": 1641883957, - "updated": 1641902339, + "created": 1734767912, + "updated": 1734767912, "section": { "number": 13, "start": false, "end": false }, "nodes": { "type": "indent", @@ -5594,10 +6233,52 @@ const lines: Line[] = [{ "whole": "[https://vimeo.com/121284607]", "content": "https://vimeo.com/121284607", "videoId": "121284607", + "params": {}, }, "children": "https://vimeo.com/121284607", }, }, +}, { + "id": "676663811280f000000d1350", + "text": " なぜかcase insensitive", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767913, + "updated": 1734767913, + "section": { "number": 13, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " なぜかcase insensitive", + "tag": " ", + "content": "なぜかcase insensitive", + }, + "children": "なぜかcase insensitive", + }, +}, { + "id": "676663951280f000000d1351", + "text": " [HTTPS://vimeo.com/121284607]", + "userId": "5ef2bdebb60650001e1280f0", + "created": 1734767913, + "updated": 1734767913, + "section": { "number": 13, "start": false, "end": false }, + "nodes": { + "type": "indent", + "unit": { + "whole": " [HTTPS://vimeo.com/121284607]", + "tag": " ", + "content": "[HTTPS://vimeo.com/121284607]", + }, + "children": { + "type": "vimeo", + "unit": { + "whole": "[HTTPS://vimeo.com/121284607]", + "content": "HTTPS://vimeo.com/121284607", + "videoId": "121284607", + "params": {}, + }, + "children": "HTTPS://vimeo.com/121284607", + }, + }, }, { "id": "625227da1280f0000075bbf6", "text": " MP4", @@ -5934,6 +6615,31 @@ const lines: Line[] = [{ "updated": 1641902636, "section": { "number": 15, "start": false, "end": true }, "nodes": "", +}, { + "id": "6587e35a5b98c20000a729fd", + "text": "[UserCSS.icon]", + "userId": "5b5e7121417cf700145b98c2", + "created": 1703404378, + "updated": 1703404379, + "section": { "number": 16, "start": true, "end": false }, + "nodes": { + "type": "icon", + "unit": { + "page": "UserCSS", + "size": 1, + "content": "UserCSS.icon", + "whole": "[UserCSS.icon]", + }, + "children": "UserCSS.icon", + }, +}, { + "id": "6587e35a5b98c20000a729fe", + "text": "", + "userId": "5b5e7121417cf700145b98c2", + "created": 1703404379, + "updated": 1703404379, + "section": { "number": 16, "start": false, "end": true }, + "nodes": "", }]; assertType>(true); diff --git a/blocks.ts b/blocks.ts index bb705f5..f4abf1d 100644 --- a/blocks.ts +++ b/blocks.ts @@ -39,8 +39,11 @@ export type Line = /** 画像を並べているときのみ生える */ numberOfImages?: number; + /** 引用文のときのみ生える */ + quoteLine?: true; + /** 中に含まれるnodes */ - nodes: Node | NodeWithoutIndent[]; + get nodes(): Node | NodeWithoutIndent[]; }); /** the type which represents a line in a block */ @@ -62,6 +65,8 @@ export interface CodeBlock extends Block { /** the file name of the code block */ filename: string; + + hasCursor: boolean; } /** the type which represents a line in a table block */ diff --git a/node/anchor.ts b/node/anchor.ts index 893b00d..8649844 100644 --- a/node/anchor.ts +++ b/node/anchor.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** Anchor埋め込み */ @@ -12,7 +12,7 @@ export interface Anchor { children: PlainText; } -export interface AnchorUnit extends Unit { +export interface AnchorUnit extends BracketUnit { /** Anchor video ID */ videoId: string; diff --git a/node/audio.ts b/node/audio.ts index 28b8708..ffa99ca 100644 --- a/node/audio.ts +++ b/node/audio.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** 音声埋め込み */ @@ -6,7 +6,7 @@ export interface Audio { type: "audio"; /** 構文解析結果 */ - unit: Unit; + unit: BracketUnit; /** scrapboxにuploadされたfileのID * diff --git a/node/audioLink.ts b/node/audioLink.ts index 9fc8d63..8515bd4 100644 --- a/node/audioLink.ts +++ b/node/audioLink.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** タイトル付き音声 */ @@ -18,7 +18,7 @@ export interface AudioLink { children: PlainText; } -export interface AudioLinkUnit extends Unit { +export interface AudioLinkUnit extends BracketUnit { /** 音声のURL */ link: string; diff --git a/node/blank.ts b/node/blank.ts index 97c9f3b..22d0b6c 100644 --- a/node/blank.ts +++ b/node/blank.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** 空白記法 */ @@ -6,7 +6,7 @@ export interface Blank { type: "blank"; /** 構文解析結果 */ - unit: Unit; + unit: BracketUnit; /** the same as `unit.content` */ children: PlainText; diff --git a/node/code.ts b/node/code.ts index bae8ad8..1c726d5 100644 --- a/node/code.ts +++ b/node/code.ts @@ -6,8 +6,13 @@ export interface Code { type: "code"; /** 構文解析結果 */ - unit: Unit; + unit: CodeUnit; /** the same as `unit.content` */ children: PlainText; } + +export interface CodeUnit extends Unit { + content: string; + whole: `\`${string}\``; +} diff --git a/node/decoration.ts b/node/decoration.ts index b5cfbf9..112429e 100644 --- a/node/decoration.ts +++ b/node/decoration.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; import type { Formula } from "./formula.ts"; import type { Link } from "./link.ts"; @@ -52,7 +52,7 @@ export interface Decoration { children: NodeInDecoration | NodeInDecoration[]; } -export interface DecorationUnit extends Unit { +export interface DecorationUnit extends BracketUnit { /** 文字装飾記号 */ deco: string; @@ -72,4 +72,6 @@ export interface DecorationUnit extends Unit { /** 下線記号`_`を含むとき`true` */ underline: boolean; + + whole: `[${string} ${string}]`; } diff --git a/node/formula.ts b/node/formula.ts index 184035c..4b0b2ad 100644 --- a/node/formula.ts +++ b/node/formula.ts @@ -1,5 +1,4 @@ -import type { Unit } from "./unit.ts"; -import type { PlainText } from "./plainText.ts"; +import type { BracketUnit } from "./unit.ts"; /** 数式記法 */ export interface Formula { @@ -9,13 +8,17 @@ export interface Formula { unit: FormulaUnit; /** the same as `unit.content` */ - children: PlainText; + children: `$ ${string}`; } -export interface FormulaUnit extends Unit { +export interface FormulaUnit extends BracketUnit { /** KaTeX text * * `content` から`$ `を外したもの */ formula: string; + + content: `$ ${string}`; + + whole: `[$ ${string}]`; } diff --git a/node/googleMap.ts b/node/googleMap.ts index eb769af..869a5f7 100644 --- a/node/googleMap.ts +++ b/node/googleMap.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** Location記法 */ @@ -12,7 +12,9 @@ export interface GoogleMap { children: PlainText; } -export interface GoogleMapUnit extends Unit { +declare const unit: GoogleMapUnit; + +export interface GoogleMapUnit extends BracketUnit { /** 緯度 */ latitude: number; @@ -24,4 +26,13 @@ export interface GoogleMapUnit extends Unit { /** 地点の名前 */ title?: string; + content: + | `${"N" | "S"}${number},${"E" | "W"}${number}${`,Z${number}` | ""}` + | `${"N" | "S"}${number},${"E" | "W"}${number}${ + | `,Z${number}` + | ""} ${string}` + | `${string} ${"N" | "S"}${number},${"E" | "W"}${number}${ + | `,Z${number}` + | ""}`; + whole: `[${this["content"]}]`; } diff --git a/node/gyazo.ts b/node/gyazo.ts index d3648ef..f53133b 100644 --- a/node/gyazo.ts +++ b/node/gyazo.ts @@ -1,20 +1,38 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit, DoubleBracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** Gyazoから引っ張ってきた画像の画像記法 */ -export interface Gyazo extends GyazoBase { +export interface Gyazo { type: "gyazo"; + + /** 構文解析結果 */ + unit: GyazoUnit; + + /** the same as `unit.content` */ + children: PlainText; } /** Gyazoから引っ張ってきた画像の強調画像記法 */ -export interface StrongGyazo extends GyazoBase { +export interface StrongGyazo { type: "strongGyazo"; -} -export interface GyazoBase { /** 構文解析結果 */ - unit: Unit; + unit: StrongGyazoUnit; /** the same as `unit.content` */ children: PlainText; } + +export interface GyazoUnit extends BracketUnit { + content: `http${"s" | ""}://${`${string}.` | ""}gyazo.com/${string}${ + | `.${string}` + | "/raw" + | ""}`; +} + +export interface StrongGyazoUnit extends DoubleBracketUnit { + content: `http${"s" | ""}://${`${string}.` | ""}gyazo.com/${string}${ + | `.${string}` + | "/raw" + | ""}`; +} diff --git a/node/gyazoLink.ts b/node/gyazoLink.ts index 3901fca..8ad1a02 100644 --- a/node/gyazoLink.ts +++ b/node/gyazoLink.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit, DoubleBracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** Gyazoから引っ張ってきた画像のリンク付き画像記法 */ @@ -16,15 +16,29 @@ export interface StrongGyazoLink { type: "strongGyazoLink"; /** 構文解析結果 */ - unit: GyazoLinkUnit; + unit: StrongGyazoLinkUnit; /** the same as `unit.content` */ children: PlainText; } -export interface GyazoLinkUnit extends Unit { +export interface GyazoLinkUnit extends BracketUnit { + /** 画像のURL */ + gyazo: `http${"s" | ""}://${`${string}.` | ""}gyazo.com/${string}${ + | `.${string}` + | "/raw" + | ""}`; + + /** 埋め込まれたリンクのURL */ + link: string; +} + +export interface StrongGyazoLinkUnit extends DoubleBracketUnit { /** 画像のURL */ - gyazo: string; + gyazo: `http${"s" | ""}://${`${string}.` | ""}gyazo.com/${string}${ + | `.${string}` + | "/raw" + | ""}`; /** 埋め込まれたリンクのURL */ link: string; diff --git a/node/hashTag.ts b/node/hashTag.ts index 57ce2f7..9b4ac8e 100644 --- a/node/hashTag.ts +++ b/node/hashTag.ts @@ -1,4 +1,3 @@ -import type { NodeWithoutIndent } from "./node.ts"; import type { Unit } from "./unit.ts"; /** hashtag */ @@ -8,8 +7,8 @@ export interface HashTag { /** 構文解析結果 */ unit: HashTagUnit; - /** 中に含まれるNodes */ - children: NodeWithoutIndent | NodeWithoutIndent[]; + /** same as {@linkcode HashTagUnit.content} */ + children: `#${string}`; } export interface HashTagUnit extends Unit { @@ -17,4 +16,10 @@ export interface HashTagUnit extends Unit { page: string; tag: "#"; + + /** page title */ + get content(): string; + + /** raw text */ + get whole(): `#${string}`; } diff --git a/node/icon.ts b/node/icon.ts index d2915a5..6c23968 100644 --- a/node/icon.ts +++ b/node/icon.ts @@ -6,7 +6,11 @@ export interface Icon { type: "icon"; /** 構文解析結果 */ - unit: IconUnit; + unit: + | IconUnit + | ProjectIconUnit + | RepeatIconUnit + | RepeatProjectIconUnit; /** the same as `unit.content` */ children: PlainText; @@ -17,25 +21,90 @@ export interface StrongIcon { type: "strong-icon"; /** 構文解析結果 */ - unit: IconUnit; + unit: + | IconUnit + | ProjectIconUnit + | RepeatIconUnit + | RepeatProjectIconUnit; /** the same as `unit.content` */ children: PlainText; } -export interface IconUnit extends Unit { - /** アイコンがあるproject name +export interface IconUnit extends Unit { + /** アイコンがあるページのタイトル */ + page: string; + + /** 繰り返し回数 * - * 同じprojectのアイコンのときは省略される + * 最大1000 */ - project?: string; + size: 1; + + /** icon syntax */ + get content(): `${string}.icon`; + + /** raw text */ + get whole(): Strong extends true ? `[[${string}.icon]]` : `[${string}.icon]`; +} + +export interface ProjectIconUnit extends Unit { + /** アイコンがあるproject name */ + project: string; /** アイコンがあるページのタイトル */ page: string; + /** 繰り返し回数 + * + * 最大1000 + */ + size: 1; + + /** icon syntax */ + get content(): `/${string}/${string}.icon`; + + /** raw text */ + get whole(): Strong extends true ? `[[/${string}/${string}.icon]]` + : `[/${string}/${string}.icon]`; +} + +export interface RepeatIconUnit extends Unit { + /** アイコンがあるページのタイトル */ + page: string; + /** 繰り返し回数 * * 最大1000 */ size: number; + + /** icon syntax */ + get content(): `${string}.icon${"*" | "x"}${number}`; + + /** raw text */ + get whole(): Strong extends true ? `[[${string}.icon${"*" | "x"}${number}]]` + : `[${string}.icon${"*" | "x"}${number}]`; +} + +export interface RepeatProjectIconUnit extends Unit { + /** アイコンがあるproject name */ + project: string; + + /** アイコンがあるページのタイトル */ + page: string; + + /** 繰り返し回数 + * + * 最大1000 + */ + size: number; + + /** icon syntax */ + get content(): `/${string}/${string}.icon${"*" | "x"}${number}`; + + /** raw text */ + get whole(): Strong extends true + ? `[[/${string}/${string}.icon${"*" | "x"}${number}]]` + : `[/${string}/${string}.icon${"*" | "x"}${number}]`; } diff --git a/node/image.ts b/node/image.ts index 0755dfe..c6bb1a1 100644 --- a/node/image.ts +++ b/node/image.ts @@ -1,19 +1,29 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit, DoubleBracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** 画像記法 */ -export interface Image extends ImageBase { +export interface Image { type: "image"; + + /** 構文解析結果 */ + unit: BracketUnit; + + /** scrapboxにuploadされたfileのID + * + * このpropertyはscrapboxにuploadされた画像ファイルのときのみ生える + */ + fileId?: string; + + /** the same as {@linkcode Unit.content} */ + children: PlainText; } /** 強調画像記法 */ -export interface StrongImage extends ImageBase { +export interface StrongImage { type: "strongImage"; -} -export interface ImageBase { /** 構文解析結果 */ - unit: Unit; + unit: DoubleBracketUnit; /** scrapboxにuploadされたfileのID * @@ -21,6 +31,6 @@ export interface ImageBase { */ fileId?: string; - /** the same as `unit.content` */ + /** the same as {@linkcode Unit.content} */ children: PlainText; } diff --git a/node/imageLink.ts b/node/imageLink.ts index 3c7897b..67c9ba3 100644 --- a/node/imageLink.ts +++ b/node/imageLink.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit, DoubleBracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** リンク付き画像記法 */ @@ -8,7 +8,19 @@ export interface ImageLink { /** 構文解析結果 */ unit: ImageLinkUnit; - /** the same as `unit.content` */ + /** scrapboxにuploadされたfileのID + * + * {@linkcode ImageLinkUnit.image}と{@linkcode ImageLinkUnit.link}がscrapboxにuploadされたfilesだったとき、そのidが格納される + */ + fileIds: [] | [string] | [string, string]; + + /** scrapboxにuploadされたfileのID + * + * このpropertyは{@linkcode ImageLinkUnit.image}がscrapboxにuploadされたfileだったときのみ生える + */ + fileId?: string; + + /** the same as {@linkcode ImageUnit.content} */ children: PlainText; } @@ -17,13 +29,33 @@ export interface StrongImageLink { type: "strongImageLink"; /** 構文解析結果 */ - unit: ImageLinkUnit; + unit: StrongImageLinkUnit; - /** the same as `unit.content` */ + /** scrapboxにuploadされたfileのID + * + * {@linkcode StrongImageLinkUnit.image}と{@linkcode StrongImageLinkUnit.link}がscrapboxにuploadされたfilesだったとき、そのidが格納される + */ + fileIds: [] | [string] | [string, string]; + + /** scrapboxにuploadされたfileのID + * + * このpropertyは{@linkcode StrongImageLinkUnit.image}がscrapboxにuploadされたfileだったときのみ生える + */ + fileId?: string; + + /** the same as {@linkcode StrongImageUnit.content} */ children: PlainText; } -export interface ImageLinkUnit extends Unit { +export interface ImageLinkUnit extends BracketUnit { + /** 画像のURL */ + image: string; + + /** 埋め込まれたリンクのURL */ + link: string; +} + +export interface StrongImageLinkUnit extends DoubleBracketUnit { /** 画像のURL */ image: string; diff --git a/node/link.ts b/node/link.ts index 3b37ad0..9a510ee 100644 --- a/node/link.ts +++ b/node/link.ts @@ -1,34 +1,69 @@ -import type { PlainText } from "./plainText.ts"; -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; /** リンク記法 * * 以下の形式が対象 * - * - [aaa] - * - [/xxx/aaa] - * - [/xxx/] - * - [/xxx] + * - `[aaa]` + * - `[aaa#id]` + * - `[/xxx/aaa]` + * - `[/xxx/aaa#id]` + * - `[/xxx/]` + * - `[/xxx]` */ export interface Link { type: "link"; /** 構文解析結果 */ - unit: InternalLinkUnit | ProjectLinkUnit | ProjectHomeLinkUnit; + unit: + | InternalLinkUnit + | InternalLinkUnitWithLineId + | ProjectLinkUnit + | ProjectLinkUnitWithLineId + | ProjectHomeLinkUnit; - /** the same as `unit.content` */ - children: PlainText; + /** the same as {@linkcode Link.unit.content} */ + children: string; } -export interface InternalLinkUnit extends Unit { +export interface InternalLinkUnit extends BracketUnit { + /** page title */ + page: string; + + /** page title */ + get content(): string; + + /** raw text */ + get whole(): `[${string}]`; +} +export interface InternalLinkUnitWithLineId extends BracketUnit { /** page title */ page: string; /** line id */ - line?: string; + line: string; + + /** page title with a line id if exists */ + get content(): `${string}#${string}`; + + /** raw text */ + get whole(): `[${string}#${string}]`; } -export interface ProjectLinkUnit extends Unit { +export interface ProjectLinkUnit extends BracketUnit { + /** project name */ + project: string; + + /** page title */ + page: string; + + /** project name and page title */ + get content(): `/${string}/${string}`; + + /** raw text */ + get whole(): `[/${string}/${string}]`; +} +export interface ProjectLinkUnitWithLineId extends BracketUnit { /** project name */ project: string; @@ -36,10 +71,16 @@ export interface ProjectLinkUnit extends Unit { page: string; /** line id */ - line?: string; + line: string; + + /** project name and page title with a line id if exists */ + get content(): `/${string}/${string}#${string}`; + + /** raw text */ + get whole(): `[/${string}/${string}#${string}]`; } -export interface ProjectHomeLinkUnit extends Unit { +export interface ProjectHomeLinkUnit extends BracketUnit { /** project name */ project: string; } diff --git a/node/node.ts b/node/node.ts index c4da1ad..c76b2d7 100644 --- a/node/node.ts +++ b/node/node.ts @@ -1,3 +1,30 @@ +export * from "./blank.ts"; +export * from "./plainText.ts"; +export * from "./code.ts"; +export * from "./formula.ts"; +export * from "./decoration.ts"; +export * from "./quote.ts"; +export * from "./strong.ts"; +export * from "./link.ts"; +export * from "./hashTag.ts"; +export * from "./icon.ts"; +export * from "./urlLink.ts"; +export * from "./url.ts"; +export * from "./image.ts"; +export * from "./gyazo.ts"; +export * from "./imageLink.ts"; +export * from "./gyazoLink.ts"; +export * from "./video.ts"; +export * from "./videoLink.ts"; +export * from "./youtube.ts"; +export * from "./vimeo.ts"; +export * from "./audio.ts"; +export * from "./audioLink.ts"; +export * from "./spotify.ts"; +export * from "./anchor.ts"; +export * from "./googleMap.ts"; +export * from "./indent.ts"; +export * from "./unit.ts"; import type { Blank } from "./blank.ts"; import type { PlainText } from "./plainText.ts"; import type { Code } from "./code.ts"; @@ -15,6 +42,7 @@ import type { Gyazo, StrongGyazo } from "./gyazo.ts"; import type { ImageLink, StrongImageLink } from "./imageLink.ts"; import type { GyazoLink, StrongGyazoLink } from "./gyazoLink.ts"; import type { Video } from "./video.ts"; +import type { VideoLink } from "./videoLink.ts"; import type { Youtube } from "./youtube.ts"; import type { Vimeo } from "./vimeo.ts"; import type { Audio } from "./audio.ts"; @@ -23,7 +51,6 @@ import type { Spotify } from "./spotify.ts"; import type { Anchor } from "./anchor.ts"; import type { GoogleMap } from "./googleMap.ts"; import type { Indent } from "./indent.ts"; - export type NodeWithoutIndent = | Blank | PlainText @@ -47,6 +74,7 @@ export type NodeWithoutIndent = | GyazoLink | StrongGyazoLink | Video + | VideoLink | Audio | AudioLink | Spotify diff --git a/node/quote.ts b/node/quote.ts index 13a9f2c..b0a4da4 100644 --- a/node/quote.ts +++ b/node/quote.ts @@ -1,5 +1,5 @@ import type { Unit } from "./unit.ts"; -import type { NodeWithoutIndent } from "./node.ts"; +import type { Node, NodeWithoutIndent } from "./node.ts"; /** 引用記法 */ export interface Quote { @@ -9,10 +9,11 @@ export interface Quote { unit: QuoteUnit; /** 中に含まれるNodes */ - children: NodeWithoutIndent | NodeWithoutIndent[]; + children: Node | NodeWithoutIndent[]; } export interface QuoteUnit extends Unit { - /** 引用記号とそれに続く空白を含んだもの */ - tag: `>${string}`; + /** 引用記号とそれに続く半角空白を1文字含んだもの */ + tag: ">" | "> "; + whole: `${">" | "> "}${string}`; } diff --git a/node/spotify.ts b/node/spotify.ts index 056b010..1dd5444 100644 --- a/node/spotify.ts +++ b/node/spotify.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** Spotify埋め込み */ @@ -12,7 +12,7 @@ export interface Spotify { children: PlainText; } -export interface SpotifyUnit extends Unit { +export interface SpotifyUnit extends BracketUnit { /** Spotify video ID */ videoId: string; diff --git a/node/strong.ts b/node/strong.ts index 3d1ec4f..9341bc0 100644 --- a/node/strong.ts +++ b/node/strong.ts @@ -1,13 +1,13 @@ -import type { Unit } from "./unit.ts"; -import type { NodeWithoutIndent } from "./node.ts"; +import type { NodeInDecoration } from "./decoration.ts"; +import type { DoubleBracketUnit } from "./unit.ts"; /** 強調記法 */ export interface Strong { type: "strong"; /** 構文解析結果 */ - unit: Unit; + unit: DoubleBracketUnit; /** 中に含まれるNode */ - children: NodeWithoutIndent; + children: NodeInDecoration | NodeInDecoration[]; } diff --git a/node/unit.ts b/node/unit.ts index c11b5bf..190e6b8 100644 --- a/node/unit.ts +++ b/node/unit.ts @@ -5,3 +5,13 @@ export interface Unit { /** 記法を取り除いていない生のテキスト */ whole: string; } + +export interface BracketUnit extends Unit { + /** 記法を取り除いていない生のテキスト */ + whole: `[${this["content"]}]`; +} + +export interface DoubleBracketUnit extends Unit { + /** 記法を取り除いていない生のテキスト */ + whole: `[[${this["content"]}]]`; +} diff --git a/node/url.ts b/node/url.ts index 44b66ca..58b4fe0 100644 --- a/node/url.ts +++ b/node/url.ts @@ -1,11 +1,10 @@ import type { Unit } from "./unit.ts"; -import type { PlainText } from "./plainText.ts"; -/** 裸のURL */ +/** raw URL */ export interface Url { type: "url"; /** 構文解析結果 */ - unit: Unit; + unit: UrlUnit; /** scrapboxにuploadされたfileのID * @@ -14,5 +13,10 @@ export interface Url { fileId?: string; /** the same as `unit.content` */ - children: PlainText; + children: `http${"s" | ""}://${string}`; +} + +export interface UrlUnit extends Unit { + content: `http${"s" | ""}://${string}`; + whole: `http${"s" | ""}://${string}`; } diff --git a/node/urlLink.ts b/node/urlLink.ts index e6c1dcc..18fdc70 100644 --- a/node/urlLink.ts +++ b/node/urlLink.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** 外部リンク記法 */ @@ -6,7 +6,7 @@ export interface UrlLink { type: "urlLink"; /** 構文解析結果 */ - unit: UrlLinkUnit; + unit: UrlLinkUnit | UrlLinkWithTitleUnit; /** scrapboxにuploadされたfileのID * @@ -18,10 +18,22 @@ export interface UrlLink { children: PlainText; } -export interface UrlLinkUnit extends Unit { +export interface UrlLinkUnit extends BracketUnit { /** URL */ - link: string; + link: `http${"s" | ""}://${string}`; - /** タイトル */ - title?: string; + content: `http${"s" | ""}://${string}`; +} + +export interface UrlLinkWithTitleUnit extends BracketUnit { + /** URL */ + link: `http${"s" | ""}://${string}`; + + /** title */ + title: string; + + /** space between `link` and `title` in `[link title]` */ + space: string; + + content: `${this["link"]}${string}` | `${string}${this["link"]}`; } diff --git a/node/video.ts b/node/video.ts index a4ee77b..c986648 100644 --- a/node/video.ts +++ b/node/video.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** 動画埋め込み */ @@ -6,7 +6,7 @@ export interface Video { type: "video"; /** 構文解析結果 */ - unit: Unit; + unit: BracketUnit; /** scrapboxにuploadされたfileのID * diff --git a/node/videoLink.ts b/node/videoLink.ts new file mode 100644 index 0000000..d1c5f72 --- /dev/null +++ b/node/videoLink.ts @@ -0,0 +1,32 @@ +import type { BracketUnit } from "./unit.ts"; +import type { PlainText } from "./plainText.ts"; + +/** リンクつき動画埋め込み */ +export interface VideoLink { + type: "videoLink"; + + /** 構文解析結果 */ + unit: VideoLinkUnit; + + /** scrapboxにuploadされたfileのID + * + * このpropertyはscrapboxにuploadされたファイルのときのみ生える + */ + fileId?: string; + + /** scrapboxにuploadされたfileのID + * + * {@linkcode VideoLinkUnit.video}と{@linkcode VideoLinkUnit.link}がscrapboxにuploadされたfilesだったとき、そのidが格納される + */ + fileIds: [] | [string] | [string, string]; + + /** the same as `unit.content` */ + children: PlainText; +} + +export interface VideoLinkUnit extends BracketUnit { + /** URL */ + link: string; + /** video URL */ + video: string; +} diff --git a/node/vimeo.ts b/node/vimeo.ts index dc2ab4f..811285a 100644 --- a/node/vimeo.ts +++ b/node/vimeo.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** Vimeo埋め込み */ @@ -12,7 +12,9 @@ export interface Vimeo { children: PlainText; } -export interface VimeoUnit extends Unit { +export interface VimeoUnit extends BracketUnit { /** vimeoのvideo id */ videoId: string; + + params: { h?: string }; } diff --git a/node/youtube.ts b/node/youtube.ts index e2712d7..bfe5f4d 100644 --- a/node/youtube.ts +++ b/node/youtube.ts @@ -1,4 +1,4 @@ -import type { Unit } from "./unit.ts"; +import type { BracketUnit } from "./unit.ts"; import type { PlainText } from "./plainText.ts"; /** Youtube埋め込み */ @@ -6,26 +6,41 @@ export interface Youtube { type: "youtube"; /** 構文解析結果 */ - unit: YoutubeUnit & (VideoId | ListId); + unit: YoutubeUnit | YoutubeShortUnit | YoutubeListUnit | YoutubeLiveUnit; /** the same as `unit.content` */ children: PlainText; } -export interface YoutubeUnit extends Unit { - /** URL parameters */ - params: Record & { t?: number }; -} - -export interface VideoId { +export interface YoutubeUnitBase extends BracketUnit { /** Youtube video ID */ videoId: string; + + /** URL parameters */ + params: Record; +} +export interface YoutubeUnit extends YoutubeUnitBase { + content: `http${"s" | ""}://${ + | `${"www." | "music." | ""}youtube.com/watch?` + | "youtu.be/"}${string}`; +} +export interface YoutubeShortUnit extends YoutubeUnitBase { + type: "short"; + content: `http${"s" | ""}://${"www." | ""}youtube.com/shorts/${string}`; +} +export interface YoutubeLiveUnit extends YoutubeUnitBase { + type: "live"; + content: `http${"s" | ""}://${"www." | ""}youtube.com/live/${string}`; } -export interface ListId { +export interface YoutubeListUnit extends Omit { /** Youtube playlist ID * * `/playlist?list=xxx`の形のURLのときのみ生える */ listId: string; + content: `http${"s" | ""}://${ + | "www." + | "music." + | ""}youtube.com/playlist?${string}`; } diff --git a/pageMenu.ts b/pageMenu.ts index bc521f1..58062c7 100644 --- a/pageMenu.ts +++ b/pageMenu.ts @@ -2,11 +2,23 @@ import type { React } from "./vendor/react.ts"; import type { BaseStore } from "./baseStore.ts"; export type { BaseStore }; -export type AddMenuInit = { - title?: string; - image: string; - onClick?: (event: React.MouseEvent) => void; -}; +export type AddMenuInit = + & { + title?: string; + onClick?: (event: React.MouseEvent) => void; + } + & ( + | { + image: string; + } + | { + icon: string; + } + | { + image: string; + icon: string; + } + ); export type Menu = { image: string; items: ((Item & { separator: false }) | { separator: true })[]; @@ -17,6 +29,8 @@ export type Item = { title: string | (() => string); /** the URL of an image which views on the left of the title */ image?: string; + /** the class names of an icon which views on the left of the title */ + icon?: string; /** the event listener which is executed when the menu item is clicked */ onClick: (event: React.MouseEvent) => void; }; diff --git a/scrapbox.ts b/scrapbox.ts index 0124aba..9dfa6c5 100644 --- a/scrapbox.ts +++ b/scrapbox.ts @@ -1,31 +1,25 @@ import type { Line } from "./blocks.ts"; -import type { BasePage, StringLc } from "./base.ts"; +import type { PageId, StringLc, UnixTime } from "./base.ts"; import type { Layout, PartialLayout } from "./layout.ts"; import type { AddMenuInit, Item, PageMenu } from "./pageMenu.ts"; import type { EventEmitter } from "./vendor/events.ts"; -/** Type definition of `window.scrapbox` */ -export type Scrapbox = - & EventEmitter - & { - PageMenu: ExposedPageMenu; - PopupMenu: PopupMenu; - TimeStamp: TimeStamp; - Project: Project; - } - & ( - { - /** the current page layout */ - Layout: "page"; - Page: Page<"page">; - } | { - /** the current page layout */ - Layout: PartialLayout; - Page: Page; - } - ); - -/** `window.scrapbox`に露出している`PageMenu`の型 */ +/** Type definition of {@linkcode scrapbox} */ +export type Scrapbox = ScrapboxBase<"page"> | ScrapboxBase; + +/** Type definition of {@linkcode scrapbox} */ +export interface ScrapboxBase extends EventEmitter { + PageMenu: ExposedPageMenu; + PopupMenu: PopupMenu; + TimeStamp: TimeStamp; + Project: Project; + + /** the current page layout */ + get Layout(): L; + Page: Page; +} + +/** {@linkcode scrapbox}に露出している`PageMenu`の型 */ export interface ExposedPageMenu { /** get a particular Page Menu * @@ -52,7 +46,7 @@ export interface ExposedPageMenu { removeAllItems: () => void; } -/** `window.scrapbox`に露出している`PopupMenu`の型 */ +/** Type of {@linkcode ScrapboxBase.PopupMenu} */ export interface PopupMenu { /** Add a popup button * @@ -72,7 +66,7 @@ export interface PopupMenu { }) => void; } -/** `window.scrapbox`に露出している`TimeStamp`の型 */ +/** Type of {@linkcode ScrapboxBase.TimeStamp} */ export interface TimeStamp { /** Add a timestamp format to Scrapbox * @@ -87,31 +81,43 @@ export interface TimeStamp { removeAllFormat: () => void; } -/** 入力補完に使われる辞書 */ -export interface Candidate extends Pick { - /** true when the page has contents */ - exists: boolean; +/** Type of {@linkcode ScrapboxBase.Project} */ +export interface Project { + /** get the current project name */ + get name(): string; - /** thumbnail URL */ - image?: string; + /** get the dictionary used for comupletion */ + get pages(): (Candidate | Candidate)[]; +} + +/** A current project's pages information for any suggestions */ +export interface Candidate { + /** page id */ + id: Exists extends true ? PageId : never; + + /** the title of a page */ + title: string; - /** lower case style of the page title */ + /** lower-case styled {@linkcode Candidate.title} */ titleLc: StringLc; /** the length of `title` */ titleLengthForSort: number; -} -/** `window.scrapbox`に露出している`Project`の型 */ -export interface Project { - /** get the current project name */ - get name(): string; + /** the updated time */ + updated: Exists extends true ? UnixTime : 0; - /** get the dictionary used for comupletion */ - get pages(): Candidate[]; + /** `true` when the page has contents */ + exists: Exists; + + /** thumbnail URL */ + image: Exists extends true ? string | undefined : never; + + /** lower-case styled links in the page */ + linksLc: Exists extends true ? StringLc[] : never; } -/** `window.scrapbox`に露出している`Page`の型 */ +/** Type of {@linkcode ScrapboxBase.Page} */ export interface Page { /** get the current page lines data */ get lines(): T extends "page" ? Line[] : null; @@ -121,4 +127,49 @@ export interface Page { /** get the current page id */ get id(): T extends "page" ? string : null; + + /** get the current page metadata */ + get metadata(): T extends "page" ? PageMetadata : null; + + /** Insert `text` before the `line`-th line. + * + * This edit can be undone by the user. + * + * If {@linkcode ScrapboxBase.Layout} is not `"page"`, this method does nothing. + * + * @param text text to insert + * @param line line number to insert. `undefined` treats as `0` + */ + insertLine(text: string, line?: number): void; + + /** Replace the `line`-th line with `text`. + * + * This edit can be undone by the user. + * + * If {@linkcode ScrapboxBase.Layout} is not `"page"`, this method does nothing. + * + * @param text text to replace + * @param line line number to replace + */ + updateLine(text: string, line: number): void; + + /** Return a promise that resolves when all page edits are saved */ + waitForSave: () => Promise; + + /** Go to `title` page */ + show: (title: string) => Promise; +} + +/** A current page metadata that {@linkcode Page.metadata} returns */ +export interface PageMetadata { + links: string[]; + projectLinks: string[]; + icons: string[]; + images: string[]; + descriptions: string[]; + files: string[]; + helpfeels: string[]; + infoboxDefinition: string[]; + linesCount: number; + charsCount: number; }