@difizen/libro-core 0.0.2-alpha.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/LICENSE +21 -0
- package/README.md +3 -0
- package/es/add-cell/index.d.ts +4 -0
- package/es/add-cell/index.d.ts.map +1 -0
- package/es/add-cell/index.js +3 -0
- package/es/add-cell/index.less +38 -0
- package/es/add-cell/libro-add-cell-module.d.ts +3 -0
- package/es/add-cell/libro-add-cell-module.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-module.js +4 -0
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts +12 -0
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-slot-contribution.js +53 -0
- package/es/add-cell/libro-add-cell-view.d.ts +21 -0
- package/es/add-cell/libro-add-cell-view.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-view.js +129 -0
- package/es/cell/index.d.ts +10 -0
- package/es/cell/index.d.ts.map +1 -0
- package/es/cell/index.js +9 -0
- package/es/cell/libro-cell-contribution.d.ts +13 -0
- package/es/cell/libro-cell-contribution.d.ts.map +1 -0
- package/es/cell/libro-cell-contribution.js +41 -0
- package/es/cell/libro-cell-model.d.ts +19 -0
- package/es/cell/libro-cell-model.d.ts.map +1 -0
- package/es/cell/libro-cell-model.js +103 -0
- package/es/cell/libro-cell-module.d.ts +10 -0
- package/es/cell/libro-cell-module.d.ts.map +1 -0
- package/es/cell/libro-cell-module.js +30 -0
- package/es/cell/libro-cell-protocol.d.ts +42 -0
- package/es/cell/libro-cell-protocol.d.ts.map +1 -0
- package/es/cell/libro-cell-protocol.js +11 -0
- package/es/cell/libro-cell-service.d.ts +28 -0
- package/es/cell/libro-cell-service.d.ts.map +1 -0
- package/es/cell/libro-cell-service.js +242 -0
- package/es/cell/libro-cell-view.d.ts +65 -0
- package/es/cell/libro-cell-view.d.ts.map +1 -0
- package/es/cell/libro-cell-view.js +191 -0
- package/es/cell/libro-edit-cell-view.d.ts +32 -0
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -0
- package/es/cell/libro-edit-cell-view.js +72 -0
- package/es/cell/libro-executable-cell-model.d.ts +14 -0
- package/es/cell/libro-executable-cell-model.d.ts.map +1 -0
- package/es/cell/libro-executable-cell-model.js +7 -0
- package/es/cell/libro-executable-cell-view.d.ts +27 -0
- package/es/cell/libro-executable-cell-view.d.ts.map +1 -0
- package/es/cell/libro-executable-cell-view.js +66 -0
- package/es/cell/libro-markdown-cell-model.d.ts +9 -0
- package/es/cell/libro-markdown-cell-model.d.ts.map +1 -0
- package/es/cell/libro-markdown-cell-model.js +7 -0
- package/es/collapse-service.d.ts +36 -0
- package/es/collapse-service.d.ts.map +1 -0
- package/es/collapse-service.js +55 -0
- package/es/command/document-commands.d.ts +6 -0
- package/es/command/document-commands.d.ts.map +1 -0
- package/es/command/document-commands.js +13 -0
- package/es/command/index.d.ts +7 -0
- package/es/command/index.d.ts.map +1 -0
- package/es/command/index.js +6 -0
- package/es/command/kernel-command.d.ts +5 -0
- package/es/command/kernel-command.d.ts.map +1 -0
- package/es/command/kernel-command.js +39 -0
- package/es/command/libro-command-contribution.d.ts +14 -0
- package/es/command/libro-command-contribution.d.ts.map +1 -0
- package/es/command/libro-command-contribution.js +1751 -0
- package/es/command/libro-command-register.d.ts +22 -0
- package/es/command/libro-command-register.d.ts.map +1 -0
- package/es/command/libro-command-register.js +105 -0
- package/es/command/module.d.ts +3 -0
- package/es/command/module.d.ts.map +1 -0
- package/es/command/module.js +4 -0
- package/es/command/notebook-commands.d.ts +6 -0
- package/es/command/notebook-commands.d.ts.map +1 -0
- package/es/command/notebook-commands.js +468 -0
- package/es/components/cell-protocol.d.ts +20 -0
- package/es/components/cell-protocol.d.ts.map +1 -0
- package/es/components/cell-protocol.js +4 -0
- package/es/components/dnd-cell-item-render.d.ts +12 -0
- package/es/components/dnd-cell-item-render.d.ts.map +1 -0
- package/es/components/dnd-cell-item-render.js +253 -0
- package/es/components/dnd-component/custom-drag-layer.d.ts +9 -0
- package/es/components/dnd-component/custom-drag-layer.d.ts.map +1 -0
- package/es/components/dnd-component/custom-drag-layer.js +141 -0
- package/es/components/dnd-component/default-dnd-content.d.ts +10 -0
- package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -0
- package/es/components/dnd-component/default-dnd-content.js +257 -0
- package/es/components/dnd-component/dnd-context.d.ts +3 -0
- package/es/components/dnd-component/dnd-context.d.ts.map +1 -0
- package/es/components/dnd-component/dnd-context.js +20 -0
- package/es/components/dnd-component/dnd-list.d.ts +10 -0
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -0
- package/es/components/dnd-component/dnd-list.js +115 -0
- package/es/components/dnd-component/index.d.ts +5 -0
- package/es/components/dnd-component/index.d.ts.map +1 -0
- package/es/components/dnd-component/index.js +4 -0
- package/es/components/index.d.ts +6 -0
- package/es/components/index.d.ts.map +1 -0
- package/es/components/index.js +5 -0
- package/es/components/libro-component.d.ts +5 -0
- package/es/components/libro-component.d.ts.map +1 -0
- package/es/components/libro-component.js +35 -0
- package/es/components/libro-side-toolbar-menu.d.ts +21 -0
- package/es/components/libro-side-toolbar-menu.d.ts.map +1 -0
- package/es/components/libro-side-toolbar-menu.js +58 -0
- package/es/components/libro-view-header.d.ts +3 -0
- package/es/components/libro-view-header.d.ts.map +1 -0
- package/es/components/libro-view-header.js +37 -0
- package/es/configuration/libro-configuration-contribution.d.ts +5 -0
- package/es/configuration/libro-configuration-contribution.d.ts.map +1 -0
- package/es/configuration/libro-configuration-contribution.js +24 -0
- package/es/configuration/libro-configuration.d.ts +10 -0
- package/es/configuration/libro-configuration.d.ts.map +1 -0
- package/es/configuration/libro-configuration.js +81 -0
- package/es/content/index.d.ts +5 -0
- package/es/content/index.d.ts.map +1 -0
- package/es/content/index.js +4 -0
- package/es/content/libro-content-contribution.d.ts +11 -0
- package/es/content/libro-content-contribution.d.ts.map +1 -0
- package/es/content/libro-content-contribution.js +32 -0
- package/es/content/libro-content-module.d.ts +3 -0
- package/es/content/libro-content-module.d.ts.map +1 -0
- package/es/content/libro-content-module.js +5 -0
- package/es/content/libro-content-protocol.d.ts +8 -0
- package/es/content/libro-content-protocol.d.ts.map +1 -0
- package/es/content/libro-content-protocol.js +2 -0
- package/es/content/libro-content-service.d.ts +9 -0
- package/es/content/libro-content-service.d.ts.map +1 -0
- package/es/content/libro-content-service.js +35 -0
- package/es/index.d.ts +20 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +19 -0
- package/es/index.less +682 -0
- package/es/libro-context-key.d.ts +22 -0
- package/es/libro-context-key.d.ts.map +1 -0
- package/es/libro-context-key.js +80 -0
- package/es/libro-keybind-registry.d.ts +5 -0
- package/es/libro-keybind-registry.d.ts.map +1 -0
- package/es/libro-keybind-registry.js +68 -0
- package/es/libro-model.d.ts +129 -0
- package/es/libro-model.d.ts.map +1 -0
- package/es/libro-model.js +803 -0
- package/es/libro-protocol.d.ts +241 -0
- package/es/libro-protocol.d.ts.map +1 -0
- package/es/libro-protocol.js +34 -0
- package/es/libro-service.d.ts +34 -0
- package/es/libro-service.d.ts.map +1 -0
- package/es/libro-service.js +180 -0
- package/es/libro-view-tracker.d.ts +6 -0
- package/es/libro-view-tracker.d.ts.map +1 -0
- package/es/libro-view-tracker.js +13 -0
- package/es/libro-view.d.ts +151 -0
- package/es/libro-view.d.ts.map +1 -0
- package/es/libro-view.js +1963 -0
- package/es/material-from-designer.d.ts +27 -0
- package/es/material-from-designer.d.ts.map +1 -0
- package/es/material-from-designer.js +550 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +55 -0
- package/es/output/index.d.ts +6 -0
- package/es/output/index.d.ts.map +1 -0
- package/es/output/index.js +5 -0
- package/es/output/output-area.d.ts +51 -0
- package/es/output/output-area.d.ts.map +1 -0
- package/es/output/output-area.js +346 -0
- package/es/output/output-contribution.d.ts +11 -0
- package/es/output/output-contribution.d.ts.map +1 -0
- package/es/output/output-contribution.js +31 -0
- package/es/output/output-model.d.ts +27 -0
- package/es/output/output-model.d.ts.map +1 -0
- package/es/output/output-model.js +95 -0
- package/es/output/output-module.d.ts +3 -0
- package/es/output/output-module.d.ts.map +1 -0
- package/es/output/output-module.js +6 -0
- package/es/output/output-protocol.d.ts +130 -0
- package/es/output/output-protocol.d.ts.map +1 -0
- package/es/output/output-protocol.js +18 -0
- package/es/slot/index.d.ts +5 -0
- package/es/slot/index.d.ts.map +1 -0
- package/es/slot/index.js +4 -0
- package/es/slot/libro-slot-manager.d.ts +13 -0
- package/es/slot/libro-slot-manager.d.ts.map +1 -0
- package/es/slot/libro-slot-manager.js +57 -0
- package/es/slot/libro-slot-protocol.d.ts +19 -0
- package/es/slot/libro-slot-protocol.d.ts.map +1 -0
- package/es/slot/libro-slot-protocol.js +5 -0
- package/es/slot/libro-slot-view.d.ts +9 -0
- package/es/slot/libro-slot-view.d.ts.map +1 -0
- package/es/slot/libro-slot-view.js +81 -0
- package/es/slot/module.d.ts +3 -0
- package/es/slot/module.d.ts.map +1 -0
- package/es/slot/module.js +5 -0
- package/es/theme/libro-color-registry.d.ts +6 -0
- package/es/theme/libro-color-registry.d.ts.map +1 -0
- package/es/theme/libro-color-registry.js +494 -0
- package/es/toolbar/change-cell-to-selector.d.ts +5 -0
- package/es/toolbar/change-cell-to-selector.d.ts.map +1 -0
- package/es/toolbar/change-cell-to-selector.js +48 -0
- package/es/toolbar/hide-all-selector.d.ts +5 -0
- package/es/toolbar/hide-all-selector.d.ts.map +1 -0
- package/es/toolbar/hide-all-selector.js +99 -0
- package/es/toolbar/index.d.ts +4 -0
- package/es/toolbar/index.d.ts.map +1 -0
- package/es/toolbar/index.js +3 -0
- package/es/toolbar/index.less +59 -0
- package/es/toolbar/libro-toolbar-protocol.d.ts +4 -0
- package/es/toolbar/libro-toolbar-protocol.d.ts.map +1 -0
- package/es/toolbar/libro-toolbar-protocol.js +1 -0
- package/es/toolbar/libro-toolbar.d.ts +8 -0
- package/es/toolbar/libro-toolbar.d.ts.map +1 -0
- package/es/toolbar/libro-toolbar.js +223 -0
- package/es/toolbar/module.d.ts +3 -0
- package/es/toolbar/module.d.ts.map +1 -0
- package/es/toolbar/module.js +5 -0
- package/es/toolbar/restart-clear-outputs-contribution.d.ts +5 -0
- package/es/toolbar/restart-clear-outputs-contribution.d.ts.map +1 -0
- package/es/toolbar/restart-clear-outputs-contribution.js +23 -0
- package/es/toolbar/restart-clear-outputs-modal.d.ts +6 -0
- package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -0
- package/es/toolbar/restart-clear-outputs-modal.js +30 -0
- package/es/toolbar/save-icon.d.ts +3 -0
- package/es/toolbar/save-icon.d.ts.map +1 -0
- package/es/toolbar/save-icon.js +54 -0
- package/es/toolbar/shutdown-contribution.d.ts +5 -0
- package/es/toolbar/shutdown-contribution.d.ts.map +1 -0
- package/es/toolbar/shutdown-contribution.js +23 -0
- package/es/toolbar/shutdown-modal.d.ts +6 -0
- package/es/toolbar/shutdown-modal.d.ts.map +1 -0
- package/es/toolbar/shutdown-modal.js +30 -0
- package/es/toolbar/side-toolar-more-select.d.ts +4 -0
- package/es/toolbar/side-toolar-more-select.d.ts.map +1 -0
- package/es/toolbar/side-toolar-more-select.js +161 -0
- package/es/typings/index.d.ts +1 -0
- package/package.json +70 -0
- package/src/add-cell/index.less +38 -0
- package/src/add-cell/index.ts +3 -0
- package/src/add-cell/libro-add-cell-module.ts +9 -0
- package/src/add-cell/libro-add-cell-slot-contribution.ts +31 -0
- package/src/add-cell/libro-add-cell-view.tsx +101 -0
- package/src/cell/README.md +14 -0
- package/src/cell/index.ts +9 -0
- package/src/cell/libro-cell-contribution.ts +38 -0
- package/src/cell/libro-cell-model.ts +61 -0
- package/src/cell/libro-cell-module.ts +40 -0
- package/src/cell/libro-cell-protocol.ts +53 -0
- package/src/cell/libro-cell-service.ts +157 -0
- package/src/cell/libro-cell-view.tsx +128 -0
- package/src/cell/libro-edit-cell-view.tsx +60 -0
- package/src/cell/libro-executable-cell-model.ts +32 -0
- package/src/cell/libro-executable-cell-view.ts +74 -0
- package/src/cell/libro-markdown-cell-model.ts +20 -0
- package/src/collapse-service.ts +69 -0
- package/src/command/document-commands.ts +18 -0
- package/src/command/index.ts +6 -0
- package/src/command/kernel-command.ts +41 -0
- package/src/command/libro-command-contribution.ts +1339 -0
- package/src/command/libro-command-register.ts +171 -0
- package/src/command/module.ts +9 -0
- package/src/command/notebook-commands.ts +498 -0
- package/src/components/cell-protocol.ts +22 -0
- package/src/components/dnd-cell-item-render.tsx +308 -0
- package/src/components/dnd-component/custom-drag-layer.tsx +145 -0
- package/src/components/dnd-component/default-dnd-content.tsx +275 -0
- package/src/components/dnd-component/dnd-context.tsx +28 -0
- package/src/components/dnd-component/dnd-list.tsx +116 -0
- package/src/components/dnd-component/index.tsx +4 -0
- package/src/components/index.ts +5 -0
- package/src/components/libro-component.tsx +30 -0
- package/src/components/libro-side-toolbar-menu.tsx +82 -0
- package/src/components/libro-view-header.tsx +33 -0
- package/src/configuration/libro-configuration-contribution.ts +29 -0
- package/src/configuration/libro-configuration.ts +88 -0
- package/src/content/index.ts +4 -0
- package/src/content/libro-content-contribution.ts +17 -0
- package/src/content/libro-content-module.ts +9 -0
- package/src/content/libro-content-protocol.ts +8 -0
- package/src/content/libro-content-service.ts +30 -0
- package/src/index.less +682 -0
- package/src/index.tsx +19 -0
- package/src/libro-context-key.ts +80 -0
- package/src/libro-keybind-registry.ts +43 -0
- package/src/libro-model.ts +614 -0
- package/src/libro-protocol.ts +322 -0
- package/src/libro-service.ts +121 -0
- package/src/libro-view-tracker.ts +9 -0
- package/src/libro-view.tsx +1399 -0
- package/src/material-from-designer.tsx +457 -0
- package/src/module.ts +90 -0
- package/src/output/index.ts +5 -0
- package/src/output/output-area.tsx +255 -0
- package/src/output/output-contribution.ts +18 -0
- package/src/output/output-model.tsx +66 -0
- package/src/output/output-module.ts +10 -0
- package/src/output/output-protocol.ts +164 -0
- package/src/slot/index.ts +4 -0
- package/src/slot/libro-slot-manager.ts +37 -0
- package/src/slot/libro-slot-protocol.ts +28 -0
- package/src/slot/libro-slot-view.tsx +51 -0
- package/src/slot/module.ts +9 -0
- package/src/theme/libro-color-registry.ts +371 -0
- package/src/toolbar/change-cell-to-selector.tsx +58 -0
- package/src/toolbar/hide-all-selector.tsx +126 -0
- package/src/toolbar/index.less +59 -0
- package/src/toolbar/index.ts +3 -0
- package/src/toolbar/libro-toolbar-protocol.ts +4 -0
- package/src/toolbar/libro-toolbar.tsx +192 -0
- package/src/toolbar/module.ts +11 -0
- package/src/toolbar/restart-clear-outputs-contribution.tsx +10 -0
- package/src/toolbar/restart-clear-outputs-modal.tsx +37 -0
- package/src/toolbar/save-icon.tsx +47 -0
- package/src/toolbar/shutdown-contribution.tsx +10 -0
- package/src/toolbar/shutdown-modal.tsx +37 -0
- package/src/toolbar/side-toolar-more-select.tsx +172 -0
- package/src/typings/index.d.ts +1 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { useConfigurationValue } from '@difizen/mana-app';
|
|
2
|
+
import { getOrigin, useInject, ViewInstance } from '@difizen/mana-app';
|
|
3
|
+
import type { Identifier } from 'dnd-core';
|
|
4
|
+
import React, { useEffect, useRef, useState, useCallback, forwardRef } from 'react';
|
|
5
|
+
import { useDrag, useDragDropManager, useDrop } from 'react-dnd';
|
|
6
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
7
|
+
|
|
8
|
+
import { CellService } from '../../cell/index.js';
|
|
9
|
+
import { CellCollapsible } from '../../collapse-service.js';
|
|
10
|
+
import { isCellView, DragAreaKey } from '../../libro-protocol.js';
|
|
11
|
+
import type { CellView, DndContentProps } from '../../libro-protocol.js';
|
|
12
|
+
import { MultiSelectionWhenShiftClick } from '../../configuration/libro-configuration.js';
|
|
13
|
+
import type { LibroView } from '../../libro-view.js';
|
|
14
|
+
import { HolderOutlined, PlusOutlined } from '../../material-from-designer.js';
|
|
15
|
+
import { hasErrorOutput } from '../../output/index.js';
|
|
16
|
+
import { BetweenCellProvider } from '../cell-protocol.js';
|
|
17
|
+
|
|
18
|
+
export interface Dragparams {
|
|
19
|
+
cell: CellView;
|
|
20
|
+
index: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const DefaultDndContent: React.FC<DndContentProps> = ({ cell, index }) => {
|
|
24
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
25
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
26
|
+
const [multiSelectionWhenShiftClick] = useConfigurationValue(
|
|
27
|
+
MultiSelectionWhenShiftClick,
|
|
28
|
+
);
|
|
29
|
+
const BetweenCellContent = useInject<BetweenCellProvider>(BetweenCellProvider);
|
|
30
|
+
const cellService = useInject<CellService>(CellService);
|
|
31
|
+
const dragDropManager = useDragDropManager();
|
|
32
|
+
const dragDropMonitor = dragDropManager.getMonitor();
|
|
33
|
+
const ItemRender = getOrigin(instance.dndItemRender);
|
|
34
|
+
const handleFocus = useCallback(
|
|
35
|
+
(e: React.FocusEvent<HTMLElement>) => {
|
|
36
|
+
const className = (e.target as HTMLDivElement).className;
|
|
37
|
+
if (
|
|
38
|
+
(e.target as HTMLDivElement).tagName === 'svg' ||
|
|
39
|
+
(className &&
|
|
40
|
+
className &&
|
|
41
|
+
typeof className === 'string' &&
|
|
42
|
+
(className.includes('mana-toolbar-item') ||
|
|
43
|
+
className.includes('mana-toolbar')))
|
|
44
|
+
) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
instance.model.selectCell(cell);
|
|
48
|
+
instance.model.selections = [];
|
|
49
|
+
if (cell.shouldEnterEditorMode(e)) {
|
|
50
|
+
instance.enterEditMode();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
[instance, cell],
|
|
54
|
+
);
|
|
55
|
+
const handleMouseDown = useCallback(
|
|
56
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
57
|
+
if (e.shiftKey && multiSelectionWhenShiftClick) {
|
|
58
|
+
//按shift键时为多选cell
|
|
59
|
+
instance.extendContiguousSelectionTo(index);
|
|
60
|
+
instance.model.mouseMode = 'multipleSelection';
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
instance.model.mouseMode = 'mouseDown';
|
|
64
|
+
},
|
|
65
|
+
[multiSelectionWhenShiftClick, instance, index],
|
|
66
|
+
);
|
|
67
|
+
const handleMouseUp = useCallback(() => {
|
|
68
|
+
if (
|
|
69
|
+
instance.model.mouseMode === 'multipleSelection' ||
|
|
70
|
+
instance.model.mouseMode === 'drag'
|
|
71
|
+
) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
instance.model.selectCell(cell);
|
|
75
|
+
instance.model.selections = [];
|
|
76
|
+
}, [instance, cell]);
|
|
77
|
+
|
|
78
|
+
const [{ isDrag }, drag, preview] = useDrag(
|
|
79
|
+
{
|
|
80
|
+
type: DragAreaKey,
|
|
81
|
+
item: { cell, index },
|
|
82
|
+
collect: (monitor) => ({
|
|
83
|
+
isDrag: monitor.isDragging(),
|
|
84
|
+
}),
|
|
85
|
+
end() {
|
|
86
|
+
instance.isDragging = false;
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
[cell, index],
|
|
90
|
+
);
|
|
91
|
+
dragDropMonitor.subscribeToStateChange(() => {
|
|
92
|
+
instance.isDragging = dragDropMonitor.isDragging();
|
|
93
|
+
});
|
|
94
|
+
const libroViewContent = instance.container?.current?.getElementsByClassName(
|
|
95
|
+
'libro-view-content',
|
|
96
|
+
)[0] as HTMLElement;
|
|
97
|
+
const scrollTimer = useRef<null | NodeJS.Timeout>(null);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
scrollTimer.current = setInterval(() => {
|
|
100
|
+
const currentOffset = dragDropMonitor.getClientOffset();
|
|
101
|
+
if (libroViewContent && instance.isDragging && currentOffset) {
|
|
102
|
+
const libroViewClientRect = libroViewContent.getBoundingClientRect();
|
|
103
|
+
const { top, bottom } = libroViewClientRect;
|
|
104
|
+
const { y } = currentOffset;
|
|
105
|
+
const topLimit = top + 30;
|
|
106
|
+
const bottomLimit = bottom - 50;
|
|
107
|
+
if (y < topLimit) {
|
|
108
|
+
libroViewContent.scrollTop -= 0.5;
|
|
109
|
+
} else if (y > bottomLimit) {
|
|
110
|
+
libroViewContent.scrollTop += 0.5;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, 10);
|
|
114
|
+
return () => {
|
|
115
|
+
if (scrollTimer.current) {
|
|
116
|
+
clearInterval(scrollTimer.current);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
// This gets called after every render, by default
|
|
124
|
+
// (the first one, and every one after that)
|
|
125
|
+
|
|
126
|
+
// Use empty image as a drag preview so browsers don't draw it
|
|
127
|
+
// and we can draw whatever we want on the custom drag layer instead.
|
|
128
|
+
preview(getEmptyImage(), {
|
|
129
|
+
// IE fallback: specify that we'd rather screenshot the node
|
|
130
|
+
// when it already knows it's being dragged so we can hide it with CSS.
|
|
131
|
+
captureDraggingState: true,
|
|
132
|
+
});
|
|
133
|
+
}, [preview]);
|
|
134
|
+
|
|
135
|
+
const [{ handlerId, isDragOver }, drop] = useDrop<
|
|
136
|
+
Dragparams,
|
|
137
|
+
void,
|
|
138
|
+
{
|
|
139
|
+
handlerId: Identifier | null;
|
|
140
|
+
isDragOver: boolean;
|
|
141
|
+
}
|
|
142
|
+
>({
|
|
143
|
+
accept: DragAreaKey,
|
|
144
|
+
drop(item, monitor) {
|
|
145
|
+
cellService
|
|
146
|
+
.getOrCreateView(
|
|
147
|
+
{
|
|
148
|
+
...item.cell.model.options,
|
|
149
|
+
modelId: item.cell.model.id,
|
|
150
|
+
singleSelectionDragPreview: true,
|
|
151
|
+
},
|
|
152
|
+
item.cell.parent.id,
|
|
153
|
+
)
|
|
154
|
+
.then((view) => {
|
|
155
|
+
view.dispose();
|
|
156
|
+
return;
|
|
157
|
+
})
|
|
158
|
+
.catch(() => {
|
|
159
|
+
//
|
|
160
|
+
});
|
|
161
|
+
if (isCellView(item.cell)) {
|
|
162
|
+
const didDrop = monitor.didDrop();
|
|
163
|
+
if (didDrop) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const dragIndex = instance.findCellIndex(item.cell);
|
|
167
|
+
const dropIndex = instance.findCellIndex(cell);
|
|
168
|
+
if (instance.model.selections.length > 0) {
|
|
169
|
+
const isDragInSelections =
|
|
170
|
+
instance.model.selections.findIndex(
|
|
171
|
+
(selection) => selection.id === item.cell.id,
|
|
172
|
+
) > -1
|
|
173
|
+
? true
|
|
174
|
+
: false;
|
|
175
|
+
const isDropInSelections =
|
|
176
|
+
instance.model.selections.findIndex(
|
|
177
|
+
(selection) => selection.id === cell.id,
|
|
178
|
+
) > -1
|
|
179
|
+
? true
|
|
180
|
+
: false;
|
|
181
|
+
if (isDragInSelections && isDropInSelections) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (isDragInSelections) {
|
|
185
|
+
instance.model.exchangeCells(instance.model.selections, dropIndex);
|
|
186
|
+
instance.model.scrollToView(cell);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (dragIndex < dropIndex) {
|
|
191
|
+
instance.model.exchangeCell(dragIndex, dropIndex - 1);
|
|
192
|
+
instance.model.scrollToView(cell);
|
|
193
|
+
}
|
|
194
|
+
if (dragIndex > dropIndex) {
|
|
195
|
+
instance.model.exchangeCell(dragIndex, dropIndex);
|
|
196
|
+
instance.model.scrollToView(cell);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
},
|
|
201
|
+
collect(monitor) {
|
|
202
|
+
return {
|
|
203
|
+
isDragOver: monitor.isOver(),
|
|
204
|
+
canDrop: monitor.canDrop(),
|
|
205
|
+
handlerId: monitor.getHandlerId(),
|
|
206
|
+
};
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
const opacity = isDrag ? 0.4 : 1;
|
|
210
|
+
if (!instance.model.readOnly) {
|
|
211
|
+
drop(ref);
|
|
212
|
+
}
|
|
213
|
+
if (isDrag) {
|
|
214
|
+
instance.model.mouseMode = 'drag';
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const isSelected = instance.isSelected(cell);
|
|
218
|
+
// let isMouseOver = false;
|
|
219
|
+
const [isMouseOverDragArea, setIsMouseOverDragArea] = useState(false);
|
|
220
|
+
const hasCellHidden = cell.hasCellHidden();
|
|
221
|
+
const hasErrorOutputs = hasErrorOutput(cell);
|
|
222
|
+
const isCollapsible = CellCollapsible.is(cell);
|
|
223
|
+
return (
|
|
224
|
+
<div
|
|
225
|
+
className={`libro-dnd-cell-container ${isSelected ? 'selected' : ''} ${
|
|
226
|
+
hasCellHidden ? 'hidden' : ''
|
|
227
|
+
}`}
|
|
228
|
+
data-handler-id={handlerId}
|
|
229
|
+
style={{ opacity }}
|
|
230
|
+
ref={ref}
|
|
231
|
+
id={cell.id}
|
|
232
|
+
>
|
|
233
|
+
<BetweenCellContent index={index} addCell={cell.parent.addCellAbove} />
|
|
234
|
+
{isDragOver && <div className="libro-drag-hoverline" />}
|
|
235
|
+
{isMouseOverDragArea && <HolderOutlined className="libro-handle-style" />}
|
|
236
|
+
<div
|
|
237
|
+
className="libro-drag-area"
|
|
238
|
+
ref={drag}
|
|
239
|
+
onMouseDown={handleMouseDown}
|
|
240
|
+
onMouseUp={handleMouseUp}
|
|
241
|
+
onMouseOver={() => setIsMouseOverDragArea(true)}
|
|
242
|
+
onMouseLeave={() => setIsMouseOverDragArea(false)}
|
|
243
|
+
/>
|
|
244
|
+
<div
|
|
245
|
+
tabIndex={-1}
|
|
246
|
+
onFocus={handleFocus}
|
|
247
|
+
// onClick={e => e.preventDefault()}
|
|
248
|
+
className={`libro-dnd-cell-content ${hasErrorOutputs ? 'error' : ''}`}
|
|
249
|
+
>
|
|
250
|
+
<ItemRender
|
|
251
|
+
isDragOver={!!isDragOver}
|
|
252
|
+
isDrag={!!isDrag}
|
|
253
|
+
cell={cell}
|
|
254
|
+
isMouseOverDragArea={isMouseOverDragArea}
|
|
255
|
+
/>
|
|
256
|
+
</div>
|
|
257
|
+
{isCollapsible && cell.headingCollapsed && cell.collapsibleChildNumber > 0 && (
|
|
258
|
+
<div className="libro-cell-collapsed-expander">
|
|
259
|
+
<button
|
|
260
|
+
className="libro-cell-expand-button"
|
|
261
|
+
onClick={() => instance.collapseCell(cell, false)}
|
|
262
|
+
>
|
|
263
|
+
<PlusOutlined className="" /> {cell.collapsibleChildNumber} cell hidden
|
|
264
|
+
</button>
|
|
265
|
+
</div>
|
|
266
|
+
)}
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export const LibroBetweenCellContent: BetweenCellProvider = forwardRef(
|
|
272
|
+
function LibroBetweenCellContent() {
|
|
273
|
+
return null;
|
|
274
|
+
},
|
|
275
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ViewInstance } from '@difizen/mana-app';
|
|
2
|
+
import { getOrigin, useInject } from '@difizen/mana-app';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
import { DndProvider } from 'react-dnd';
|
|
5
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
6
|
+
|
|
7
|
+
import type { LibroView } from '../../libro-view.js';
|
|
8
|
+
|
|
9
|
+
export const DndContext: FC<any> = ({ children }) => {
|
|
10
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
11
|
+
|
|
12
|
+
if (!instance.isVisible && !instance.model.dndAreaNullEnable) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return (
|
|
16
|
+
<DndProvider
|
|
17
|
+
backend={HTML5Backend}
|
|
18
|
+
options={{
|
|
19
|
+
rootElement:
|
|
20
|
+
instance.isVisible || !instance.model.dndAreaNullEnable
|
|
21
|
+
? getOrigin(instance).container?.current
|
|
22
|
+
: null,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</DndProvider>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { getOrigin, useInject, useObserve, ViewInstance } from '@difizen/mana-app';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
import { forwardRef, memo } from 'react';
|
|
4
|
+
import type { XYCoord } from 'react-dnd';
|
|
5
|
+
import { useDrop } from 'react-dnd';
|
|
6
|
+
|
|
7
|
+
import { LibroCellService } from '../../cell/index.js';
|
|
8
|
+
import type { CellService } from '../../cell/index.js';
|
|
9
|
+
import { DragAreaKey, isCellView } from '../../libro-protocol.js';
|
|
10
|
+
import type { CellView, DndContentProps } from '../../libro-protocol.js';
|
|
11
|
+
import type { LibroView } from '../../libro-view.js';
|
|
12
|
+
|
|
13
|
+
import type { Dragparams } from './default-dnd-content.js';
|
|
14
|
+
|
|
15
|
+
const DndContent: FC<DndContentProps> = ({ cell, index, ...props }) => {
|
|
16
|
+
const observableCell = useObserve(cell);
|
|
17
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
18
|
+
const DndContentRender = instance.dndContentRender;
|
|
19
|
+
return (
|
|
20
|
+
<DndContentRender cell={observableCell} key={cell.id} index={index} {...props} />
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
const DndContentMemo = memo(DndContent);
|
|
24
|
+
|
|
25
|
+
export const DndCellContent = forwardRef<HTMLDivElement, { libroView: LibroView }>(
|
|
26
|
+
function DndCellContent({ libroView }, ref) {
|
|
27
|
+
const LoadingRender = getOrigin(libroView.loadingRender);
|
|
28
|
+
const cells = libroView.model.getCells().reduce<CellView[]>(function (a, b) {
|
|
29
|
+
if (a.indexOf(b) < 0) {
|
|
30
|
+
a.push(b);
|
|
31
|
+
}
|
|
32
|
+
return a;
|
|
33
|
+
}, []);
|
|
34
|
+
return (
|
|
35
|
+
<div className="libro-dnd-cells-container" ref={ref}>
|
|
36
|
+
{!libroView.model.isInitialized && <LoadingRender />}
|
|
37
|
+
{libroView.model.isInitialized &&
|
|
38
|
+
cells
|
|
39
|
+
.filter((cell) => cell.collapsedHidden === false)
|
|
40
|
+
.map((cell, index) => {
|
|
41
|
+
return <DndContentMemo cell={cell} key={cell.id} index={index} />;
|
|
42
|
+
})}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export const DndList = forwardRef<
|
|
49
|
+
HTMLDivElement,
|
|
50
|
+
{ libroView: LibroView; children: any }
|
|
51
|
+
>(function DndList({ libroView, children }) {
|
|
52
|
+
const cellService = useInject<CellService>(LibroCellService);
|
|
53
|
+
|
|
54
|
+
const [, drop] = useDrop<Dragparams>(() => ({
|
|
55
|
+
accept: DragAreaKey,
|
|
56
|
+
drop(item, dropMonitor) {
|
|
57
|
+
cellService
|
|
58
|
+
.getOrCreateView(
|
|
59
|
+
{
|
|
60
|
+
...item.cell.model.options,
|
|
61
|
+
modelId: item.cell.model.id,
|
|
62
|
+
singleSelectionDragPreview: true,
|
|
63
|
+
},
|
|
64
|
+
item.cell.parent.id,
|
|
65
|
+
)
|
|
66
|
+
.then((view) => {
|
|
67
|
+
return view.dispose();
|
|
68
|
+
})
|
|
69
|
+
.catch(() => {
|
|
70
|
+
//
|
|
71
|
+
});
|
|
72
|
+
if (isCellView(item.cell)) {
|
|
73
|
+
const didDrop = dropMonitor.didDrop();
|
|
74
|
+
if (didDrop) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// Determine mouse position
|
|
78
|
+
const clientOffset = dropMonitor.getClientOffset();
|
|
79
|
+
const clientOffsetY = (clientOffset as XYCoord).y;
|
|
80
|
+
const dragIndex = libroView.findCellIndex(item.cell);
|
|
81
|
+
// Determine rectangle on screen
|
|
82
|
+
const lastCell =
|
|
83
|
+
libroView.model.getCells()[libroView.model.getCells().length - 1];
|
|
84
|
+
const lastCellOffsetY = lastCell.container?.current?.getBoundingClientRect().y;
|
|
85
|
+
if (lastCellOffsetY && clientOffsetY >= lastCellOffsetY) {
|
|
86
|
+
if (libroView.model.selections.length > 0) {
|
|
87
|
+
const isDragInSelections =
|
|
88
|
+
libroView.model.selections.findIndex(
|
|
89
|
+
(selection) => selection.id === item.cell.id,
|
|
90
|
+
) > -1
|
|
91
|
+
? true
|
|
92
|
+
: false;
|
|
93
|
+
if (isDragInSelections) {
|
|
94
|
+
libroView.model.exchangeCells(
|
|
95
|
+
libroView.model.selections,
|
|
96
|
+
libroView.model.cells.length,
|
|
97
|
+
);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
libroView.model.exchangeCell(dragIndex, libroView.model.cells.length - 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Determine mouse position
|
|
105
|
+
|
|
106
|
+
return;
|
|
107
|
+
},
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<div className="libro-dnd-list-container" ref={drop}>
|
|
112
|
+
<DndCellContent libroView={libroView} />
|
|
113
|
+
{children}
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ViewRender } from '@difizen/mana-app';
|
|
2
|
+
import { useInject } from '@difizen/mana-app';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { NotebookOption, NotebookView } from '../libro-protocol.js';
|
|
6
|
+
import { LibroService } from '../libro-service.js';
|
|
7
|
+
|
|
8
|
+
export function LibroComponent(props: { options: NotebookOption }) {
|
|
9
|
+
const libroService = useInject(LibroService);
|
|
10
|
+
const [libroView, setLibroView] = useState<NotebookView | undefined>(undefined);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
libroService
|
|
14
|
+
.getOrCreateView(props.options)
|
|
15
|
+
.then((view) => {
|
|
16
|
+
if (!view) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
setLibroView(view);
|
|
20
|
+
return;
|
|
21
|
+
})
|
|
22
|
+
.catch(() => {
|
|
23
|
+
//
|
|
24
|
+
});
|
|
25
|
+
}, [props.options, libroService]);
|
|
26
|
+
if (!libroView || !libroView.view) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return <ViewRender view={libroView} />;
|
|
30
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Toolbar } from '@difizen/mana-app';
|
|
2
|
+
import {
|
|
3
|
+
CommandRegistry,
|
|
4
|
+
getOrigin,
|
|
5
|
+
ToolbarInstance,
|
|
6
|
+
useInject,
|
|
7
|
+
} from '@difizen/mana-app';
|
|
8
|
+
import { Menu, MenuContext } from '@difizen/mana-react';
|
|
9
|
+
import type { ReactNode } from 'react';
|
|
10
|
+
|
|
11
|
+
import type { LibroToolbarArags } from '../toolbar/index.js';
|
|
12
|
+
|
|
13
|
+
export type LibroSideToolbarMenuItemType = {
|
|
14
|
+
id: string;
|
|
15
|
+
label: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* When extra, group means that the item will be located in a submenu(s) of the `...` dropdown.
|
|
18
|
+
* The submenu's title is named by the name in group, e.g. ['menu', 'submenu'].
|
|
19
|
+
*/
|
|
20
|
+
readonly group?: string | string[];
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
interface LibroSideToolbarMenuInlinesProps {
|
|
25
|
+
items: LibroSideToolbarMenuItemType[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const LibroSideToolbarMenuInlines: React.FC<
|
|
29
|
+
LibroSideToolbarMenuInlinesProps
|
|
30
|
+
> = ({ items }: LibroSideToolbarMenuInlinesProps) => {
|
|
31
|
+
const command = useInject(CommandRegistry);
|
|
32
|
+
const toolbar = useInject<Toolbar>(ToolbarInstance);
|
|
33
|
+
const data = toolbar.currentArgs as LibroToolbarArags;
|
|
34
|
+
const args = getOrigin(data) || [];
|
|
35
|
+
if (!items.length) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const nodes: React.ReactNode[] = [];
|
|
39
|
+
let group: string | undefined = undefined;
|
|
40
|
+
const baseCls = 'mana-menu';
|
|
41
|
+
const contextValue: MenuContext.Context = {
|
|
42
|
+
prefixCls: baseCls,
|
|
43
|
+
};
|
|
44
|
+
items.forEach((item) => {
|
|
45
|
+
let itemGroup: string | string[] | undefined = item.group;
|
|
46
|
+
if (itemGroup) {
|
|
47
|
+
itemGroup = typeof itemGroup === 'string' ? itemGroup : itemGroup[0];
|
|
48
|
+
}
|
|
49
|
+
if (nodes.length && itemGroup !== group) {
|
|
50
|
+
nodes.push(itemGroup && <Menu.Divider key={`${item.id}-divider`} />);
|
|
51
|
+
}
|
|
52
|
+
group = itemGroup;
|
|
53
|
+
nodes.push(
|
|
54
|
+
<Menu.Item
|
|
55
|
+
key={item.id}
|
|
56
|
+
onClick={() => {
|
|
57
|
+
command.executeCommand(item.id, ...args);
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{item.label}
|
|
61
|
+
</Menu.Item>,
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
return (
|
|
65
|
+
<div className="libro-toolbar-menu-inlines">
|
|
66
|
+
<MenuContext.Provider value={contextValue}>{nodes} </MenuContext.Provider>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
interface LibroSideToolbarMenuProps {
|
|
72
|
+
items: LibroSideToolbarMenuItemType[];
|
|
73
|
+
}
|
|
74
|
+
export const LibroSideToolbarMenu: React.FC<LibroSideToolbarMenuProps> = ({
|
|
75
|
+
items,
|
|
76
|
+
}: LibroSideToolbarMenuProps) => {
|
|
77
|
+
return (
|
|
78
|
+
<div className="libro-side-toolbar-menu">
|
|
79
|
+
<LibroSideToolbarMenuInlines items={items} />
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { ToolbarRender, useInject, ViewInstance } from '@difizen/mana-app';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
|
|
6
|
+
import { LibroToolbarArea } from '../libro-protocol.js';
|
|
7
|
+
import type { LibroView } from '../libro-view.js';
|
|
8
|
+
|
|
9
|
+
export const LibroViewHeader: FC = () => {
|
|
10
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
11
|
+
const headerLeftArgs = useMemo(() => {
|
|
12
|
+
return [instance.model.active, instance, LibroToolbarArea.HeaderLeft];
|
|
13
|
+
}, [instance.model.active, instance]);
|
|
14
|
+
const headerCenterArgs = useMemo(() => {
|
|
15
|
+
return [instance.model.active, instance, LibroToolbarArea.HeaderCenter];
|
|
16
|
+
}, [instance.model.active, instance]);
|
|
17
|
+
const headerRightArgs = useMemo(() => {
|
|
18
|
+
return [instance.model.active, instance, LibroToolbarArea.HeaderRight];
|
|
19
|
+
}, [instance.model.active, instance]);
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<div className="libro-header-left">
|
|
23
|
+
<ToolbarRender data={headerLeftArgs} />
|
|
24
|
+
</div>
|
|
25
|
+
<div className="libro-header-center">
|
|
26
|
+
<ToolbarRender data={headerCenterArgs} />
|
|
27
|
+
</div>
|
|
28
|
+
<div className="libro-header-right">
|
|
29
|
+
<ToolbarRender data={headerRightArgs} />
|
|
30
|
+
</div>
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ConfigurationContribution } from '@difizen/mana-app';
|
|
2
|
+
import { singleton } from '@difizen/mana-app';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
CellSideToolbarVisible,
|
|
6
|
+
CellTopToolbarSetting,
|
|
7
|
+
HeaderToolbarVisible,
|
|
8
|
+
AutoInsertWhenNoCell,
|
|
9
|
+
EnterEditModeWhenAddCell,
|
|
10
|
+
CollapserClickActive,
|
|
11
|
+
MultiSelectionWhenShiftClick,
|
|
12
|
+
RightContentFixed,
|
|
13
|
+
} from './libro-configuration.js';
|
|
14
|
+
|
|
15
|
+
@singleton({ contrib: ConfigurationContribution })
|
|
16
|
+
export class LibroConfigurationContribution implements ConfigurationContribution {
|
|
17
|
+
registerConfigurations() {
|
|
18
|
+
return [
|
|
19
|
+
HeaderToolbarVisible,
|
|
20
|
+
CellTopToolbarSetting,
|
|
21
|
+
CellSideToolbarVisible,
|
|
22
|
+
AutoInsertWhenNoCell,
|
|
23
|
+
EnterEditModeWhenAddCell,
|
|
24
|
+
CollapserClickActive,
|
|
25
|
+
MultiSelectionWhenShiftClick,
|
|
26
|
+
RightContentFixed,
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ConfigurationNode } from '@difizen/mana-app';
|
|
2
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
3
|
+
|
|
4
|
+
export const HeaderToolbarVisible: ConfigurationNode<boolean> = {
|
|
5
|
+
id: 'libro.header.toolbar',
|
|
6
|
+
description: l10n.t('是否显示libro顶部工具栏'),
|
|
7
|
+
title: l10n.t('顶部工具栏'),
|
|
8
|
+
type: 'checkbox',
|
|
9
|
+
defaultValue: true,
|
|
10
|
+
schema: {
|
|
11
|
+
type: 'boolean',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const CellTopToolbarSetting: ConfigurationNode<boolean> = {
|
|
16
|
+
id: 'libro.cell.toptoolbar',
|
|
17
|
+
description: l10n.t('是否显示cell顶部工具栏'),
|
|
18
|
+
title: l10n.t('cell顶部工具栏'),
|
|
19
|
+
type: 'checkbox',
|
|
20
|
+
defaultValue: true,
|
|
21
|
+
schema: {
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const CellSideToolbarVisible: ConfigurationNode<boolean> = {
|
|
27
|
+
id: 'libro.cell.sidetoolbar',
|
|
28
|
+
description: l10n.t('是否显示cell侧边工具栏'),
|
|
29
|
+
title: l10n.t('cell侧边工具栏'),
|
|
30
|
+
type: 'checkbox',
|
|
31
|
+
defaultValue: true,
|
|
32
|
+
schema: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const AutoInsertWhenNoCell: ConfigurationNode<boolean> = {
|
|
38
|
+
id: 'libro.command.insertcellbelow',
|
|
39
|
+
description: l10n.t('没有cell时是否默认创建cell'),
|
|
40
|
+
title: l10n.t('默认创建cell'),
|
|
41
|
+
type: 'checkbox',
|
|
42
|
+
defaultValue: true,
|
|
43
|
+
schema: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const EnterEditModeWhenAddCell: ConfigurationNode<boolean> = {
|
|
49
|
+
id: 'libro.command.entereditmodewhenaddcell',
|
|
50
|
+
description: l10n.t('增加cell操作默认进入编辑态'),
|
|
51
|
+
title: l10n.t('默认进入编辑态'),
|
|
52
|
+
type: 'checkbox',
|
|
53
|
+
defaultValue: true,
|
|
54
|
+
schema: {
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
export const CollapserClickActive: ConfigurationNode<boolean> = {
|
|
59
|
+
id: 'libro.command.collapserclickactive',
|
|
60
|
+
description: l10n.t('点击左侧长条是否可以隐藏与显示cell'),
|
|
61
|
+
title: l10n.t('默认点击长条可以隐藏与显示cell'),
|
|
62
|
+
type: 'checkbox',
|
|
63
|
+
defaultValue: true,
|
|
64
|
+
schema: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
export const MultiSelectionWhenShiftClick: ConfigurationNode<boolean> = {
|
|
69
|
+
id: 'libro.command.multiselectionwhenshiftclick',
|
|
70
|
+
description: l10n.t('按住shift键并点击拖拽区域可以进行多选'),
|
|
71
|
+
title: l10n.t('默认按住shift键并点击拖拽区域可以进行多选'),
|
|
72
|
+
type: 'checkbox',
|
|
73
|
+
defaultValue: true,
|
|
74
|
+
schema: {
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const RightContentFixed: ConfigurationNode<boolean> = {
|
|
80
|
+
id: 'libro.right.content.fixed',
|
|
81
|
+
description: l10n.t('libroview的右边栏是否相对固定'),
|
|
82
|
+
title: l10n.t('右侧内容是否相对固定'),
|
|
83
|
+
type: 'checkbox',
|
|
84
|
+
defaultValue: false,
|
|
85
|
+
schema: {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
},
|
|
88
|
+
};
|