@formicoidea/labre-core 0.57.0 → 0.59.0
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.
- package/architecture/code.c4 +94 -65
- package/architecture/domain.c4 +2510 -0
- package/architecture/likec4.config.json +3 -3
- package/dist/_pkgs/affine-block-attachment/edgeless-clipboard-config.d.ts +3 -2
- package/dist/_pkgs/affine-block-attachment/edgeless-clipboard-config.js +18 -13
- package/dist/_pkgs/affine-block-callout/adapters/markdown.js +4 -1
- package/dist/_pkgs/affine-block-code/adapters/html.js +1 -1
- package/dist/_pkgs/affine-block-code/adapters/markdown/preprocessor.js +13 -1
- package/dist/_pkgs/affine-block-code/adapters/notion-html.js +1 -1
- package/dist/_pkgs/affine-block-code/code-block.d.ts +17 -2
- package/dist/_pkgs/affine-block-code/code-block.js +28 -23
- package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +17 -4
- package/dist/_pkgs/affine-block-code/code-toolbar/components/preview-button.js +1 -1
- package/dist/_pkgs/affine-block-data-view/data-source.js +12 -5
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-clipboard-config.d.ts +3 -2
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-clipboard-config.js +8 -5
- package/dist/_pkgs/affine-block-image/asset-picker.d.ts +23 -2
- package/dist/_pkgs/affine-block-image/asset-picker.js +52 -12
- package/dist/_pkgs/affine-block-image/configs/replace-action.d.ts +8 -5
- package/dist/_pkgs/affine-block-image/configs/replace-action.js +8 -8
- package/dist/_pkgs/affine-block-image/configs/toolbar.js +2 -1
- package/dist/_pkgs/affine-block-image/crop/crop-controller.d.ts +15 -0
- package/dist/_pkgs/affine-block-image/crop/crop-controller.js +40 -2
- package/dist/_pkgs/affine-block-image/crop/crop-math.d.ts +22 -0
- package/dist/_pkgs/affine-block-image/crop/crop-math.js +55 -2
- package/dist/_pkgs/affine-block-image/crop/crop-overlay.d.ts +17 -3
- package/dist/_pkgs/affine-block-image/crop/crop-overlay.js +64 -6
- package/dist/_pkgs/affine-block-image/edgeless-clipboard-config.d.ts +3 -2
- package/dist/_pkgs/affine-block-image/edgeless-clipboard-config.js +20 -14
- package/dist/_pkgs/affine-block-image/image-block.js +1 -0
- package/dist/_pkgs/affine-block-image/image-edgeless-block.js +3 -0
- package/dist/_pkgs/affine-block-image/index.d.ts +2 -0
- package/dist/_pkgs/affine-block-image/index.js +2 -0
- package/dist/_pkgs/affine-block-image/replace/commands.d.ts +68 -0
- package/dist/_pkgs/affine-block-image/replace/commands.js +200 -0
- package/dist/_pkgs/affine-block-image/replace/replace-model.d.ts +44 -0
- package/dist/_pkgs/affine-block-image/replace/replace-model.js +168 -0
- package/dist/_pkgs/affine-block-image/replace/toolbar.d.ts +21 -0
- package/dist/_pkgs/affine-block-image/replace/toolbar.js +159 -0
- package/dist/_pkgs/affine-block-image/translations.d.ts +15 -2
- package/dist/_pkgs/affine-block-image/translations.js +35 -2
- package/dist/_pkgs/affine-block-image/utils.d.ts +7 -0
- package/dist/_pkgs/affine-block-image/utils.js +13 -0
- package/dist/_pkgs/affine-block-image/view.js +7 -0
- package/dist/_pkgs/affine-block-note/components/edgeless-page-block-title.d.ts +14 -5
- package/dist/_pkgs/affine-block-note/components/edgeless-page-block-title.js +18 -11
- package/dist/_pkgs/affine-block-note/config.d.ts +9 -2
- package/dist/_pkgs/affine-block-note/edgeless-clipboard-config.d.ts +3 -2
- package/dist/_pkgs/affine-block-note/edgeless-clipboard-config.js +8 -5
- package/dist/_pkgs/affine-block-paragraph/adapters/markdown.js +11 -0
- package/dist/_pkgs/affine-block-root/commands/invisible-characters-commands.d.ts +17 -0
- package/dist/_pkgs/affine-block-root/commands/invisible-characters-commands.js +123 -0
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +82 -65
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.js +2 -0
- package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-root/index.js +1 -0
- package/dist/_pkgs/affine-block-root/translations.d.ts +6 -0
- package/dist/_pkgs/affine-block-root/translations.js +10 -0
- package/dist/_pkgs/affine-block-root/view.js +6 -1
- package/dist/_pkgs/affine-block-surface/commands/index.d.ts +1 -1
- package/dist/_pkgs/affine-block-surface/commands/index.js +1 -1
- package/dist/_pkgs/affine-block-surface/commands/reassociate-connectors.d.ts +9 -0
- package/dist/_pkgs/affine-block-surface/commands/reassociate-connectors.js +21 -12
- package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.d.ts +33 -0
- package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +53 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.js +12 -12
- package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +2 -1
- package/dist/_pkgs/affine-block-surface/framework-background/band-widths.d.ts +104 -0
- package/dist/_pkgs/affine-block-surface/framework-background/band-widths.js +156 -0
- package/dist/_pkgs/affine-block-surface/framework-background/def.d.ts +87 -4
- package/dist/_pkgs/affine-block-surface/framework-background/def.js +26 -7
- package/dist/_pkgs/affine-block-surface/framework-background/ellipsis.d.ts +58 -0
- package/dist/_pkgs/affine-block-surface/framework-background/ellipsis.js +110 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +3 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.js +3 -0
- package/dist/_pkgs/affine-block-surface/framework-background/labels.d.ts +12 -2
- package/dist/_pkgs/affine-block-surface/framework-background/labels.js +29 -5
- package/dist/_pkgs/affine-block-surface/framework-background/measure-text.d.ts +14 -0
- package/dist/_pkgs/affine-block-surface/framework-background/measure-text.js +31 -0
- package/dist/_pkgs/affine-block-surface/framework-background/renderer.d.ts +14 -1
- package/dist/_pkgs/affine-block-surface/framework-background/renderer.js +84 -31
- package/dist/_pkgs/affine-block-table/adapters/html.js +26 -14
- package/dist/_pkgs/affine-block-table/adapters/utils.d.ts +1 -0
- package/dist/_pkgs/affine-block-table/adapters/utils.js +23 -5
- package/dist/_pkgs/affine-block-table/header-menu.d.ts +13 -0
- package/dist/_pkgs/affine-block-table/header-menu.js +25 -0
- package/dist/_pkgs/affine-block-table/selection-controller.d.ts +15 -0
- package/dist/_pkgs/affine-block-table/selection-controller.js +62 -0
- package/dist/_pkgs/affine-block-table/table-cell-css.d.ts +7 -0
- package/dist/_pkgs/affine-block-table/table-cell-css.js +10 -0
- package/dist/_pkgs/affine-block-table/table-cell.d.ts +8 -0
- package/dist/_pkgs/affine-block-table/table-cell.js +35 -3
- package/dist/_pkgs/affine-block-table/table-data-manager.d.ts +14 -0
- package/dist/_pkgs/affine-block-table/table-data-manager.js +44 -3
- package/dist/_pkgs/affine-block-table/translations.d.ts +14 -0
- package/dist/_pkgs/affine-block-table/translations.js +22 -0
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/highlight-duotone-icon.js +8 -8
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/text-duotone-icon.js +11 -11
- package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.d.ts +3 -1
- package/dist/_pkgs/affine-fragment-doc-title/title-band/title-band.js +15 -2
- package/dist/_pkgs/affine-gfx-mindmap/toolbar/mindmap-tool-button.d.ts +2 -2
- package/dist/_pkgs/affine-gfx-template/builtin/other.d.ts +4 -0
- package/dist/_pkgs/affine-gfx-template/builtin/other.js +1 -1
- package/dist/_pkgs/affine-gfx-template/builtin/slides/build.d.ts +81 -0
- package/dist/_pkgs/affine-gfx-template/builtin/slides/build.js +276 -0
- package/dist/_pkgs/affine-gfx-template/builtin/slides/consts.d.ts +126 -0
- package/dist/_pkgs/affine-gfx-template/builtin/slides/consts.js +101 -0
- package/dist/_pkgs/affine-gfx-template/builtin/slides/index.d.ts +8 -0
- package/dist/_pkgs/affine-gfx-template/builtin/slides/index.js +27 -0
- package/dist/_pkgs/affine-gfx-template/builtin/slides/masks.d.ts +83 -0
- package/dist/_pkgs/affine-gfx-template/builtin/slides/masks.js +674 -0
- package/dist/_pkgs/affine-gfx-template/contribute.js +12 -17
- package/dist/_pkgs/affine-gfx-template/make-snapshot.d.ts +14 -2
- package/dist/_pkgs/affine-gfx-template/make-snapshot.js +6 -2
- package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +12 -0
- package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +48 -0
- package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
- package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.d.ts +15 -1
- package/dist/_pkgs/affine-gfx-template/toolbar/builtin-templates.js +33 -37
- package/dist/_pkgs/affine-gfx-template/toolbar/template-type.d.ts +6 -0
- package/dist/_pkgs/affine-gfx-template/translations.d.ts +94 -0
- package/dist/_pkgs/affine-gfx-template/translations.js +441 -2
- package/dist/_pkgs/affine-model/blocks/table/table-model.d.ts +4 -0
- package/dist/_pkgs/affine-model/blocks/table/table-model.js +4 -0
- package/dist/_pkgs/affine-model/elements/bpmn/node.d.ts +46 -3
- package/dist/_pkgs/affine-model/elements/bpmn/node.js +47 -4
- package/dist/_pkgs/affine-model/elements/bpmn/pool.d.ts +20 -0
- package/dist/_pkgs/affine-model/elements/bpmn/pool.js +33 -4
- package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +3 -16
- package/dist/_pkgs/affine-shared/services/edit-props-store.js +16 -16
- package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
- package/dist/_pkgs/affine-shared/services/editor-setting-service.js +4 -0
- package/dist/_pkgs/affine-shared/services/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/services/index.js +1 -0
- package/dist/_pkgs/affine-shared/services/invisible-characters.d.ts +33 -0
- package/dist/_pkgs/affine-shared/services/invisible-characters.js +63 -0
- package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-cache.d.ts +0 -9
- package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-cache.js +3 -9
- package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +26 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +4 -3
- package/dist/_pkgs/affine-shared/services/telemetry-service/types.d.ts +11 -0
- package/dist/_pkgs/affine-shared/utils/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/utils/index.js +1 -0
- package/dist/_pkgs/affine-shared/utils/invisible-characters.d.ts +42 -0
- package/dist/_pkgs/affine-shared/utils/invisible-characters.js +81 -0
- package/dist/_pkgs/affine-widget-edgeless-zoom-toolbar/index.js +26 -26
- package/dist/_pkgs/affine-widget-edgeless-zoom-toolbar/zoom-toolbar.js +13 -2
- package/dist/_pkgs/affine-widget-keyboard-toolbar/icons.js +98 -98
- package/dist/_pkgs/affine-widget-page-dragging-area/index.js +10 -10
- package/dist/_pkgs/affine-widget-viewport-overlay/index.js +13 -13
- package/dist/_pkgs/data-view/core/utils/menu-title.js +17 -17
- package/dist/_pkgs/data-view/view-presets/table/pc/header/column-header.js +6 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/table-view-ui-logic.js +5 -2
- package/dist/_pkgs/std/clipboard/clipboard.d.ts +15 -1
- package/dist/_pkgs/std/clipboard/clipboard.js +18 -0
- package/dist/_pkgs/std/inline/components/embed-gap.js +1 -1
- package/dist/_pkgs/std/inline/components/v-line.js +1 -1
- package/dist/_pkgs/std/inline/components/v-text.d.ts +15 -2
- package/dist/_pkgs/std/inline/components/v-text.js +147 -15
- package/dist/_pkgs/std/inline/consts.d.ts +5 -0
- package/dist/_pkgs/std/inline/consts.js +5 -0
- package/dist/_pkgs/std/inline/utils/index.d.ts +1 -0
- package/dist/_pkgs/std/inline/utils/index.js +1 -0
- package/dist/_pkgs/std/inline/utils/invisible-characters.d.ts +57 -0
- package/dist/_pkgs/std/inline/utils/invisible-characters.js +162 -0
- package/dist/_pkgs/std/inline/utils/point-conversion.js +3 -3
- package/dist/_pkgs/std/inline/utils/text.d.ts +8 -0
- package/dist/_pkgs/std/inline/utils/text.js +11 -2
- package/dist/_pkgs/store/model/store/crud.d.ts +28 -0
- package/dist/_pkgs/store/model/store/crud.js +97 -30
- package/dist/_pkgs/store/model/store/query.js +3 -2
- package/dist/_pkgs/store/model/store/store.d.ts +21 -0
- package/dist/_pkgs/store/model/store/store.js +88 -21
- package/dist/_pkgs/store/transformer/transformer.d.ts +46 -0
- package/dist/_pkgs/store/transformer/transformer.js +72 -0
- package/dist/commands.js +6 -1
- package/dist/translations.js +2 -0
- package/package.json +3 -4
|
@@ -33,7 +33,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
33
33
|
return useValue ? value : void 0;
|
|
34
34
|
};
|
|
35
35
|
import { rotatePoint } from '../../../global/gfx/index.js';
|
|
36
|
-
import { field } from '../../../std/gfx/index.js';
|
|
36
|
+
import { field, local } from '../../../std/gfx/index.js';
|
|
37
37
|
import { FrameworkBackgroundElementModel } from '../framework-background/index.js';
|
|
38
38
|
import { POOL_BAND_WIDTH, POOL_LANE_BAND_WIDTH } from './consts.js';
|
|
39
39
|
/**
|
|
@@ -68,6 +68,9 @@ let BpmnPoolElementModel = (() => {
|
|
|
68
68
|
let _lanes_decorators;
|
|
69
69
|
let _lanes_initializers = [];
|
|
70
70
|
let _lanes_extraInitializers = [];
|
|
71
|
+
let _paintedBands_decorators;
|
|
72
|
+
let _paintedBands_initializers = [];
|
|
73
|
+
let _paintedBands_extraInitializers = [];
|
|
71
74
|
return class BpmnPoolElementModel extends _classSuper {
|
|
72
75
|
static {
|
|
73
76
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
@@ -76,11 +79,13 @@ let BpmnPoolElementModel = (() => {
|
|
|
76
79
|
_rotate_decorators = [field(0)];
|
|
77
80
|
_xywh_decorators = [field('[0,0,0,0]')];
|
|
78
81
|
_lanes_decorators = [field()];
|
|
82
|
+
_paintedBands_decorators = [local()];
|
|
79
83
|
__esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
|
|
80
84
|
__esDecorate(this, null, _resizeEnabled_decorators, { kind: "accessor", name: "resizeEnabled", static: false, private: false, access: { has: obj => "resizeEnabled" in obj, get: obj => obj.resizeEnabled, set: (obj, value) => { obj.resizeEnabled = value; } }, metadata: _metadata }, _resizeEnabled_initializers, _resizeEnabled_extraInitializers);
|
|
81
85
|
__esDecorate(this, null, _rotate_decorators, { kind: "accessor", name: "rotate", static: false, private: false, access: { has: obj => "rotate" in obj, get: obj => obj.rotate, set: (obj, value) => { obj.rotate = value; } }, metadata: _metadata }, _rotate_initializers, _rotate_extraInitializers);
|
|
82
86
|
__esDecorate(this, null, _xywh_decorators, { kind: "accessor", name: "xywh", static: false, private: false, access: { has: obj => "xywh" in obj, get: obj => obj.xywh, set: (obj, value) => { obj.xywh = value; } }, metadata: _metadata }, _xywh_initializers, _xywh_extraInitializers);
|
|
83
87
|
__esDecorate(this, null, _lanes_decorators, { kind: "accessor", name: "lanes", static: false, private: false, access: { has: obj => "lanes" in obj, get: obj => obj.lanes, set: (obj, value) => { obj.lanes = value; } }, metadata: _metadata }, _lanes_initializers, _lanes_extraInitializers);
|
|
88
|
+
__esDecorate(this, null, _paintedBands_decorators, { kind: "accessor", name: "paintedBands", static: false, private: false, access: { has: obj => "paintedBands" in obj, get: obj => obj.paintedBands, set: (obj, value) => { obj.paintedBands = value; } }, metadata: _metadata }, _paintedBands_initializers, _paintedBands_extraInitializers);
|
|
84
89
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
85
90
|
}
|
|
86
91
|
get type() {
|
|
@@ -133,6 +138,25 @@ let BpmnPoolElementModel = (() => {
|
|
|
133
138
|
*/
|
|
134
139
|
get lanes() { return this.#lanes_accessor_storage; }
|
|
135
140
|
set lanes(value) { this.#lanes_accessor_storage = value; }
|
|
141
|
+
#paintedBands_accessor_storage = (__runInitializers(this, _lanes_extraInitializers), __runInitializers(this, _paintedBands_initializers, undefined));
|
|
142
|
+
/**
|
|
143
|
+
* The title band widths the renderer last PAINTED this pool with: the
|
|
144
|
+
* participant band (`margin`) and the shared lane strip (`zoneBandWidth`).
|
|
145
|
+
*
|
|
146
|
+
* The bands grow with their names (`fit: 'wrap'`, PO 2026-10-27), which is a
|
|
147
|
+
* function of measured text, and this package cannot measure text. So the
|
|
148
|
+
* BPMN renderer, which does, caches what it painted here after each paint,
|
|
149
|
+
* and {@link includesPoint} selects by it: a click on a band widened by a
|
|
150
|
+
* two-line name picks the pool, as the painted band promises.
|
|
151
|
+
*
|
|
152
|
+
* A derived, view-time fact cached on the model, NEVER stored — the reasoning
|
|
153
|
+
* ADR 0031 applies to the local hide: `@local()` lives in `_local` and is not
|
|
154
|
+
* written to the Y.Map, so no document carries it, no peer receives it and no
|
|
155
|
+
* snapshot serialises it. Undefined until the first paint; a pool never
|
|
156
|
+
* painted (headless) selects by the declared widths.
|
|
157
|
+
*/
|
|
158
|
+
get paintedBands() { return this.#paintedBands_accessor_storage; }
|
|
159
|
+
set paintedBands(value) { this.#paintedBands_accessor_storage = value; }
|
|
136
160
|
/**
|
|
137
161
|
* A pool is picked by its BORDER — and by its TITLE BANDS, which is the one
|
|
138
162
|
* carve-out the recette kept (issue #194).
|
|
@@ -174,11 +198,16 @@ let BpmnPoolElementModel = (() => {
|
|
|
174
198
|
}
|
|
175
199
|
if (ly < 0 || ly > h || lx < 0)
|
|
176
200
|
return false;
|
|
201
|
+
// As wide as last painted (`paintedBands`), the declared widths until then.
|
|
177
202
|
// Clamped to a pool narrower than its own margin — the degenerate case the
|
|
178
203
|
// renderer clamps too.
|
|
179
|
-
const
|
|
204
|
+
const painted = this.paintedBands ?? {
|
|
205
|
+
margin: POOL_BAND_WIDTH,
|
|
206
|
+
zoneBandWidth: POOL_LANE_BAND_WIDTH,
|
|
207
|
+
};
|
|
208
|
+
const band = Math.min(painted.margin, w);
|
|
180
209
|
const lanes = this.hasUsableLane
|
|
181
|
-
? Math.min(
|
|
210
|
+
? Math.min(painted.zoneBandWidth, w - band)
|
|
182
211
|
: 0;
|
|
183
212
|
return lx <= band + Math.max(lanes, 0);
|
|
184
213
|
}
|
|
@@ -202,7 +231,7 @@ let BpmnPoolElementModel = (() => {
|
|
|
202
231
|
}
|
|
203
232
|
constructor() {
|
|
204
233
|
super(...arguments);
|
|
205
|
-
__runInitializers(this,
|
|
234
|
+
__runInitializers(this, _paintedBands_extraInitializers);
|
|
206
235
|
}
|
|
207
236
|
};
|
|
208
237
|
})();
|
|
@@ -47,26 +47,12 @@ declare const LocalPropsSchema: z.ZodObject<{
|
|
|
47
47
|
presentNoFrameToastShown: z.ZodBoolean;
|
|
48
48
|
autoHideEmbedHTMLFullScreenToolbar: z.ZodBoolean;
|
|
49
49
|
connectorCenterAnchor: z.ZodDefault<z.ZodBoolean>;
|
|
50
|
-
/**
|
|
51
|
-
* The ids this viewer hid on this document's canvas (ADR 0031 §8). Per
|
|
52
|
-
* viewer and per document, like the viewport; never written to the
|
|
53
|
-
* document. Owned by `CanvasLocalVisibility`.
|
|
54
|
-
*/
|
|
55
50
|
localHiddenElements: z.ZodArray<z.ZodString, "many">;
|
|
56
|
-
/**
|
|
57
|
-
* The user layers this viewer hid on this document's canvas (ADR 0031 §8,
|
|
58
|
-
* stage 7). Same owner, same key scheme, same lifetime as
|
|
59
|
-
* `localHiddenElements`; a separate key so the element list keeps the shape
|
|
60
|
-
* it already has in viewers' storage.
|
|
61
|
-
*/
|
|
62
51
|
localHiddenLayers: z.ZodArray<z.ZodString, "many">;
|
|
63
|
-
/**
|
|
64
|
-
* This viewer's grid override on this document's canvas (ADR 0031 §11),
|
|
65
|
-
* keyed like the viewport. Absent = the document, the host or the library
|
|
66
|
-
* decides. Owned by `CanvasGrid`.
|
|
67
|
-
*/
|
|
68
52
|
localShowGrid: z.ZodBoolean;
|
|
53
|
+
showInvisibles: z.ZodBoolean;
|
|
69
54
|
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
showInvisibles: boolean;
|
|
70
56
|
viewport: {
|
|
71
57
|
zoom: number;
|
|
72
58
|
centerX: number;
|
|
@@ -85,6 +71,7 @@ declare const LocalPropsSchema: z.ZodObject<{
|
|
|
85
71
|
localHiddenLayers: string[];
|
|
86
72
|
localShowGrid: boolean;
|
|
87
73
|
}, {
|
|
74
|
+
showInvisibles: boolean;
|
|
88
75
|
viewport: {
|
|
89
76
|
zoom: number;
|
|
90
77
|
centerX: number;
|
|
@@ -37,25 +37,23 @@ const LocalPropsSchema = z.object({
|
|
|
37
37
|
presentNoFrameToastShown: z.boolean(),
|
|
38
38
|
autoHideEmbedHTMLFullScreenToolbar: z.boolean(),
|
|
39
39
|
connectorCenterAnchor: z.boolean().default(false),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* document. Owned by `CanvasLocalVisibility`.
|
|
44
|
-
*/
|
|
40
|
+
// The ids this viewer hid on this document's canvas (ADR 0031 §8). Per
|
|
41
|
+
// viewer and per document, like the viewport; never written to the
|
|
42
|
+
// document. Owned by `CanvasLocalVisibility`.
|
|
45
43
|
localHiddenElements: z.array(z.string()),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* it already has in viewers' storage.
|
|
51
|
-
*/
|
|
44
|
+
// The user layers this viewer hid on this document's canvas (ADR 0031 §8,
|
|
45
|
+
// stage 7). Same owner, same key scheme, same lifetime as
|
|
46
|
+
// `localHiddenElements`; a separate key so the element list keeps the shape
|
|
47
|
+
// it already has in viewers' storage.
|
|
52
48
|
localHiddenLayers: z.array(z.string()),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* decides. Owned by `CanvasGrid`.
|
|
57
|
-
*/
|
|
49
|
+
// This viewer's grid override on this document's canvas (ADR 0031 §11),
|
|
50
|
+
// keyed like the viewport. Absent = the document, the host or the library
|
|
51
|
+
// decides. Owned by `CanvasGrid`.
|
|
58
52
|
localShowGrid: z.boolean(),
|
|
53
|
+
// This viewer's "show special characters" choice, for every document:
|
|
54
|
+
// a writer's habit, like a word processor's ¶ button. Absent = the host's
|
|
55
|
+
// default, else off. Owned by `InvisibleCharacters`.
|
|
56
|
+
showInvisibles: z.boolean(),
|
|
59
57
|
});
|
|
60
58
|
function isLocalProp(key) {
|
|
61
59
|
return key in LocalPropsSchema.shape;
|
|
@@ -137,6 +135,8 @@ export class EditPropsStore extends LifeCycleWatcher {
|
|
|
137
135
|
return 'blocksuite:' + id + ':localHiddenLayers';
|
|
138
136
|
case 'localShowGrid':
|
|
139
137
|
return 'blocksuite:' + id + ':localShowGrid';
|
|
138
|
+
case 'showInvisibles':
|
|
139
|
+
return 'blocksuite:showInvisibles';
|
|
140
140
|
default:
|
|
141
141
|
return key;
|
|
142
142
|
}
|
|
@@ -6,6 +6,7 @@ export declare const GeneralSettingSchema: z.ZodObject<{
|
|
|
6
6
|
edgelessScrollZoom: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
edgelessDisableScheduleUpdate: z.ZodDefault<z.ZodBoolean>;
|
|
8
8
|
edgelessShowGrid: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
showInvisibles: z.ZodOptional<z.ZodBoolean>;
|
|
9
10
|
docCanvasPreferView: z.ZodDefault<z.ZodEnum<["affine:embed-linked-doc", "affine:embed-synced-doc"]>>;
|
|
10
11
|
} & {
|
|
11
12
|
connector: z.ZodDefault<z.ZodObject<{
|
|
@@ -1481,6 +1482,7 @@ export declare const GeneralSettingSchema: z.ZodObject<{
|
|
|
1481
1482
|
textVerticalAlign?: import("../../affine-model/index.js").TextVerticalAlign | undefined;
|
|
1482
1483
|
};
|
|
1483
1484
|
edgelessShowGrid?: boolean | undefined;
|
|
1485
|
+
showInvisibles?: boolean | undefined;
|
|
1484
1486
|
}, {
|
|
1485
1487
|
text?: {
|
|
1486
1488
|
color: string | {
|
|
@@ -1515,6 +1517,7 @@ export declare const GeneralSettingSchema: z.ZodObject<{
|
|
|
1515
1517
|
edgelessScrollZoom?: boolean | undefined;
|
|
1516
1518
|
edgelessDisableScheduleUpdate?: boolean | undefined;
|
|
1517
1519
|
edgelessShowGrid?: boolean | undefined;
|
|
1520
|
+
showInvisibles?: boolean | undefined;
|
|
1518
1521
|
docCanvasPreferView?: "affine:embed-linked-doc" | "affine:embed-synced-doc" | undefined;
|
|
1519
1522
|
connector?: {
|
|
1520
1523
|
mode: import("../../affine-model/index.js").ConnectorMode;
|
|
@@ -12,6 +12,10 @@ export const GeneralSettingSchema = z
|
|
|
12
12
|
// A line comment, not JSDoc: see the guard in
|
|
13
13
|
// `affine/all/src/__tests__/zod-schema-jsdoc.unit.spec.ts`.
|
|
14
14
|
edgelessShowGrid: z.boolean().optional(),
|
|
15
|
+
// The host's (or the user's) default for "show special characters"
|
|
16
|
+
// (`text.invisibles.toggle`). Absent means off. A viewer's own toggle
|
|
17
|
+
// wins over it. A line comment, not JSDoc (same guard as above).
|
|
18
|
+
showInvisibles: z.boolean().optional(),
|
|
15
19
|
docCanvasPreferView: z
|
|
16
20
|
.enum(['affine:embed-linked-doc', 'affine:embed-synced-doc'])
|
|
17
21
|
.default('affine:embed-synced-doc'),
|
|
@@ -14,6 +14,7 @@ export * from './doc-mode-service.js';
|
|
|
14
14
|
export * from './drag-handle-config.js';
|
|
15
15
|
export * from './edit-props-store.js';
|
|
16
16
|
export * from './editor-setting-service.js';
|
|
17
|
+
export * from './invisible-characters.js';
|
|
17
18
|
export * from './embed-iframe/index.js';
|
|
18
19
|
export * from './embed-option-service.js';
|
|
19
20
|
export * from './feature-flag-service.js';
|
|
@@ -14,6 +14,7 @@ export * from './doc-mode-service.js';
|
|
|
14
14
|
export * from './drag-handle-config.js';
|
|
15
15
|
export * from './edit-props-store.js';
|
|
16
16
|
export * from './editor-setting-service.js';
|
|
17
|
+
export * from './invisible-characters.js';
|
|
17
18
|
export * from './embed-iframe/index.js';
|
|
18
19
|
export * from './embed-option-service.js';
|
|
19
20
|
export * from './feature-flag-service.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Container } from '../../global/di/index.js';
|
|
2
|
+
import { LifeCycleWatcher } from '../../std/index.js';
|
|
3
|
+
import { type ReadonlySignal } from '@preact/signals-core';
|
|
4
|
+
/**
|
|
5
|
+
* "Show special characters" as THIS viewer sees it (`text.invisibles.toggle`),
|
|
6
|
+
* modelled on `CanvasGrid` minus the document level: a display preference
|
|
7
|
+
* writes nothing to the document, so a reader may toggle it too.
|
|
8
|
+
*
|
|
9
|
+
* Nearest decision first: the viewer's own toggle (an `EditPropsStore`
|
|
10
|
+
* `localStorage` prop, the same for every document, a writer's habit), the
|
|
11
|
+
* host's default (`EditorSettingProvider`'s `showInvisibles`), off.
|
|
12
|
+
*
|
|
13
|
+
* Read by every `v-text` under the editor host through
|
|
14
|
+
* `InvisibleCharactersDisplayIdentifier` (`@labre/std/inline`), which marks
|
|
15
|
+
* spaces, tabs, no-break spaces and invisible characters; the line ends are
|
|
16
|
+
* drawn from {@link SHOW_INVISIBLES_ATTR}, which this service keeps on the
|
|
17
|
+
* host while `visible$` holds. The document title sits outside the host and
|
|
18
|
+
* shows no marks.
|
|
19
|
+
*/
|
|
20
|
+
export declare class InvisibleCharacters extends LifeCycleWatcher {
|
|
21
|
+
static key: string;
|
|
22
|
+
static setup(di: Container): void;
|
|
23
|
+
private readonly _local$;
|
|
24
|
+
/** Whether this viewer sees the special characters. */
|
|
25
|
+
readonly visible$: ReadonlySignal<boolean>;
|
|
26
|
+
/** What `v-text` reads. */
|
|
27
|
+
readonly showInvisibles$: ReadonlySignal<boolean>;
|
|
28
|
+
private _stopHostAttribute;
|
|
29
|
+
/** Flip the display for this viewer. Answers the new state. */
|
|
30
|
+
toggle(): boolean;
|
|
31
|
+
mounted(): void;
|
|
32
|
+
unmounted(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { LifeCycleWatcher } from '../../std/index.js';
|
|
2
|
+
import { InvisibleCharactersDisplayIdentifier, SHOW_INVISIBLES_ATTR, } from '../../std/inline/index.js';
|
|
3
|
+
import { computed, effect, signal, } from '@preact/signals-core';
|
|
4
|
+
import { EditPropsStore } from './edit-props-store.js';
|
|
5
|
+
import { EditorSettingProvider } from './editor-setting-service.js';
|
|
6
|
+
/**
|
|
7
|
+
* "Show special characters" as THIS viewer sees it (`text.invisibles.toggle`),
|
|
8
|
+
* modelled on `CanvasGrid` minus the document level: a display preference
|
|
9
|
+
* writes nothing to the document, so a reader may toggle it too.
|
|
10
|
+
*
|
|
11
|
+
* Nearest decision first: the viewer's own toggle (an `EditPropsStore`
|
|
12
|
+
* `localStorage` prop, the same for every document, a writer's habit), the
|
|
13
|
+
* host's default (`EditorSettingProvider`'s `showInvisibles`), off.
|
|
14
|
+
*
|
|
15
|
+
* Read by every `v-text` under the editor host through
|
|
16
|
+
* `InvisibleCharactersDisplayIdentifier` (`@labre/std/inline`), which marks
|
|
17
|
+
* spaces, tabs, no-break spaces and invisible characters; the line ends are
|
|
18
|
+
* drawn from {@link SHOW_INVISIBLES_ATTR}, which this service keeps on the
|
|
19
|
+
* host while `visible$` holds. The document title sits outside the host and
|
|
20
|
+
* shows no marks.
|
|
21
|
+
*/
|
|
22
|
+
export class InvisibleCharacters extends LifeCycleWatcher {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this._local$ = signal(undefined);
|
|
26
|
+
/** Whether this viewer sees the special characters. */
|
|
27
|
+
this.visible$ = computed(() => this._local$.value ??
|
|
28
|
+
this.std.getOptional(EditorSettingProvider)?.setting$.value
|
|
29
|
+
.showInvisibles ??
|
|
30
|
+
false);
|
|
31
|
+
/** What `v-text` reads. */
|
|
32
|
+
this.showInvisibles$ = this.visible$;
|
|
33
|
+
this._stopHostAttribute = null;
|
|
34
|
+
}
|
|
35
|
+
static { this.key = 'invisible-characters'; }
|
|
36
|
+
static setup(di) {
|
|
37
|
+
super.setup(di);
|
|
38
|
+
di.addImpl(InvisibleCharactersDisplayIdentifier, provider => provider.get(InvisibleCharacters));
|
|
39
|
+
}
|
|
40
|
+
/** Flip the display for this viewer. Answers the new state. */
|
|
41
|
+
toggle() {
|
|
42
|
+
const visible = !this.visible$.peek();
|
|
43
|
+
this._local$.value = visible;
|
|
44
|
+
this.std.getOptional(EditPropsStore)?.setStorage('showInvisibles', visible);
|
|
45
|
+
return visible;
|
|
46
|
+
}
|
|
47
|
+
mounted() {
|
|
48
|
+
super.mounted();
|
|
49
|
+
const stored = this.std
|
|
50
|
+
.getOptional(EditPropsStore)
|
|
51
|
+
?.getStorage('showInvisibles');
|
|
52
|
+
this._local$.value = stored ?? undefined;
|
|
53
|
+
const host = this.std.host;
|
|
54
|
+
this._stopHostAttribute = effect(() => {
|
|
55
|
+
host.toggleAttribute(SHOW_INVISIBLES_ATTR, this.visible$.value);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
unmounted() {
|
|
59
|
+
super.unmounted();
|
|
60
|
+
this._stopHostAttribute?.();
|
|
61
|
+
this._stopHostAttribute = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -3,17 +3,8 @@ import { type Container } from '../../../global/di/index.js';
|
|
|
3
3
|
import { Extension, type ExtensionType } from '../../../store/index.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
export declare const LinkPreviewCacheConfigSchema: z.ZodObject<{
|
|
6
|
-
/**
|
|
7
|
-
* The maximum number of items in the cache
|
|
8
|
-
*/
|
|
9
6
|
cacheSize: z.ZodNumber;
|
|
10
|
-
/**
|
|
11
|
-
* The time to live for the memory cache
|
|
12
|
-
*/
|
|
13
7
|
memoryTTL: z.ZodNumber;
|
|
14
|
-
/**
|
|
15
|
-
* The time to live for the local storage cache
|
|
16
|
-
*/
|
|
17
8
|
localStorageTTL: z.ZodNumber;
|
|
18
9
|
}, "strip", z.ZodTypeAny, {
|
|
19
10
|
cacheSize: number;
|
|
@@ -5,17 +5,11 @@ import QuickLRU from 'quick-lru';
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { LinkPreviewStorage } from './link-preview-storage.js';
|
|
7
7
|
export const LinkPreviewCacheConfigSchema = z.object({
|
|
8
|
-
|
|
9
|
-
* The maximum number of items in the cache
|
|
10
|
-
*/
|
|
8
|
+
// The maximum number of items in the cache
|
|
11
9
|
cacheSize: z.number(),
|
|
12
|
-
|
|
13
|
-
* The time to live for the memory cache
|
|
14
|
-
*/
|
|
10
|
+
// The time to live for the memory cache
|
|
15
11
|
memoryTTL: z.number(),
|
|
16
|
-
|
|
17
|
-
* The time to live for the local storage cache
|
|
18
|
-
*/
|
|
12
|
+
// The time to live for the local storage cache
|
|
19
13
|
localStorageTTL: z.number(),
|
|
20
14
|
});
|
|
21
15
|
const DEFAULT_LINK_PREVIEW_CACHE_CONFIG = {
|
|
@@ -389,3 +389,29 @@ export type CanvasPaneEvents = {
|
|
|
389
389
|
CanvasGridToggled: CanvasGridToggledEvent;
|
|
390
390
|
CanvasLayerChanged: CanvasLayerChangedEvent;
|
|
391
391
|
};
|
|
392
|
+
/**
|
|
393
|
+
* `text.invisibles.remove` stripped the invisible characters of the document
|
|
394
|
+
* (zero-width spaces, word joiners, tag characters…).
|
|
395
|
+
*
|
|
396
|
+
* `count` is how many characters the ONE gesture removed, `blockCount` how
|
|
397
|
+
* many blocks it changed (the canvas counts as one: its elements live in the
|
|
398
|
+
* surface block). A run that finds nothing reports nothing.
|
|
399
|
+
*
|
|
400
|
+
* Counts only: never a character, a block id or any text.
|
|
401
|
+
*/
|
|
402
|
+
export interface InvisibleCharactersRemovedEvent extends TelemetryEvent {
|
|
403
|
+
count: number;
|
|
404
|
+
blockCount: number;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* `text.invisibles.toggle` switched "show special characters" for this
|
|
408
|
+
* viewer. `visible` is the state after the gesture. Nothing is written to
|
|
409
|
+
* the document.
|
|
410
|
+
*/
|
|
411
|
+
export interface InvisibleCharactersToggledEvent extends TelemetryEvent {
|
|
412
|
+
visible: boolean;
|
|
413
|
+
}
|
|
414
|
+
export type InvisibleCharactersEvents = {
|
|
415
|
+
InvisibleCharactersRemoved: InvisibleCharactersRemovedEvent;
|
|
416
|
+
InvisibleCharactersToggled: InvisibleCharactersToggledEvent;
|
|
417
|
+
};
|
|
@@ -2,12 +2,12 @@ import type { ExtensionType } from '../../../store/index.js';
|
|
|
2
2
|
import type { CitationEvents } from './citation.js';
|
|
3
3
|
import type { CodeBlockEvents } from './code-block.js';
|
|
4
4
|
import type { OutDatabaseAllEvents } from './database.js';
|
|
5
|
-
import type { AuditEvents, BlockLifecycleEvents, CanvasPaneEvents, DocumentHealthEvents, FrameworkDiagramEvents, ValidationEvents } from './lifecycle.js';
|
|
5
|
+
import type { AuditEvents, BlockLifecycleEvents, CanvasPaneEvents, InvisibleCharactersEvents, DocumentHealthEvents, FrameworkDiagramEvents, ValidationEvents } from './lifecycle.js';
|
|
6
6
|
import type { LinkToolbarEvents } from './link.js';
|
|
7
7
|
import type { NoteEvents } from './note.js';
|
|
8
8
|
import type { SlashMenuEvents } from './slash-menu.js';
|
|
9
|
-
import type { AttachmentReloadedEvent, AttachmentReloadedEventInToolbar, AttachmentUpgradedEvent, AttachmentUploadedEvent, BlockCreationEvent, DocCreatedEvent, EdgelessToolPickedEvent, ElementCreationEvent, ElementLockEvent, ElementUpdatedEvent, LatexEvent, LinkedDocCreatedEvent, LinkEvent, MindMapCollapseEvent, TelemetryEvent } from './types.js';
|
|
10
|
-
export type TelemetryEventMap = OutDatabaseAllEvents & LinkToolbarEvents & SlashMenuEvents & CodeBlockEvents & NoteEvents & CitationEvents & BlockLifecycleEvents & FrameworkDiagramEvents & ValidationEvents & AuditEvents & CanvasPaneEvents & DocumentHealthEvents & {
|
|
9
|
+
import type { AttachmentReloadedEvent, AttachmentReloadedEventInToolbar, AttachmentUpgradedEvent, AttachmentUploadedEvent, BlockCreationEvent, DocCreatedEvent, EdgelessToolPickedEvent, ElementCreationEvent, ElementLockEvent, ElementReplacedEvent, ElementUpdatedEvent, LatexEvent, LinkedDocCreatedEvent, LinkEvent, MindMapCollapseEvent, TelemetryEvent } from './types.js';
|
|
10
|
+
export type TelemetryEventMap = OutDatabaseAllEvents & LinkToolbarEvents & SlashMenuEvents & CodeBlockEvents & NoteEvents & CitationEvents & BlockLifecycleEvents & FrameworkDiagramEvents & ValidationEvents & AuditEvents & CanvasPaneEvents & InvisibleCharactersEvents & DocumentHealthEvents & {
|
|
11
11
|
DocCreated: DocCreatedEvent;
|
|
12
12
|
Link: TelemetryEvent;
|
|
13
13
|
LinkedDocCreated: LinkedDocCreatedEvent;
|
|
@@ -15,6 +15,7 @@ export type TelemetryEventMap = OutDatabaseAllEvents & LinkToolbarEvents & Slash
|
|
|
15
15
|
CanvasElementAdded: ElementCreationEvent;
|
|
16
16
|
CanvasElementUpdated: ElementUpdatedEvent;
|
|
17
17
|
EdgelessElementLocked: ElementLockEvent;
|
|
18
|
+
ElementReplaced: ElementReplacedEvent;
|
|
18
19
|
ExpandedAndCollapsed: MindMapCollapseEvent;
|
|
19
20
|
AttachmentReloadedEvent: AttachmentReloadedEvent | AttachmentReloadedEventInToolbar;
|
|
20
21
|
AttachmentUpgradedEvent: AttachmentUpgradedEvent;
|
|
@@ -37,6 +37,17 @@ export interface ElementLockEvent extends TelemetryEvent {
|
|
|
37
37
|
export interface BlockCreationEvent extends TelemetryEvent {
|
|
38
38
|
blockType: string;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* A canvas model replaced by a model of another kind at its place (ADR 0044):
|
|
42
|
+
* a shape by an image, an image by a shape — or a canvas image's picture by
|
|
43
|
+
* another (`image` → `image`, amendment of 2026-10-27). Kinds only — never
|
|
44
|
+
* the ids, never the picture's `sourceId`, never content.
|
|
45
|
+
*/
|
|
46
|
+
export interface ElementReplacedEvent extends TelemetryEvent {
|
|
47
|
+
page?: 'whiteboard editor';
|
|
48
|
+
from: 'shape' | 'image';
|
|
49
|
+
to: 'shape' | 'image';
|
|
50
|
+
}
|
|
40
51
|
export interface MindMapCollapseEvent extends TelemetryEvent {
|
|
41
52
|
page: 'whiteboard editor';
|
|
42
53
|
segment: 'mind map';
|
|
@@ -13,6 +13,7 @@ export * from './file/index.js';
|
|
|
13
13
|
export * from './fractional-indexing.js';
|
|
14
14
|
export * from './image.js';
|
|
15
15
|
export * from './insert.js';
|
|
16
|
+
export * from './invisible-characters.js';
|
|
16
17
|
export * from './is-abort-error.js';
|
|
17
18
|
export * from './label-mode.js';
|
|
18
19
|
export * from './link-preview-refresh.js';
|
|
@@ -13,6 +13,7 @@ export * from './file/index.js';
|
|
|
13
13
|
export * from './fractional-indexing.js';
|
|
14
14
|
export * from './image.js';
|
|
15
15
|
export * from './insert.js';
|
|
16
|
+
export * from './invisible-characters.js';
|
|
16
17
|
export * from './is-abort-error.js';
|
|
17
18
|
export * from './label-mode.js';
|
|
18
19
|
export * from './link-preview-refresh.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { INVISIBLE_CHARACTERS } from '../../std/inline/index.js';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
/**
|
|
4
|
+
* Removing the invisible characters an AI text generator or a "watermarking"
|
|
5
|
+
* tool leaves in a text (`text.invisibles.remove`). The character set and the
|
|
6
|
+
* two contexts where a ZWJ or a tag is kept (emoji sequences, subdivision
|
|
7
|
+
* flags) live in `@labre/std/inline`, where the "show special characters"
|
|
8
|
+
* display reads the same list.
|
|
9
|
+
*/
|
|
10
|
+
export { INVISIBLE_CHARACTERS };
|
|
11
|
+
export interface StripInvisiblesOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Also replace the no-break spaces U+00A0 and U+202F with a plain space.
|
|
14
|
+
* Off by default: French typography puts them before `: ; ! ?` and inside
|
|
15
|
+
* quotation marks on purpose. They are not counted in `removed`.
|
|
16
|
+
*/
|
|
17
|
+
normalizeSpaces?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `str` without its invisible characters, and how many were removed (code
|
|
21
|
+
* points, not UTF-16 units: a tag character counts once).
|
|
22
|
+
*/
|
|
23
|
+
export declare function stripInvisibles(str: string, options?: StripInvisiblesOptions): {
|
|
24
|
+
text: string;
|
|
25
|
+
removed: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Delete the invisible characters of a `Y.Text` in place, from the end so the
|
|
29
|
+
* indices still to visit stay valid, one `delete` per contiguous run: the
|
|
30
|
+
* formatting of the text around them is untouched. Answers how many were
|
|
31
|
+
* removed. The caller owns the transaction (one gesture, one undo step).
|
|
32
|
+
*
|
|
33
|
+
* Indices follow Yjs: an embed counts as one, like the inline editor's.
|
|
34
|
+
*/
|
|
35
|
+
export declare function stripInvisiblesFromYText(yText: Y.Text): number;
|
|
36
|
+
/**
|
|
37
|
+
* Every `Y.Text` held under a Yjs value, depth first: a block's `prop:text`
|
|
38
|
+
* and `prop:title`, a table's cells, a database's rich-text cells, and under
|
|
39
|
+
* the surface block every canvas element's text, labels and titles — whatever
|
|
40
|
+
* the framework, without a list to keep in step.
|
|
41
|
+
*/
|
|
42
|
+
export declare function collectYTexts(value: unknown, into?: Y.Text[]): Y.Text[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { findInvisibleCharacters, INVISIBLE_CHARACTERS, } from '../../std/inline/index.js';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
/**
|
|
4
|
+
* Removing the invisible characters an AI text generator or a "watermarking"
|
|
5
|
+
* tool leaves in a text (`text.invisibles.remove`). The character set and the
|
|
6
|
+
* two contexts where a ZWJ or a tag is kept (emoji sequences, subdivision
|
|
7
|
+
* flags) live in `@labre/std/inline`, where the "show special characters"
|
|
8
|
+
* display reads the same list.
|
|
9
|
+
*/
|
|
10
|
+
export { INVISIBLE_CHARACTERS };
|
|
11
|
+
/**
|
|
12
|
+
* `str` without its invisible characters, and how many were removed (code
|
|
13
|
+
* points, not UTF-16 units: a tag character counts once).
|
|
14
|
+
*/
|
|
15
|
+
export function stripInvisibles(str, options = {}) {
|
|
16
|
+
const runs = findInvisibleCharacters(str);
|
|
17
|
+
let text = str;
|
|
18
|
+
if (runs.length > 0) {
|
|
19
|
+
let kept = '';
|
|
20
|
+
let from = 0;
|
|
21
|
+
for (const run of runs) {
|
|
22
|
+
kept += str.slice(from, run.index);
|
|
23
|
+
from = run.index + run.length;
|
|
24
|
+
}
|
|
25
|
+
text = kept + str.slice(from);
|
|
26
|
+
}
|
|
27
|
+
if (options.normalizeSpaces)
|
|
28
|
+
text = text.replace(/[\u00A0\u202F]/g, ' ');
|
|
29
|
+
return { text, removed: runs.length };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Delete the invisible characters of a `Y.Text` in place, from the end so the
|
|
33
|
+
* indices still to visit stay valid, one `delete` per contiguous run: the
|
|
34
|
+
* formatting of the text around them is untouched. Answers how many were
|
|
35
|
+
* removed. The caller owns the transaction (one gesture, one undo step).
|
|
36
|
+
*
|
|
37
|
+
* Indices follow Yjs: an embed counts as one, like the inline editor's.
|
|
38
|
+
*/
|
|
39
|
+
export function stripInvisiblesFromYText(yText) {
|
|
40
|
+
const ranges = [];
|
|
41
|
+
let removed = 0;
|
|
42
|
+
let offset = 0;
|
|
43
|
+
for (const op of yText.toDelta()) {
|
|
44
|
+
if (typeof op.insert !== 'string') {
|
|
45
|
+
offset += 1;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
for (const run of findInvisibleCharacters(op.insert)) {
|
|
49
|
+
removed += 1;
|
|
50
|
+
const index = offset + run.index;
|
|
51
|
+
const last = ranges[ranges.length - 1];
|
|
52
|
+
if (last && last.index + last.length === index)
|
|
53
|
+
last.length += run.length;
|
|
54
|
+
else
|
|
55
|
+
ranges.push({ index, length: run.length });
|
|
56
|
+
}
|
|
57
|
+
offset += op.insert.length;
|
|
58
|
+
}
|
|
59
|
+
for (let i = ranges.length - 1; i >= 0; i--) {
|
|
60
|
+
yText.delete(ranges[i].index, ranges[i].length);
|
|
61
|
+
}
|
|
62
|
+
return removed;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Every `Y.Text` held under a Yjs value, depth first: a block's `prop:text`
|
|
66
|
+
* and `prop:title`, a table's cells, a database's rich-text cells, and under
|
|
67
|
+
* the surface block every canvas element's text, labels and titles — whatever
|
|
68
|
+
* the framework, without a list to keep in step.
|
|
69
|
+
*/
|
|
70
|
+
export function collectYTexts(value, into = []) {
|
|
71
|
+
if (value instanceof Y.Text) {
|
|
72
|
+
into.push(value);
|
|
73
|
+
}
|
|
74
|
+
else if (value instanceof Y.Map) {
|
|
75
|
+
value.forEach(child => collectYTexts(child, into));
|
|
76
|
+
}
|
|
77
|
+
else if (value instanceof Y.Array) {
|
|
78
|
+
value.forEach(child => collectYTexts(child, into));
|
|
79
|
+
}
|
|
80
|
+
return into;
|
|
81
|
+
}
|
|
@@ -52,29 +52,29 @@ let AffineEdgelessZoomToolbarWidget = (() => {
|
|
|
52
52
|
__esDecorate(this, null, __hide_decorators, { kind: "accessor", name: "_hide", static: false, private: false, access: { has: obj => "_hide" in obj, get: obj => obj._hide, set: (obj, value) => { obj._hide = value; } }, metadata: _metadata }, __hide_initializers, __hide_extraInitializers);
|
|
53
53
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
54
54
|
}
|
|
55
|
-
static { this.styles = css `
|
|
56
|
-
:host {
|
|
57
|
-
position: absolute;
|
|
58
|
-
bottom: 20px;
|
|
59
|
-
left: 12px;
|
|
60
|
-
z-index: var(--affine-z-index-popover);
|
|
61
|
-
display: flex;
|
|
62
|
-
justify-content: center;
|
|
63
|
-
-webkit-user-select: none;
|
|
64
|
-
user-select: none;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@container viewport (width <= 1200px) {
|
|
68
|
-
edgeless-zoom-toolbar {
|
|
69
|
-
display: none;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@container viewport (width > 1200px) {
|
|
74
|
-
zoom-bar-toggle-button {
|
|
75
|
-
display: none;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
55
|
+
static { this.styles = css `
|
|
56
|
+
:host {
|
|
57
|
+
position: absolute;
|
|
58
|
+
bottom: 20px;
|
|
59
|
+
left: 12px;
|
|
60
|
+
z-index: var(--affine-z-index-popover);
|
|
61
|
+
display: flex;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
-webkit-user-select: none;
|
|
64
|
+
user-select: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@container viewport (width <= 1200px) {
|
|
68
|
+
edgeless-zoom-toolbar {
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@container viewport (width > 1200px) {
|
|
74
|
+
zoom-bar-toggle-button {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
78
|
`; }
|
|
79
79
|
get edgeless() {
|
|
80
80
|
return this.block;
|
|
@@ -105,9 +105,9 @@ let AffineEdgelessZoomToolbarWidget = (() => {
|
|
|
105
105
|
if (this._hide || !this.edgeless) {
|
|
106
106
|
return nothing;
|
|
107
107
|
}
|
|
108
|
-
return html `
|
|
109
|
-
<edgeless-zoom-toolbar .std=${this.std}></edgeless-zoom-toolbar>
|
|
110
|
-
<zoom-bar-toggle-button .std=${this.std}></zoom-bar-toggle-button>
|
|
108
|
+
return html `
|
|
109
|
+
<edgeless-zoom-toolbar .std=${this.std}></edgeless-zoom-toolbar>
|
|
110
|
+
<zoom-bar-toggle-button .std=${this.std}></zoom-bar-toggle-button>
|
|
111
111
|
`;
|
|
112
112
|
}
|
|
113
113
|
#_hide_accessor_storage = __runInitializers(this, __hide_initializers, false);
|