|
|
@ -196,7 +196,7 @@ class Note {
|
|
|
|
$title = preg_replace([
|
|
|
|
$title = preg_replace([
|
|
|
|
"/^- \[ \] /m",
|
|
|
|
"/^- \[ \] /m",
|
|
|
|
"/^- \[x\] /m"
|
|
|
|
"/^- \[x\] /m"
|
|
|
|
], "", $title);
|
|
|
|
], "", $title);
|
|
|
|
return trim($title);
|
|
|
|
return trim($title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -326,6 +326,14 @@ class Note {
|
|
|
|
$this->setText(implode("\n", $text));
|
|
|
|
$this->setText(implode("\n", $text));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Remove checklist markup from the note.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function fromChecklist() {
|
|
|
|
|
|
|
|
$text = preg_replace("/^- \[[ x]\] /im", "", $this->getText());
|
|
|
|
|
|
|
|
$this->setText($text);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Toggle the checked status of a checklist item.
|
|
|
|
* Toggle the checked status of a checklist item.
|
|
|
|
* @param string $item The text of the item to toggle.
|
|
|
|
* @param string $item The text of the item to toggle.
|
|
|
@ -334,17 +342,17 @@ class Note {
|
|
|
|
$text = explode("\n", $this->getText());
|
|
|
|
$text = explode("\n", $this->getText());
|
|
|
|
$item = trim(str_replace("\n", "", $item));
|
|
|
|
$item = trim(str_replace("\n", "", $item));
|
|
|
|
for ($i = 0; $i < count($text); $i++) {
|
|
|
|
for ($i = 0; $i < count($text); $i++) {
|
|
|
|
if (!preg_match("/^- \[[x ]\] .*/", $text[$i])) {
|
|
|
|
if (!preg_match("/^- \[[x ]\] .*/i", $text[$i])) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$linecleaned = trim(preg_replace("/^- \[[x ]\] /", "", $text[$i]));
|
|
|
|
$linecleaned = trim(preg_replace("/^- \[[x ]\] /i", "", $text[$i]));
|
|
|
|
if ($item != $linecleaned) {
|
|
|
|
if ($item != $linecleaned) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (preg_match("/^- \[[x]\] .*/", $text[$i])) {
|
|
|
|
if (preg_match("/^- \[[x]\] .*/i", $text[$i])) {
|
|
|
|
$text[$i] = preg_replace("/^- \[[x]\] /", "- [ ] ", $text[$i]);
|
|
|
|
$text[$i] = preg_replace("/^- \[[x]\] /i", "- [ ] ", $text[$i]);
|
|
|
|
} else if (preg_match("/^- \[ \] .*/", $text[$i])) {
|
|
|
|
} else if (preg_match("/^- \[ \] .*/i", $text[$i])) {
|
|
|
|
$text[$i] = preg_replace("/^- \[ \] /", "- [x] ", $text[$i]);
|
|
|
|
$text[$i] = preg_replace("/^- \[ \] /i", "- [x] ", $text[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->setText(implode("\n", $text));
|
|
|
|
$this->setText(implode("\n", $text));
|
|
|
|