@formicoidea/labre-core-database 4.1.0 → 4.3.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/dist/creation-popover.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { connectDatabaseToSource, DATABASE_CREATION_TITLE, reconnectDatabaseView, } from '@formicoidea/labre-core/blocks/database';
|
|
1
|
+
import { connectDatabaseToSource, DATABASE_CREATION_TITLE, placeViewThroughHost, reconnectDatabaseView, } from '@formicoidea/labre-core/blocks/database';
|
|
2
2
|
import { menu, popMenu, popupTargetFromElement, } from '@formicoidea/labre-core/components/context-menu';
|
|
3
3
|
import { DataSourcePickerProvider, translateKey, } from '@formicoidea/labre-core/shared/services';
|
|
4
4
|
import { LinkIcon } from '@blocksuite/icons/lit';
|
|
@@ -27,15 +27,34 @@ export function databaseCreationItems(std, picker, blockId, viewId) {
|
|
|
27
27
|
const connect = (database, sourceId) => {
|
|
28
28
|
const model = databaseModel(std, blockId);
|
|
29
29
|
if (!model)
|
|
30
|
-
return;
|
|
30
|
+
return false;
|
|
31
31
|
if (model.props.externalSourceId === undefined) {
|
|
32
|
-
connectDatabaseToSource(std, model, { database, sourceId });
|
|
33
|
-
return;
|
|
32
|
+
return connectDatabaseToSource(std, model, { database, sourceId });
|
|
34
33
|
}
|
|
35
34
|
const view = viewId ?? model.props.views[0]?.id;
|
|
36
|
-
|
|
37
|
-
reconnectDatabaseView(std, model, { database, sourceId, viewId: view })
|
|
38
|
-
|
|
35
|
+
return view
|
|
36
|
+
? reconnectDatabaseView(std, model, { database, sourceId, viewId: view })
|
|
37
|
+
: false;
|
|
38
|
+
};
|
|
39
|
+
// An existing source goes through the host's `placeView` (issue #701);
|
|
40
|
+
// one the host just created for this gesture does not.
|
|
41
|
+
const connectExisting = (database, sourceId) => {
|
|
42
|
+
const model = databaseModel(std, blockId);
|
|
43
|
+
const reconnects = model?.props.externalSourceId !== undefined;
|
|
44
|
+
const view = reconnects ? (viewId ?? model?.props.views[0]?.id) : undefined;
|
|
45
|
+
placeViewThroughHost({
|
|
46
|
+
picker,
|
|
47
|
+
store: std.store,
|
|
48
|
+
ref: {
|
|
49
|
+
gesture: 'connect',
|
|
50
|
+
databaseId: database.id,
|
|
51
|
+
sourceId,
|
|
52
|
+
docId: std.store.id,
|
|
53
|
+
blockId,
|
|
54
|
+
...(view === undefined ? {} : { viewId: view }),
|
|
55
|
+
},
|
|
56
|
+
placeNow: () => connect(database, sourceId),
|
|
57
|
+
});
|
|
39
58
|
};
|
|
40
59
|
const createDatabase = picker.createDatabase;
|
|
41
60
|
const list = picker.list();
|
|
@@ -67,7 +86,8 @@ export function databaseCreationItems(std, picker, blockId, viewId) {
|
|
|
67
86
|
testId: 'database-creation-link-existing',
|
|
68
87
|
items: dataSourcePickerItems(std, picker, {
|
|
69
88
|
offerCreate: false,
|
|
70
|
-
|
|
89
|
+
// `offerCreate: false`: every pick here is an existing source.
|
|
90
|
+
onPick: ({ database, sourceId }) => connectExisting(database, sourceId),
|
|
71
91
|
}),
|
|
72
92
|
},
|
|
73
93
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { insertLinkedDatabaseView } from '@formicoidea/labre-core/blocks/database';
|
|
1
|
+
import { insertLinkedDatabaseView, placeViewThroughHost, } from '@formicoidea/labre-core/blocks/database';
|
|
2
2
|
import { popupTargetFromElement } from '@formicoidea/labre-core/components/context-menu';
|
|
3
3
|
import { getSelectedModelsCommand } from '@formicoidea/labre-core/shared/commands';
|
|
4
4
|
import { DataSourcePickerProvider } from '@formicoidea/labre-core/shared/services';
|
|
@@ -36,13 +36,28 @@ export const linkedViewSlashMenuConfig = {
|
|
|
36
36
|
if (!after || !anchor)
|
|
37
37
|
return;
|
|
38
38
|
popDataSourcePicker(std, picker, popupTargetFromElement(anchor), {
|
|
39
|
-
onPick: ({ database, sourceId }) => {
|
|
40
|
-
insertLinkedDatabaseView(std, {
|
|
39
|
+
onPick: ({ database, sourceId, source }) => {
|
|
40
|
+
const insert = () => insertLinkedDatabaseView(std, {
|
|
41
41
|
after,
|
|
42
42
|
database,
|
|
43
43
|
sourceId,
|
|
44
44
|
viewType: 'table',
|
|
45
45
|
removeEmptyLine: true,
|
|
46
|
+
}) !== null;
|
|
47
|
+
// A source the host just created for this pick is no placement
|
|
48
|
+
// to confirm (issue #701).
|
|
49
|
+
placeViewThroughHost({
|
|
50
|
+
picker,
|
|
51
|
+
store: std.store,
|
|
52
|
+
ref: source === 'new'
|
|
53
|
+
? null
|
|
54
|
+
: {
|
|
55
|
+
gesture: 'linked-view',
|
|
56
|
+
databaseId: database.id,
|
|
57
|
+
sourceId,
|
|
58
|
+
docId: std.store.id,
|
|
59
|
+
},
|
|
60
|
+
placeNow: insert,
|
|
46
61
|
});
|
|
47
62
|
},
|
|
48
63
|
});
|
|
@@ -125,7 +125,8 @@ let DatabasePropertiesPanel = (() => {
|
|
|
125
125
|
|
|
126
126
|
.affine-database-properties-panel-button:focus-visible,
|
|
127
127
|
.affine-database-properties-panel-toggle:focus-visible {
|
|
128
|
-
outline: 2px solid
|
|
128
|
+
outline: 2px solid
|
|
129
|
+
var(--affine-focus-ring-color, var(--affine-primary-color));
|
|
129
130
|
outline-offset: 1px;
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HostedDataSourceBase, viewDatabaseId, } from '@formicoidea/labre-core/blocks/database';
|
|
1
|
+
import { HostedDataSourceBase, placeViewThroughHost, viewDatabaseId, } from '@formicoidea/labre-core/blocks/database';
|
|
2
2
|
import { menu } from '@formicoidea/labre-core/components/context-menu';
|
|
3
3
|
import { DataSourcePickerProvider, DOC_UNTITLED, translateKey, } from '@formicoidea/labre-core/shared/services';
|
|
4
4
|
import { viewDefaultName, } from '@formicoidea/labre-core/data-view';
|
|
@@ -163,11 +163,32 @@ export function databaseAddViewMenu(picker) {
|
|
|
163
163
|
testId: 'database-add-view-preset',
|
|
164
164
|
prefix: html `<uni-lit .uni=${meta.renderer.icon}></uni-lit>`,
|
|
165
165
|
select: () => {
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
const addNow = () => {
|
|
167
|
+
if (source?.databaseId === undefined) {
|
|
168
|
+
return !!addViewOnSource(context, dataSource, meta.type, source?.sourceId);
|
|
169
|
+
}
|
|
170
|
+
return !!addViewOnSource(context, dataSource, meta.type, source.sourceId, 'existing', source.databaseId);
|
|
171
|
+
};
|
|
172
|
+
const model = dataSource.hostModel;
|
|
173
|
+
const databaseId = source?.databaseId ?? model.props.externalSourceId;
|
|
174
|
+
if (!hostPicker?.placeView || databaseId === undefined) {
|
|
175
|
+
addNow();
|
|
168
176
|
return;
|
|
169
177
|
}
|
|
170
|
-
|
|
178
|
+
placeViewThroughHost({
|
|
179
|
+
picker: hostPicker,
|
|
180
|
+
store: model.store,
|
|
181
|
+
ref: {
|
|
182
|
+
gesture: 'add-view',
|
|
183
|
+
databaseId,
|
|
184
|
+
...(source?.sourceId === undefined
|
|
185
|
+
? {}
|
|
186
|
+
: { sourceId: source.sourceId }),
|
|
187
|
+
docId: model.store.id,
|
|
188
|
+
blockId: model.id,
|
|
189
|
+
},
|
|
190
|
+
placeNow: addNow,
|
|
191
|
+
});
|
|
171
192
|
},
|
|
172
193
|
}));
|
|
173
194
|
if (shape.kind === 'presets') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HostedDataSourceBase } from '@formicoidea/labre-core/blocks/database';
|
|
1
|
+
import { HostedDataSourceBase, placeViewThroughHost, } from '@formicoidea/labre-core/blocks/database';
|
|
2
2
|
import { menu, popMenu, } from '@formicoidea/labre-core/components/context-menu';
|
|
3
3
|
import { DataSourcePickerProvider, DOC_UNTITLED, translateKey, } from '@formicoidea/labre-core/shared/services';
|
|
4
4
|
import { ArrowRightSmallIcon, DatabaseTableViewIcon, } from '@blocksuite/icons/lit';
|
|
@@ -100,7 +100,19 @@ export function popChangeSourcePicker(std, target, change, reopen) {
|
|
|
100
100
|
select: () => {
|
|
101
101
|
if (selected)
|
|
102
102
|
return;
|
|
103
|
-
|
|
103
|
+
placeViewThroughHost({
|
|
104
|
+
picker,
|
|
105
|
+
store: std.store,
|
|
106
|
+
ref: {
|
|
107
|
+
gesture: 'change-source',
|
|
108
|
+
databaseId: source.databaseId ?? databaseId,
|
|
109
|
+
sourceId: source.sourceId,
|
|
110
|
+
docId: std.store.id,
|
|
111
|
+
blockId: dataSource.hostModel.id,
|
|
112
|
+
viewId,
|
|
113
|
+
},
|
|
114
|
+
placeNow: () => changeViewSource(dataSource, viewId, source.sourceId, 'existing', ...inDatabase(source.databaseId)),
|
|
115
|
+
});
|
|
104
116
|
},
|
|
105
117
|
});
|
|
106
118
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formicoidea/labre-core-database",
|
|
3
3
|
"description": "Labre core-database editing chrome for @formicoidea/labre-core.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@formicoidea/labre-core": "4.
|
|
30
|
+
"@formicoidea/labre-core": "4.3.0",
|
|
31
31
|
"@blocksuite/icons": "^2.2.12",
|
|
32
32
|
"@preact/signals-core": "^1.8.0",
|
|
33
33
|
"lit": "^3.2.0"
|