Skip to content

Commit c9c33c7

Browse files
authored
Handle both forms of charmId access (#1841)
* Handle both forms of `charmId` access This is a strange bug, it might imply mixing up the result and source cell somewhere? Or [ID] missing in some objects? * Tweak styling to handle `ct-render` in `ct-autolayout`
1 parent 5fbb434 commit c9c33c7

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

packages/ui/src/v2/components/ct-autolayout/ct-autolayout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export class CTAutoLayout extends BaseElement {
199199
var(--ct-border-radius-md, 0.375rem)
200200
);
201201
padding: var(--ct-theme-spacing-loose, 1rem);
202+
box-sizing: border-box;
202203
}
203204
204205
.tabs {

packages/ui/src/v2/components/ct-code-editor/ct-code-editor.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ export class CTCodeEditor extends BaseElement {
254254
type: "text",
255255
info: "Create new backlink",
256256
apply: () => {
257-
this.emit("backlink-create", { text: raw });
257+
// Instantiate the pattern if available
258+
if (this.pattern) {
259+
this.createBacklinkFromPattern(raw);
260+
} else {
261+
this.emit("backlink-create", { text: raw });
262+
}
258263
},
259264
});
260265
}
@@ -436,9 +441,11 @@ export class CTCodeEditor extends BaseElement {
436441
if (charm) {
437442
// this is VERY specific
438443
// if you do `getEntityId(mentionableArray.key(i))` you'll get a different answer (the ID of the array itself)
439-
const charmIdObj = getEntityId(mentionableArray.get()[i]);
440-
const charmId = charmIdObj?.["/"] || "";
441-
if (charmId === id) {
444+
const charmIdObjA = getEntityId(mentionableArray.get()[i]);
445+
const charmIdObjB = getEntityId(mentionableArray.key(i));
446+
const charmIdA = charmIdObjA?.["/"] || "";
447+
const charmIdB = charmIdObjB?.["/"] || "";
448+
if (charmIdA === id || charmIdB === id) {
442449
return charm;
443450
}
444451
}
@@ -797,14 +804,19 @@ export class CTCodeEditor extends BaseElement {
797804
// Try accepting an active completion first
798805
if (acceptCompletion(view)) return true;
799806

800-
// If typing a backlink with no matches, emit create event
807+
// If typing a backlink with no matches, create new backlink
801808
const query = this._currentBacklinkQuery(view);
802809
if (query != null) {
803810
const matches = this.getFilteredMentionable(query);
804811
if (matches.length === 0) {
805812
const text = query.trim();
806813
if (text.length > 0) {
807-
this.emit("backlink-create", { text });
814+
// Instantiate the pattern if available
815+
if (this.pattern) {
816+
this.createBacklinkFromPattern(text);
817+
} else {
818+
this.emit("backlink-create", { text });
819+
}
808820
return true;
809821
}
810822
}

0 commit comments

Comments
 (0)