@formicoidea/labre-core 0.46.0 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ import type { BlockModel, Store } from '../../store/index.js';
14
14
  */
15
15
  export declare function calloutConversionTargets(store: Store, models: BlockModel[]): BlockModel[];
16
16
  /**
17
- * Wraps each selected paragraph, list item or code block in a callout (#418).
17
+ * Turns each selected paragraph, list item or code block into a callout (#418).
18
18
  *
19
19
  * A callout is a hub with no text of its own, so this cannot be
20
20
  * `transformModel`: the callout takes the block's place, a paragraph inside it
@@ -37,7 +37,7 @@ export function calloutConversionTargets(store, models) {
37
37
  return convertible.filter(model => !convertible.some(other => isAncestor(store, other, model)));
38
38
  }
39
39
  /**
40
- * Wraps each selected paragraph, list item or code block in a callout (#418).
40
+ * Turns each selected paragraph, list item or code block into a callout (#418).
41
41
  *
42
42
  * A callout is a hub with no text of its own, so this cannot be
43
43
  * `transformModel`: the callout takes the block's place, a paragraph inside it
@@ -42,10 +42,12 @@ export const calloutSlashMenuConfig = {
42
42
  if (index === -1)
43
43
  return;
44
44
  const calloutId = store.addBlock('affine:callout', {}, parent, index + 1);
45
- if (!calloutId)
45
+ // `addBlock` returns an id even when the schema refused the block
46
+ // (`transact` swallows the throw, #418): only the model proves it.
47
+ if (!store.getModelById(calloutId))
46
48
  return;
47
49
  const paragraphId = store.addBlock('affine:paragraph', {}, calloutId);
48
- if (!paragraphId)
50
+ if (!store.getModelById(paragraphId))
49
51
  return;
50
52
  std.host.updateComplete
51
53
  .then(() => {
@@ -1,6 +1,35 @@
1
1
  import { type ViewExtensionContext, ViewExtensionProvider } from '../affine-ext-loader/index.js';
2
- export declare class CalloutViewExtension extends ViewExtensionProvider {
2
+ /**
3
+ * Callout rendering — ALWAYS registered, independent of the `callout` flag
4
+ * (ADR 0009, #418). A document that already holds callouts must paint them,
5
+ * let them be edited and let them be turned back into text whatever the flag
6
+ * says: until 2026-10-11 the whole view sat behind the flag, and
7
+ * `{ callout: false }` left every stored callout rendered as nothing.
8
+ *
9
+ * What lives here is what an EXISTING callout needs, the mirror of
10
+ * `WardleyRenderViewExtension`:
11
+ * - `effects()` whole: `affine-callout` paints the block, and
12
+ * `affine-emoji-menu` opens from a rendered callout's icon — both are
13
+ * render-side, so unlike the frameworks' this `effects()` is not tooling;
14
+ * - the flavour and the block view, the lookup `lit-host` performs;
15
+ * - the keymap: Enter and Backspace inside a callout edit stored content, they
16
+ * create nothing;
17
+ * - the block toolbar (#468): Turn into text, copy, duplicate, delete — the
18
+ * way OUT of a stored callout, as the Wardley contextual toolbar stays with
19
+ * a stored map.
20
+ */
21
+ export declare class CalloutRenderViewExtension extends ViewExtensionProvider {
3
22
  name: string;
4
23
  effect(): void;
5
24
  setup(context: ViewExtensionContext): void;
6
25
  }
26
+ /**
27
+ * Callout creation tooling — flag-gated (`callout`, ADR 0009): the slash-menu
28
+ * item and the "Turn into → Callout" entry, the two ways to CREATE a callout.
29
+ * With the flag off no new callout can be made; the ones already written keep
30
+ * rendering through {@link CalloutRenderViewExtension}.
31
+ */
32
+ export declare class CalloutViewExtension extends ViewExtensionProvider {
33
+ name: string;
34
+ setup(context: ViewExtensionContext): void;
35
+ }
@@ -9,10 +9,29 @@ import { calloutSlashMenuConfig } from './configs/slash-menu.js';
9
9
  import { calloutToolbarConfig } from './configs/toolbar.js';
10
10
  import { calloutTurnIntoEntry } from './configs/turn-into.js';
11
11
  import { effects } from './effects.js';
