changement de noms et correction ticket caractères accentués par composition

pull/13/head
Nicolas Sanchez 3 years ago
parent 53986db3f7
commit cf7243bf61

36
Cargo.lock generated

@ -435,6 +435,24 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cheezenotes"
version = "0.1.0"
dependencies = [
"actix-files",
"actix-web",
"askama",
"askama_actix",
"clap",
"git2",
"lazy_static",
"mongodb",
"regex",
"rusqlite",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.23" version = "0.4.23"
@ -1249,24 +1267,6 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "mdnotes"
version = "0.1.0"
dependencies = [
"actix-files",
"actix-web",
"askama",
"askama_actix",
"clap",
"git2",
"lazy_static",
"mongodb",
"regex",
"rusqlite",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.5.0"

@ -1,5 +1,5 @@
[package] [package]
name = "mdnotes" name = "cheezenotes"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

@ -1,4 +1,4 @@
mdnotes cheezenotes
====== ======
Notes utilisant la syntaxe MarkDown pour être rapide et facile à modifier. Notes utilisant la syntaxe MarkDown pour être rapide et facile à modifier.

@ -1,5 +1,5 @@
# RustyNotes # CheezeNotes
L'objectif de RustyNotes est de pouvoir saisir des notes avec un minimum de formatage le plus rapidement possible. L'objectif de CheezeNotes est de pouvoir saisir des notes avec un minimum de formatage le plus rapidement possible.
> Cette page est un bac à sable. Les modifications ne seront jamais enregistrées. > Cette page est un bac à sable. Les modifications ne seront jamais enregistrées.
> Pour réinitialiser la page, il suffit de la recharger. > Pour réinitialiser la page, il suffit de la recharger.
## Utilisation ## Utilisation
@ -13,6 +13,8 @@ Il y a 4 niveaux de titres :
- `## titre 2` - `## titre 2`
- `### titre 3` - `### titre 3`
- `#### titre 4` - `#### titre 4`
- `##### titre 5`
- `###### titre 6`
### **Gras**, *italic* etc. ### **Gras**, *italic* etc.
|:Syntaxe:|:Résultat:|:Ok ?:| |:Syntaxe:|:Résultat:|:Ok ?:|
|:`**gras**`|:**gras**|:| |:`**gras**`|:**gras**|:|
@ -23,6 +25,7 @@ Il y a 4 niveaux de titres :
|`___gras_italic___`|___gras_italic___|Non| |`___gras_italic___`|___gras_italic___|Non|
|`__*gras_italic*__`|__*gras_italic*__|| |`__*gras_italic*__`|__*gras_italic*__||
|````texte formaté````|`texte formaté`|| |````texte formaté````|`texte formaté`||
| `````````|```||
### Liens ### Liens
Pour une url longue à laquelle on veut associer un libellé plus parlant, on choisira la syntaxe complète : Pour une url longue à laquelle on veut associer un libellé plus parlant, on choisira la syntaxe complète :
- [Wikipedia Markdown](https://fr.wikipedia.org/wiki/Markdown) - [Wikipedia Markdown](https://fr.wikipedia.org/wiki/Markdown)

@ -6,7 +6,7 @@ pub struct Arguments {
#[arg(short, long, default_value_t = String::from("127.0.0.1"))] #[arg(short, long, default_value_t = String::from("127.0.0.1"))]
pub ip: String, pub ip: String,
/// Port to listen to /// Port to listen to
#[arg(short, long, default_value_t = 8081)] #[arg(short, long, default_value_t = 8333)]
pub port: u16, pub port: u16,
/// root of the url ending and starting with / /// root of the url ending and starting with /
#[arg(short, long, default_value_t = String::from("/"))] #[arg(short, long, default_value_t = String::from("/"))]

@ -1,8 +1,8 @@
use actix_web::{web, App, HttpServer}; use actix_web::{web, App, HttpServer};
use actix_files; use actix_files;
use mdnotes::commons::{Arguments, AppData}; use cheezenotes::commons::{Arguments, AppData};
use mdnotes::{ page, index }; use cheezenotes::{ page, index };
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {

@ -37,9 +37,9 @@ async fn page(path: web::Path<(String,)>, data: web::Data<AppData>) -> impl Resp
#[put("/page/{page}")] #[put("/page/{page}")]
async fn save_page(body: String, path: web::Path<(String,)>) -> impl Responder { async fn save_page(body: String, path: web::Path<(String,)>) -> impl Responder {
let pagename = &path.0; let pagename = &path.0;
if pagename == "index" { /*if pagename == "index" {
return HttpResponse::Ok(); return HttpResponse::Ok();
} }*/
let filename = String::from("pages/") + pagename.as_str() + ".md"; let filename = String::from("pages/") + pagename.as_str() + ".md";
let mut file = match fs::File::create(&filename) { let mut file = match fs::File::create(&filename) {
Ok(f) => f, Ok(f) => f,

@ -55,7 +55,7 @@ textarea#ta {
background-color: #cceeff; background-color: #cceeff;
} }
div#mdnotes { div#cheezenotes {
margin-top: 3rem; margin-top: 3rem;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@ -70,27 +70,27 @@ div#mdnotes {
overflow-x: auto; overflow-x: auto;
} }
div#mdnotes div.mdnotes_line { div#cheezenotes div.cheezenotes_line {
/* Pour firefox : white-space: pre; */ /* Pour firefox : white-space: pre; */
} }
div#mdnotes span.tokenfictif { div#cheezenotes span.tokenfictif {
font-weight: 1; font-weight: 1;
color: #1353b3; color: #1353b3;
} }
div#mdnotes:focus { div#cheezenotes:focus {
outline: none; outline: none;
} }
div#mdnotes div.line { div#cheezenotes div.line {
border-bottom: 1px solid #dddddd; border-bottom: 1px solid #dddddd;
padding-top: 0rem; padding-top: 0rem;
margin-top: 0rem; margin-top: 0rem;
font-size: 8pt; font-size: 8pt;
} }
div#mdnotes div.h1 { div#cheezenotes div.h1 {
font-size: 3rem; font-size: 3rem;
margin-top: 1.5rem; margin-top: 1.5rem;
margin-bottom: 1.3rem; margin-bottom: 1.3rem;
@ -98,26 +98,37 @@ div#mdnotes div.h1 {
border-bottom: 1px solid #dddddd; border-bottom: 1px solid #dddddd;
} }
div#mdnotes div.h2 { div#cheezenotes div.h2 {
font-size: 2.3rem; font-size: 2.3rem;
margin-top: 1rem; margin-top: 1rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
div#mdnotes div.h3 { div#cheezenotes div.h3 {
font-size: 1.8rem; font-size: 1.8rem;
margin-top: 0.8rem; margin-top: 0.8rem;
margin-bottom: 0.8rem; margin-bottom: 0.8rem;
} }
div#mdnotes div.h4 { div#cheezenotes div.h4 {
font-style: italic; font-size: 1.5rem;
font-size: 1.4rem; margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
div#cheezenotes div.h5 {
font-size: 1.3rem;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
div#cheezenotes div.h6 {
font-size: 1.2rem;
margin-top: 0.5rem; margin-top: 0.5rem;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
div#mdnotes div.bq1 { div#cheezenotes div.bq1 {
padding-top: 0.3rem; padding-top: 0.3rem;
padding-bottom: 0.3rem; padding-bottom: 0.3rem;
padding-left: .9rem; padding-left: .9rem;
@ -125,7 +136,7 @@ div#mdnotes div.bq1 {
border-left: .3rem solid #446699; border-left: .3rem solid #446699;
} }
div#mdnotes div.bq2 { div#cheezenotes div.bq2 {
padding-top: 0.3rem; padding-top: 0.3rem;
padding-bottom: 0.3rem; padding-bottom: 0.3rem;
padding-left: .6rem; padding-left: .6rem;
@ -133,7 +144,7 @@ div#mdnotes div.bq2 {
border-left: .6rem solid #5577aa; border-left: .6rem solid #5577aa;
} }
div#mdnotes div.bq3 { div#cheezenotes div.bq3 {
padding-top: 0.3rem; padding-top: 0.3rem;
padding-bottom: 0.3rem; padding-bottom: 0.3rem;
padding-left: .3rem; padding-left: .3rem;
@ -141,111 +152,111 @@ div#mdnotes div.bq3 {
border-left: .9rem solid #6688bb; border-left: .9rem solid #6688bb;
} }
div#mdnotes div.ul1 { display:list-item; list-style-position: inside; padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; } div#cheezenotes div.ul1 { display:list-item; list-style-position: inside; padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ul1.bq1 { padding-left: 1.9rem; } div#cheezenotes div.ul1.bq1 { padding-left: 1.9rem; }
div#mdnotes div.ul1.bq2 { padding-left: 1.6rem; } div#cheezenotes div.ul1.bq2 { padding-left: 1.6rem; }
div#mdnotes div.ul1.bq3 { padding-left: 1.3rem; } div#cheezenotes div.ul1.bq3 { padding-left: 1.3rem; }
div#mdnotes div.ul2 { display:list-item; list-style-position: inside; list-style-type: circle; padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; } div#cheezenotes div.ul2 { display:list-item; list-style-position: inside; list-style-type: circle; padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ul2.bq1 { padding-left: 2.4rem; } div#cheezenotes div.ul2.bq1 { padding-left: 2.4rem; }
div#mdnotes div.ul2.bq2 { padding-left: 2.1rem; } div#cheezenotes div.ul2.bq2 { padding-left: 2.1rem; }
div#mdnotes div.ul2.bq3 { padding-left: 1.8rem; } div#cheezenotes div.ul2.bq3 { padding-left: 1.8rem; }
div#mdnotes div.ul3 { display:list-item; list-style-position: inside; list-style-type: square; padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; } div#cheezenotes div.ul3 { display:list-item; list-style-position: inside; list-style-type: square; padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ul3.bq1 { padding-left: 2.9rem; } div#cheezenotes div.ul3.bq1 { padding-left: 2.9rem; }
div#mdnotes div.ul3.bq2 { padding-left: 2.6rem; } div#cheezenotes div.ul3.bq2 { padding-left: 2.6rem; }
div#mdnotes div.ul3.bq3 { padding-left: 2.3rem; } div#cheezenotes div.ul3.bq3 { padding-left: 2.3rem; }
div#mdnotes div.ol1 { padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; } div#cheezenotes div.ol1 { padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ol1.bq1 { padding-left: 1.9rem; } div#cheezenotes div.ol1.bq1 { padding-left: 1.9rem; }
div#mdnotes div.ol1.bq2 { padding-left: 1.6rem; } div#cheezenotes div.ol1.bq2 { padding-left: 1.6rem; }
div#mdnotes div.ol1.bq3 { padding-left: 1.3rem; } div#cheezenotes div.ol1.bq3 { padding-left: 1.3rem; }
div#mdnotes div.ol2 { padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; } div#cheezenotes div.ol2 { padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ol2.bq1 { padding-left: 2.4rem; } div#cheezenotes div.ol2.bq1 { padding-left: 2.4rem; }
div#mdnotes div.ol2.bq2 { padding-left: 2.1rem; } div#cheezenotes div.ol2.bq2 { padding-left: 2.1rem; }
div#mdnotes div.ol2.bq3 { padding-left: 1.8rem; } div#cheezenotes div.ol2.bq3 { padding-left: 1.8rem; }
div#mdnotes div.ol3 { padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; } div#cheezenotes div.ol3 { padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ol3.bq1 { padding-left: 2.9rem; } div#cheezenotes div.ol3.bq1 { padding-left: 2.9rem; }
div#mdnotes div.ol3.bq2 { padding-left: 2.6rem; } div#cheezenotes div.ol3.bq2 { padding-left: 2.6rem; }
div#mdnotes div.ol3.bq3 { padding-left: 2.3rem; } div#cheezenotes div.ol3.bq3 { padding-left: 2.3rem; }
div#mdnotes span.oltoken { div#cheezenotes span.oltoken {
display: inline-block; display: inline-block;
width: 2rem; width: 2rem;
} }
div#mdnotes span.lefttablespacer { div#cheezenotes span.lefttablespacer {
display: inline-block; display: inline-block;
} }
div#mdnotes span.righttablespacer { div#cheezenotes span.righttablespacer {
display: inline-block; display: inline-block;
} }
div#mdnotes div.tablerow { div#cheezenotes div.tablerow {
margin-top: .5rem; margin-top: .5rem;
margin-bottom: .9rem; margin-bottom: .9rem;
overflow-x: visible; overflow-x: visible;
} }
div#mdnotes span.tablerow { div#cheezenotes span.tablerow {
white-space: nowrap; white-space: nowrap;
overflow-x: visible; overflow-x: visible;
border-bottom: 1px solid #dddddd; border-bottom: 1px solid #dddddd;
padding-bottom: 0.4rem; padding-bottom: 0.4rem;
} }
div#mdnotes div.firsttablerow { div#cheezenotes div.firsttablerow {
margin-top: 1.5rem; margin-top: 1.5rem;
} }
div#mdnotes div.firsttablerow span.tablerow { div#cheezenotes div.firsttablerow span.tablerow {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
border-bottom: 1px solid #666666; border-bottom: 1px solid #666666;
font-weight: bold; font-weight: bold;
} }
div#mdnotes div.lasttablerow { div#cheezenotes div.lasttablerow {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
div#mdnotes div.lasttablerow span.tablerow { div#cheezenotes div.lasttablerow span.tablerow {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
border-bottom: none; border-bottom: none;
} }
div#mdnotes div.mdnotes_line span.token { div#cheezenotes div.cheezenotes_line span.token {
font-weight: 1; font-weight: 1;
color: #1353b3; color: #1353b3;
overflow: hidden; overflow: hidden;
} }
div#mdnotes div.mdnotes_line span.token { div#cheezenotes div.cheezenotes_line span.token {
font-size: 0; font-size: 0;
} }
div#mdnotes:focus div.mdnotes_line span.token { div#cheezenotes:focus div.cheezenotes_line span.token {
font-size: inherit; font-size: inherit;
} }
div#mdnotes div.body { div#cheezenotes div.body {
margin-top: 0.5rem; margin-top: 0.5rem;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
div#mdnotes span.bold { div#cheezenotes span.bold {
font-weight: bold; font-weight: bold;
} }
div#mdnotes span.italic { div#cheezenotes span.italic {
font-style: italic; font-style: italic;
} }
div#mdnotes span.mono { div#cheezenotes span.mono {
font-family: monospace; font-family: monospace;
color: #885511; color: #555555;
} }

@ -8,7 +8,7 @@ function getStartPositionInLine() {
let position = range.startOffset; let position = range.startOffset;
if (obj.nodeName == 'DIV' && obj.classList.contains('mdnotes_line')) { if (obj.nodeName == 'DIV' && obj.classList.contains('cheezenotes_line')) {
return [obj, position]; return [obj, position];
} }
@ -22,9 +22,9 @@ function getStartPositionInLine() {
} else if (obj.length != null) { } else if (obj.length != null) {
position += obj.length; position += obj.length;
} }
} else if (obj.parentNode != null && obj.parentNode.classList != null && !obj.parentNode.classList.contains('mdnotes_line')) { } else if (obj.parentNode != null && obj.parentNode.classList != null && !obj.parentNode.classList.contains('cheezenotes_line')) {
obj = obj.parentNode; obj = obj.parentNode;
} else if (obj.parentNode != null && obj.parentNode.classList != null && obj.parentNode.classList.contains('mdnotes_line')) { } else if (obj.parentNode != null && obj.parentNode.classList != null && obj.parentNode.classList.contains('cheezenotes_line')) {
line = obj.parentNode; line = obj.parentNode;
obj = null; obj = null;
} else { } else {

@ -20,7 +20,7 @@ function ontextarea(e) {
function onsave(e) { function onsave(e) {
let saveButton = document.getElementById('saveButton'); let saveButton = document.getElementById('saveButton');
saveButton.disabled = true; saveButton.disabled = true;
let text = save(document.getElementById('ta'), document.getElementById('mdnotes')); let text = save(document.getElementById('ta'), document.getElementById('cheezenotes'));
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () { xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status != 200) { if (this.readyState == 4 && this.status != 200) {
@ -33,11 +33,16 @@ function onsave(e) {
} }
function onload(e) { function onload(e) {
load(document.getElementById('ta'), document.getElementById('mdnotes')); load(document.getElementById('ta'), document.getElementById('cheezenotes'));
} }
function onedit(e) { function onedit(e) {
console.log('onedit');
if (e.inputType == 'insertCompositionText') {
e.preventDefault();
return false;
}
timeoutSave(); timeoutSave();
saveButton.disabled = false; saveButton.disabled = false;
let ret = getStartPositionInLine(); let ret = getStartPositionInLine();
@ -45,14 +50,14 @@ function onedit(e) {
let position = ret[1]; let position = ret[1];
if (line.innerText == '\n') { if (line.innerText == '\n') {
line.className = 'mdnotes_line'; line.className = 'cheezenotes_line';
line.classList.add('body'); line.classList.add('body');
return; return;
} }
let prevline = line.previousSibling; let prevline = line.previousSibling;
if (prevline != null && prevline.innerText == '\n') { if (prevline != null && prevline.innerText == '\n') {
prevline.className = 'mdnotes_line'; prevline.className = 'cheezenotes_line';
prevline.classList.add('body'); prevline.classList.add('body');
} }
@ -84,24 +89,24 @@ function onkeydown(e) {
return false; return false;
} }
function onkeypress(e) { function onkeyup(e) {
if (e.key !== 'Escape') { if (e.key !== 'Escape') {
return true; return true;
} }
e.preventDefault(); e.preventDefault();
document.getElementById('mdnotes').blur(); document.getElementById('cheezenotes').blur();
if (saveButton.disabled == false) { if (saveButton.disabled == false) {
onsave(); onsave();
} }
return false; return false;
} }
function onkeyup(e) { function onkeypress(e) {
if (e.key !== 'Escape') { if (e.key !== 'Escape') {
return true; return true;
} }
e.preventDefault(); e.preventDefault();
document.getElementById('mdnotes').blur(); document.getElementById('cheezenotes').blur();
if (saveButton.disabled == false) { if (saveButton.disabled == false) {
onsave(); onsave();
} }
@ -112,7 +117,7 @@ function onpaste(e) {
e.preventDefault(); e.preventDefault();
timeoutSave(); timeoutSave();
let data = e.clipboardData.getData('text/plain'); let data = e.clipboardData.getData('text/plain');
appendData(document.getElementById('mdnotes'), data); appendData(document.getElementById('cheezenotes'), data);
saveButton.disabled = false; saveButton.disabled = false;
return false; return false;
} }
@ -123,11 +128,11 @@ function oncopy(e) {
function onlockbutton(e) { function onlockbutton(e) {
let lockButton = document.getElementById('lockButton'); let lockButton = document.getElementById('lockButton');
let mdnotes = document.getElementById('mdnotes'); let cheezenotes = document.getElementById('cheezenotes');
if (lockButton.checked) { if (lockButton.checked) {
mdnotes.contentEditable = false; cheezenotes.contentEditable = false;
} else { } else {
mdnotes.contentEditable = true; cheezenotes.contentEditable = true;
} }
} }
@ -147,21 +152,21 @@ function init(pagename = null) {
/*if (pagename != null) { /*if (pagename != null) {
window.history.replaceState(null, '', '/page/' + pagename); window.history.replaceState(null, '', '/page/' + pagename);
}*/ }*/
let mdnotesdiv = document.getElementById('mdnotes'); let cheezenotesdiv = document.getElementById('cheezenotes');
dpwidth(mdnotesdiv); dpwidth(cheezenotesdiv);
mdnotesdiv.addEventListener('input', onedit); cheezenotesdiv.addEventListener('input', onedit);
mdnotesdiv.addEventListener('keyup', onkeyup); cheezenotesdiv.addEventListener('keyup', onkeyup);
mdnotesdiv.addEventListener('keypress', onkeypress); cheezenotesdiv.addEventListener('keypress', onkeypress);
mdnotesdiv.addEventListener('keydown', onkeydown); cheezenotesdiv.addEventListener('keydown', onkeydown);
mdnotesdiv.addEventListener('paste', onpaste); cheezenotesdiv.addEventListener('paste', onpaste);
mdnotesdiv.addEventListener('copy', oncopy); cheezenotesdiv.addEventListener('copy', oncopy);
mdnotesdiv.addEventListener('blur', () => {redrawTables(mdnotesdiv); onsave()}); cheezenotesdiv.addEventListener('blur', () => { redrawTables(cheezenotesdiv); onsave() });
mdnotesdiv.addEventListener('focus', () => {redrawTables(mdnotesdiv, dpwidth());}); cheezenotesdiv.addEventListener('focus', () => { redrawTables(cheezenotesdiv, dpwidth()); });
mdnotesdiv.addEventListener('drag', ondrag); cheezenotesdiv.addEventListener('drag', ondrag);
mdnotesdiv.addEventListener('dragenter', ondragenter); cheezenotesdiv.addEventListener('dragenter', ondragenter);
mdnotesdiv.addEventListener('dragleave', ondragleave); cheezenotesdiv.addEventListener('dragleave', ondragleave);
let saveButton = document.getElementById('saveButton'); let saveButton = document.getElementById('saveButton');
saveButton.disabled = true; saveButton.disabled = true;

@ -80,16 +80,16 @@ function emsp() {
function onlinkin(e) { function onlinkin(e) {
let link = e.currentTarget; let link = e.currentTarget;
if (document.getElementById('mdnotes') !== document.activeElement) { if (document.getElementById('cheezenotes') !== document.activeElement) {
document.getElementById('mdnotes').contentEditable = false; document.getElementById('cheezenotes').contentEditable = false;
} }
} }
function onlink(e) { function onlink(e) {
let mdnotes = document.getElementById('mdnotes'); let cheezenotes = document.getElementById('cheezenotes');
if (mdnotes.contentEditable == 'false') { if (cheezenotes.contentEditable == 'false') {
e.preventDefault(); e.preventDefault();
mdnotes.contentEditable = true; cheezenotes.contentEditable = true;
let link = e.currentTarget; let link = e.currentTarget;
if (link.host !== document.location.host) { if (link.host !== document.location.host) {
open(link.href); open(link.href);
@ -103,16 +103,16 @@ function onlink(e) {
} }
function onlinkout(e) { function onlinkout(e) {
let mdnotes = document.getElementById('mdnotes'); let cheezenotes = document.getElementById('cheezenotes');
if (mdnotes.contentEditable == 'false') { if (cheezenotes.contentEditable == 'false') {
mdnotes.contentEditable = true; cheezenotes.contentEditable = true;
} }
} }
function formatLine(line) { function formatLine(line) {
let token = null; let token = null;
let elem = document.createElement('div'); let elem = document.createElement('div');
elem.classList.add('mdnotes_line'); elem.classList.add('cheezenotes_line');
if (line == '' || line == '\n') { if (line == '' || line == '\n') {
elem.classList.add('body'); elem.classList.add('body');
elem.innerHTML = '<br>'; elem.innerHTML = '<br>';
@ -129,9 +129,15 @@ function formatLine(line) {
ret = removeLink(line); ret = removeLink(line);
console.log('removeLink ' + ret[0]); console.log('removeLink ' + ret[0]);
if (line.match(/^\s*-{3,}\s*$/)) { if (line.match(/^\s*_{3,}\s*$/)) {
token = /^(\s*-{3,}\s*)$/ token = /^(\s*_{3,}\s*)$/
elem.classList.add('line'); elem.classList.add('line');
} else if (line.match(/^\s*######(\s|$)/i)) {
token = /^(\s*######(\s|$))/i;
elem.classList.add('h6');
} else if (line.match(/^\s*#####(\s|$)/i)) {
token = /^(\s*#####(\s|$))/i;
elem.classList.add('h5');
} else if (line.match(/^\s*####(\s|$)/i)) { } else if (line.match(/^\s*####(\s|$)/i)) {
token = /^(\s*####(\s|$))/i; token = /^(\s*####(\s|$))/i;
elem.classList.add('h4'); elem.classList.add('h4');
@ -282,11 +288,11 @@ function addTableLine(line) {
return line; return line;
} }
function redrawTables(mdnotes, dpwidth = 0) { function redrawTables(cheezenotes, dpwidth = 0) {
if (mdnotes.childNodes.length == 0) { if (cheezenotes.childNodes.length == 0) {
return; return;
} }
let child = mdnotes.childNodes[0]; let child = cheezenotes.childNodes[0];
let firsttableline = null; let firsttableline = null;
while(child != null) { while(child != null) {
if (firsttableline == null) { if (firsttableline == null) {

@ -13,8 +13,8 @@
</head> </head>
<body> <body>
<div id="buttons"><button id="saveButton">💾</button> <input type="checkbox" id="taButton" /><label id="taButtonLabel" for="taButton">📋</label> <input type="checkbox" id="lockButton" /><label id="lockButtonLabel" for="lockButton">&#128065</label></div> <div id="buttons"><button id="saveButton">💾</button> <input type="checkbox" id="taButton" /><label id="taButtonLabel" for="taButton">📋</label> <input type="checkbox" id="lockButton" /><label id="lockButtonLabel" for="lockButton">&#128065</label></div>
<div class="ta"><textarea id="ta" class="mdnotes" spellcheck="false">{{md}}</textarea></body><div> <div class="ta"><textarea id="ta" class="cheezenotes" spellcheck="false">{{md}}</textarea></body><div>
<div id="mdnotes" class="mdnotes" contenteditable="true" spellcheck="false"></div> <div id="cheezenotes" class="cheezenotes" contenteditable="true" spellcheck="false"></div>
<script type="module"> <script type="module">
import { init } from '{{ root|safe }}static/modules/cheezenotes.js'; import { init } from '{{ root|safe }}static/modules/cheezenotes.js';

Loading…
Cancel
Save