Changed named anchor syntax
parent
246d3ae45b
commit
a2e5d0cc93
|
@ -11,7 +11,7 @@ export async function indexAnchors({ name: pageName, tree }: IndexTreeEvent) {
|
||||||
const anchors: { key: string; value: string }[] = [];
|
const anchors: { key: string; value: string }[] = [];
|
||||||
|
|
||||||
collectNodesOfType(tree, "NamedAnchor").forEach((n) => {
|
collectNodesOfType(tree, "NamedAnchor").forEach((n) => {
|
||||||
const aName = n.children![0].text!;
|
const aName = n.children![0].text!.substring(1);
|
||||||
anchors.push({
|
anchors.push({
|
||||||
key: `a:${pageName}:${aName}`,
|
key: `a:${pageName}:${aName}`,
|
||||||
value: "" + n.from,
|
value: "" + n.from,
|
||||||
|
@ -31,11 +31,13 @@ export async function anchorComplete() {
|
||||||
if (!pageRef) {
|
if (!pageRef) {
|
||||||
pageRef = await editor.getCurrentPage();
|
pageRef = await editor.getCurrentPage();
|
||||||
}
|
}
|
||||||
const allAnchors = await index.queryPrefix(`a:${pageRef}:@${anchorRef}`);
|
const allAnchors = await index.queryPrefix(
|
||||||
|
`a:${pageRef}:${anchorRef}`,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
from: prefix.from + pageRefPrefix.length + 1,
|
from: prefix.from + pageRefPrefix.length + 1,
|
||||||
options: allAnchors.map((a) => ({
|
options: allAnchors.map((a) => ({
|
||||||
label: a.key.split("@")[1],
|
label: a.key.split(":")[2],
|
||||||
type: "anchor",
|
type: "anchor",
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,8 +19,8 @@ syntax:
|
||||||
className: sb-command-link
|
className: sb-command-link
|
||||||
NamedAnchor:
|
NamedAnchor:
|
||||||
firstCharacters:
|
firstCharacters:
|
||||||
- "@"
|
- "$"
|
||||||
regex: "@[a-zA-Z\\.\\-\\/]+[\\w\\.\\-\\/]*"
|
regex: "\\$[a-zA-Z\\.\\-\\/]+[\\w\\.\\-\\/]*"
|
||||||
className: sb-named-anchor
|
className: sb-named-anchor
|
||||||
functions:
|
functions:
|
||||||
clearPageIndex:
|
clearPageIndex:
|
||||||
|
|
|
@ -201,7 +201,7 @@ export class Editor {
|
||||||
const stateRestored = await this.loadPage(pageName);
|
const stateRestored = await this.loadPage(pageName);
|
||||||
if (pos) {
|
if (pos) {
|
||||||
if (typeof pos === "string") {
|
if (typeof pos === "string") {
|
||||||
// console.log("Navigating to anchor", pos);
|
console.log("Navigating to anchor", pos);
|
||||||
|
|
||||||
// We're going to look up the anchor through a direct page store query...
|
// We're going to look up the anchor through a direct page store query...
|
||||||
const posLookup = await this.system.localSyscall(
|
const posLookup = await this.system.localSyscall(
|
||||||
|
@ -209,7 +209,7 @@ export class Editor {
|
||||||
"index.get",
|
"index.get",
|
||||||
[
|
[
|
||||||
pageName,
|
pageName,
|
||||||
`a:${pageName}:@${pos}`,
|
`a:${pageName}:${pos}`,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,16 @@ release.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 0.1.4
|
||||||
|
|
||||||
|
- Breaking change (for those who used it): the named anchor syntax has changed
|
||||||
|
from `@anchorname` to `$anchorname`. This is to avoid conflicts with
|
||||||
|
potentialy future use of `@` for other purposes (like mentioning people).
|
||||||
|
Linking to an anchor still uses the `[[page@anchorname]]` syntax. So, you
|
||||||
|
create an anchor $likethis you can then reference it [[@likethis]].
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 0.1.3
|
## 0.1.3
|
||||||
|
|
||||||
- Silver Bullet now runs on Windows!
|
- Silver Bullet now runs on Windows!
|
||||||
|
|
Loading…
Reference in New Issue