A few more text manipulation commands
This commit is contained in:
parent
b22775fcc4
commit
e74caf0055
@ -15,10 +15,6 @@ npm run build
|
||||
npm install
|
||||
# Build plugs (ctrl-c after done, it's watching)
|
||||
npm run plugs
|
||||
# Symlink in the default set of plugs into your space
|
||||
cd pages
|
||||
ln -s ../packages/plugs/dist _plug
|
||||
cd ..
|
||||
# Launch server
|
||||
npm run server
|
||||
```
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -26512,7 +26512,7 @@
|
||||
"nodemon": "^2.0.15",
|
||||
"parcel": "2.5.0",
|
||||
"typescript": "^4.6.2",
|
||||
"uuid": "*",
|
||||
"uuid": "^8.3.2",
|
||||
"vm2": "^3.9.9",
|
||||
"ws": "^8.5.0",
|
||||
"yaml": "^1.10.2",
|
||||
|
@ -6,6 +6,7 @@
|
||||
"scripts": {
|
||||
"watch": "rm -rf .parcel-cache && parcel watch --no-hmr packages/{web,server,plugos,plugs} desktop",
|
||||
"clean": "rm -rf .parcel-cache packages/*/dist",
|
||||
"nuke": "rm -rf node_modules && npm run clean",
|
||||
"build": "parcel build packages/{web,server,plugos}",
|
||||
"plugs": "cd packages/plugs && npm run watch",
|
||||
"server": "nodemon -w packages/server/dist --exec 'silverbullet pages'",
|
||||
|
@ -139,6 +139,14 @@ functions:
|
||||
name: "Text: Quote Selection"
|
||||
key: "Ctrl->"
|
||||
mac: "Cmd-Shift-."
|
||||
listifySelection:
|
||||
path: ./text.ts:listifySelection
|
||||
command:
|
||||
name: "Text: Listify Selection"
|
||||
numberListifySelection:
|
||||
path: ./text.ts:numberListifySelection
|
||||
command:
|
||||
name: "Text: Number Listify Selection"
|
||||
bold:
|
||||
path: ./text.ts:boldCommand
|
||||
command:
|
||||
|
@ -26,6 +26,36 @@ export async function quoteSelection() {
|
||||
await replaceRange(from, selection.to, text);
|
||||
}
|
||||
|
||||
export async function listifySelection() {
|
||||
let text = await getText();
|
||||
const selection = await getSelection();
|
||||
let from = selection.from;
|
||||
while (from >= 0 && text[from] !== "\n") {
|
||||
from--;
|
||||
}
|
||||
from++;
|
||||
text = text.slice(from, selection.to);
|
||||
text = `* ${text.replaceAll(/\n(?!\n)/g, "\n* ")}`;
|
||||
await replaceRange(from, selection.to, text);
|
||||
}
|
||||
|
||||
export async function numberListifySelection() {
|
||||
let text = await getText();
|
||||
const selection = await getSelection();
|
||||
let from = selection.from;
|
||||
while (from >= 0 && text[from] !== "\n") {
|
||||
from--;
|
||||
}
|
||||
from++;
|
||||
text = text.slice(from, selection.to);
|
||||
let counter = 1;
|
||||
text = `1. ${text.replaceAll(/\n(?!\n)/g, () => {
|
||||
counter++;
|
||||
return `\n${counter}. `;
|
||||
})}`;
|
||||
await replaceRange(from, selection.to, text);
|
||||
}
|
||||
|
||||
export function boldCommand() {
|
||||
return insertMarker("**");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user