12
- export class CalloutViewExtension extends ViewExtensionProvider {
12
+ /**
13
+ * Callout rendering — ALWAYS registered, independent of the `callout` flag
14
+ * (ADR 0009, #418). A document that already holds callouts must paint them,
15
+ * let them be edited and let them be turned back into text whatever the flag
16
+ * says: until 2026-10-11 the whole view sat behind the flag, and
17
+ * `{ callout: false }` left every stored callout rendered as nothing.
18
+ *
19
+ * What lives here is what an EXISTING callout needs, the mirror of
20
+ * `WardleyRenderViewExtension`:
21
+ * - `effects()` whole: `affine-callout` paints the block, and
22
+ * `affine-emoji-menu` opens from a rendered callout's icon — both are
23
+ * render-side, so unlike the frameworks' this `effects()` is not tooling;
24
+ * - the flavour and the block view, the lookup `lit-host` performs;
25
+ * - the keymap: Enter and Backspace inside a callout edit stored content, they
26
+ * create nothing;
27
+ * - the block toolbar (#468): Turn into text, copy, duplicate, delete — the
28
+ * way OUT of a stored callout, as the Wardley contextual toolbar stays with
29
+ * a stored map.
30
+ */
31
+ export class CalloutRenderViewExtension extends ViewExtensionProvider {
13
32
  constructor() {
14
33
  super(...arguments);
15
- this.name = 'affine-callout-block';
34
+ this.name = 'affine-callout-render-block';
16
35
  }
17
36
  effect() {
18
37
  super.effect();
@@ -24,8 +43,6 @@ export class CalloutViewExtension extends ViewExtensionProvider {
24
43
  FlavourExtension('affine:callout'),
25
44
  BlockViewExtension('affine:callout', literal `affine-callout`),
26
45
  CalloutKeymapExtension,
27
- SlashMenuConfigExtension('affine:callout', calloutSlashMenuConfig),
28
- TextConversionEntryExtension(calloutTurnIntoEntry),
29
46
  ToolbarModuleExtension({
30
47
  id: BlockFlavourIdentifier('affine:callout'),
31
48
  config: calloutToolbarConfig,
@@ -33,3 +50,22 @@ export class CalloutViewExtension extends ViewExtensionProvider {
33
50
  ]);
34
51
  }
35
52
  }
53
+ /**
54
+ * Callout creation tooling — flag-gated (`callout`, ADR 0009): the slash-menu
55
+ * item and the "Turn into → Callout" entry, the two ways to CREATE a callout.
56
+ * With the flag off no new callout can be made; the ones already written keep
57
+ * rendering through {@link CalloutRenderViewExtension}.
58
+ */
59
+ export class CalloutViewExtension extends ViewExtensionProvider {
60
+ constructor() {
61
+ super(...arguments);
62
+ this.name = 'affine-callout-block';
63
+ }
64
+ setup(context) {
65
+ super.setup(context);
66
+ context.register([
67
+ SlashMenuConfigExtension('affine:callout', calloutSlashMenuConfig),
68
+ TextConversionEntryExtension(calloutTurnIntoEntry),
69
+ ]);
70
+ }
71
+ }
@@ -118,7 +118,7 @@ let LanguageListButton = (() => {
118
118
  const plainText = {
119
119
  label: translateKey(this.blockComponent.std, ...CODE_PLAIN_TEXT_LANGUAGE),
120
120
  name: PLAIN_TEXT_ITEM_NAME,
121
- aliases: ['plain', 'text', 'none'],
121
+ aliases: ['plain', 'text', 'plaintext', 'txt', 'none'],
122
122
  };
123
123
  const index = languages.findIndex(item => item.name === PLAIN_TEXT_ITEM_NAME);
124
124
  if (index === -1) {
@@ -1,6 +1,6 @@
1
1
  import { AttachmentViewExtension } from '../_pkgs/affine-block-attachment/view.js';
2
2
  import { BookmarkViewExtension } from '../_pkgs/affine-block-bookmark/view.js';
3
- import { CalloutViewExtension } from '../_pkgs/affine-block-callout/view.js';
3
+ import { CalloutRenderViewExtension, CalloutViewExtension, } from '../_pkgs/affine-block-callout/view.js';
4
4
  import { CodeBlockViewExtension } from '../_pkgs/affine-block-code/view.js';
5
5
  import { DataViewViewExtension } from '../_pkgs/affine-block-data-view/view.js';
6
6
  import { DatabaseViewExtension } from '../_pkgs/affine-block-database/view.js';
@@ -108,6 +108,10 @@ export function getInternalViewExtensions(flags) {
108
108
  // Block
109
109
  ...(on('attachment') ? [AttachmentViewExtension] : []),
110
110
  ...(on('bookmark') ? [BookmarkViewExtension] : []),
111
+ // Split like the frameworks (ADR 0009, #418): a stored callout paints,
112
+ // edits and keeps its block toolbar; the flag removes only the creation
113
+ // entries (slash item, Turn into). The other blocks are not split yet.
114
+ CalloutRenderViewExtension,
111
115
  ...(on('callout') ? [CalloutViewExtension] : []),
112
116
  ...(on('code') ? [CodeBlockViewExtension] : []),
113
117
  ...(on('data-view') ? [DataViewViewExtension] : []),
package/dist/flags.d.ts CHANGED
@@ -47,6 +47,9 @@
47
47
  * re-renders untouched once the flag is back on — but a disabled block
48
48
  * currently renders as nothing until its view extension is split the way the
49
49
  * frameworks' were. See the "Consequences" section of `docs/adr/0009`.
50
+ * `callout` is the one block split so far (2026-10-11 amendment of that
51
+ * ADR): with `{ callout: false }` a stored callout still renders, stays
52
+ * editable and keeps its block toolbar; only its creation entries go.
50
53
  * - `latex` covers both the latex block and inline latex.
51
54
  * - `frame` also covers the frame panel fragment.
52
55
  * - `ddd-templates` covers all four DDD Templates-panel categories, so the
package/dist/flags.js CHANGED
@@ -47,6 +47,9 @@
47
47
  * re-renders untouched once the flag is back on — but a disabled block
48
48
  * currently renders as nothing until its view extension is split the way the
49
49
  * frameworks' were. See the "Consequences" section of `docs/adr/0009`.
50
+ * `callout` is the one block split so far (2026-10-11 amendment of that
51
+ * ADR): with `{ callout: false }` a stored callout still renders, stays
52
+ * editable and keeps its block toolbar; only its creation entries go.
50
53
  * - `latex` covers both the latex block and inline latex.
51
54
  * - `frame` also covers the frame panel fragment.
52
55
  * - `ddd-templates` covers all four DDD Templates-panel categories, so the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-core",
3
3
  "description": "Labre editor — the full BlockSuite-derived editor as one package.",
4
- "version": "0.46.0",
4
+ "version": "0.46.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",