A few more text manipulation commands
parent
b22775fcc4
commit
e74caf0055
|
@ -15,10 +15,6 @@ npm run build
|
||||||
npm install
|
npm install
|
||||||
# Build plugs (ctrl-c after done, it's watching)
|
# Build plugs (ctrl-c after done, it's watching)
|
||||||
npm run plugs
|
npm run plugs
|
||||||
# Symlink in the default set of plugs into your space
|
|
||||||
cd pages
|
|
||||||
ln -s ../packages/plugs/dist _plug
|
|
||||||
cd ..
|
|
||||||
# Launch server
|
# Launch server
|
||||||
npm run server
|
npm run server
|
||||||
```
|
```
|
||||||
|
|
|
@ -26512,7 +26512,7 @@
|
||||||
"nodemon": "^2.0.15",
|
"nodemon": "^2.0.15",
|
||||||
"parcel": "2.5.0",
|
"parcel": "2.5.0",
|
||||||
"typescript": "^4.6.2",
|
"typescript": "^4.6.2",
|
||||||
"uuid": "*",
|
"uuid": "^8.3.2",
|
||||||
"vm2": "^3.9.9",
|
"vm2": "^3.9.9",
|
||||||
"ws": "^8.5.0",
|
"ws": "^8.5.0",
|
||||||
"yaml": "^1.10.2",
|
"yaml": "^1.10.2",
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "rm -rf .parcel-cache && parcel watch --no-hmr packages/{web,server,plugos,plugs} desktop",
|
"watch": "rm -rf .parcel-cache && parcel watch --no-hmr packages/{web,server,plugos,plugs} desktop",
|
||||||
"clean": "rm -rf .parcel-cache packages/*/dist",
|
"clean": "rm -rf .parcel-cache packages/*/dist",
|
||||||
|
"nuke": "rm -rf node_modules && npm run clean",
|
||||||
"build": "parcel build packages/{web,server,plugos}",
|
"build": "parcel build packages/{web,server,plugos}",
|
||||||
"plugs": "cd packages/plugs && npm run watch",
|
"plugs": "cd packages/plugs && npm run watch",
|
||||||
"server": "nodemon -w packages/server/dist --exec 'silverbullet pages'",
|
"server": "nodemon -w packages/server/dist --exec 'silverbullet pages'",
|
||||||
|
|
|
@ -139,6 +139,14 @@ functions:
|
||||||
name: "Text: Quote Selection"
|
name: "Text: Quote Selection"
|
||||||
key: "Ctrl->"
|
key: "Ctrl->"
|
||||||
mac: "Cmd-Shift-."
|
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:
|
bold:
|
||||||
path: ./text.ts:boldCommand
|
path: ./text.ts:boldCommand
|
||||||
command:
|
command:
|
||||||
|
|
|
@ -26,6 +26,36 @@ export async function quoteSelection() {
|
||||||
await replaceRange(from, selection.to, text);
|
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() {
|
export function boldCommand() {
|
||||||
return insertMarker("**");
|
return insertMarker("**");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue