Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class CTAutoLayout extends BaseElement {
var(--ct-border-radius-md, 0.375rem)
);
padding: var(--ct-theme-spacing-loose, 1rem);
box-sizing: border-box;
}

.tabs {
Expand Down
24 changes: 18 additions & 6 deletions packages/ui/src/v2/components/ct-code-editor/ct-code-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ export class CTCodeEditor extends BaseElement {
type: "text",
info: "Create new backlink",
apply: () => {
this.emit("backlink-create", { text: raw });
// Instantiate the pattern if available
if (this.pattern) {
this.createBacklinkFromPattern(raw);
} else {
this.emit("backlink-create", { text: raw });
}
},
});
}
Expand Down Expand Up @@ -436,9 +441,11 @@ export class CTCodeEditor extends BaseElement {
if (charm) {
// this is VERY specific
// if you do `getEntityId(mentionableArray.key(i))` you'll get a different answer (the ID of the array itself)
const charmIdObj = getEntityId(mentionableArray.get()[i]);
const charmId = charmIdObj?.["/"] || "";
if (charmId === id) {
const charmIdObjA = getEntityId(mentionableArray.get()[i]);
const charmIdObjB = getEntityId(mentionableArray.key(i));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to double check, but I think that getEntityId ignores to path part, so all of these IDs will be the same irrespective of i.

const charmIdA = charmIdObjA?.["/"] || "";
const charmIdB = charmIdObjB?.["/"] || "";
if (charmIdA === id || charmIdB === id) {
return charm;
}
}
Expand Down Expand Up @@ -797,14 +804,19 @@ export class CTCodeEditor extends BaseElement {
// Try accepting an active completion first
if (acceptCompletion(view)) return true;

// If typing a backlink with no matches, emit create event
// If typing a backlink with no matches, create new backlink
const query = this._currentBacklinkQuery(view);
if (query != null) {
const matches = this.getFilteredMentionable(query);
if (matches.length === 0) {
const text = query.trim();
if (text.length > 0) {
this.emit("backlink-create", { text });
// Instantiate the pattern if available
if (this.pattern) {
this.createBacklinkFromPattern(text);
} else {
this.emit("backlink-create", { text });
}
return true;
}
}
Expand Down