diff --git a/packages/base/codemirror-editor.gts b/packages/base/codemirror-editor.gts index b368da55a47..d38ab55c8c0 100644 --- a/packages/base/codemirror-editor.gts +++ b/packages/base/codemirror-editor.gts @@ -5,6 +5,7 @@ import { modifier } from 'ember-modifier'; import { fn } from '@ember/helper'; import { on } from '@ember/modifier'; import { scheduleOnce } from '@ember/runloop'; +import { htmlSafe } from '@ember/template'; import { Tooltip } from '@cardstack/boxel-ui/components'; import { eq, not } from '@cardstack/boxel-ui/helpers'; @@ -16,7 +17,10 @@ import { CardContextName, trimJsonExtension, } from '@cardstack/runtime-common'; -import { type BfmRefRange } from '@cardstack/runtime-common/bfm-card-references'; +import { + type BfmRefFormat, + type BfmRefRange, +} from '@cardstack/runtime-common/bfm-card-references'; import { consume } from 'ember-provide-consume-context'; import { type BaseDef, @@ -47,10 +51,13 @@ import PencilIcon from '@cardstack/boxel-icons/pencil'; interface CardWidgetTarget { element: HTMLElement; cardId: string; - format: 'atom' | 'embedded'; + format: BfmRefFormat; kind: 'inline' | 'block'; // 'card' refs resolve to CardDef instances; 'file' refs to FileDef instances. refType: 'card' | 'file'; + // Inline sizing derived from the directive's size specifier (width/height plus + // `overflow: hidden` for fitted). Undefined for non-fitted formats. + style?: string; } interface CardRenderTarget extends CardWidgetTarget { @@ -995,7 +1002,11 @@ export default class CodeMirrorEditor extends GlimmerComponent { this.args.selection.setKind(kind); } + // A Custom-size fitted embed with no dimensions would insert a size-less + // bare `fitted`, so the CTA is held disabled until a valid size is entered. + private get ctaDisabled(): boolean { + return !this.args.selection.hasValidSize; + } + @action private insert() { + if (this.ctaDisabled) return; let bfm = this.bfmString; if (!bfm) return; this.args.onInsert(bfm); @@ -207,6 +214,7 @@ export default class MarkdownEmbedPreviewPane extends Component {