onchain-lexical-instance 0.0.3 → 0.0.4

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.
@@ -1563,8 +1563,8 @@ function isFixedAddress(instance) {
1563
1563
  return !!instance && Object.keys(instance).length === 1 && typeof instance.value === 'object';
1564
1564
  }
1565
1565
 
1566
- var css_248z$5 = ".styles-module_left__CN0nC{align-items:center;display:flex;flex-direction:column;left:0;position:absolute;transform:translate(-26px);user-select:none;width:26px}.styles-module_left__CN0nC .styles-module_link__M-1Wq{margin-bottom:10px}.styles-module_left__CN0nC>*{align-items:center;display:inline-flex;justify-content:center}.styles-module_left__CN0nC>span:first-of-type{height:38px}.styles-module_right__sxVYl{align-items:center;display:inline-flex;height:40px;justify-content:flex-end;position:absolute;right:0;top:0;user-select:none}.styles-module_hasChildren__FqxrJ,.styles-module_hover__IeKlt:hover,.styles-module_selected__dpCTX{color:#0563b0}";
1567
- var Styles$5 = {"left":"styles-module_left__CN0nC","link":"styles-module_link__M-1Wq","right":"styles-module_right__sxVYl","selected":"styles-module_selected__dpCTX","hasChildren":"styles-module_hasChildren__FqxrJ","hover":"styles-module_hover__IeKlt"};
1566
+ var css_248z$5 = ".styles-module_left__CN0nC{align-items:center;display:flex;flex-direction:column;left:0;position:absolute;transform:translate(-26px);user-select:none;width:26px}.styles-module_left__CN0nC .styles-module_link__M-1Wq{margin-bottom:6px}.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div{position:relative}.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div>i{align-items:center;background-color:#0563b0;border-radius:50%;bottom:-2px;color:#fff;display:flex;font-size:10px;font-style:normal;height:12px;justify-content:center;position:absolute;right:-2px;width:12px}.styles-module_left__CN0nC .styles-module_hiddenLinkCount__ThNp5>button>span>div>i,.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div>i:empty{display:none}.styles-module_left__CN0nC>*{align-items:center;display:inline-flex;justify-content:center}.styles-module_left__CN0nC>span:first-of-type{height:38px}.styles-module_right__sxVYl{align-items:center;display:inline-flex;height:40px;justify-content:flex-end;position:absolute;right:0;top:0;user-select:none}.styles-module_hasChildren__FqxrJ,.styles-module_hover__IeKlt:hover,.styles-module_selected__dpCTX{color:#0563b0}";
1567
+ var Styles$5 = {"left":"styles-module_left__CN0nC","link":"styles-module_link__M-1Wq","hiddenLinkCount":"styles-module_hiddenLinkCount__ThNp5","right":"styles-module_right__sxVYl","selected":"styles-module_selected__dpCTX","hasChildren":"styles-module_hasChildren__FqxrJ","hover":"styles-module_hover__IeKlt"};
1568
1568
  styleInject(css_248z$5);
1569
1569
 
1570
1570
  /**
@@ -1585,11 +1585,13 @@ const Bar = props => {
1585
1585
  const {
1586
1586
  preview,
1587
1587
  selectedInstance,
1588
- getInstanceIcon
1588
+ getInstanceIcon,
1589
+ components
1589
1590
  } = instanceConfig.useInstanceConfig();
1590
1591
  const {
1591
1592
  extra
1592
1593
  } = settings.useSettings();
1594
+ const [open, setOpen] = React.useState(false);
1593
1595
 
1594
1596
  // icon-front-link1
1595
1597
  const isSelected = React.useMemo(() => {
@@ -1628,6 +1630,11 @@ const Bar = props => {
1628
1630
  }
1629
1631
  return 'demand1';
1630
1632
  }, [instance]);
1633
+ const Components = React.useMemo(() => {
1634
+ return {
1635
+ ...components
1636
+ };
1637
+ }, [components]);
1631
1638
  const hasChildren = !!instance?.children?.length || instance?.insBom;
1632
1639
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1633
1640
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -1637,10 +1644,31 @@ const Bar = props => {
1637
1644
  className: hasChildren ? Styles$5.hasChildren : undefined,
1638
1645
  type: `icon-front-${icon}`
1639
1646
  }), !preview && extra.showLeftToolbar !== false ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1640
- children: [/*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
1641
- className: `${Styles$5.hover} ${Styles$5.link}`,
1642
- type: "icon-front-link1"
1647
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
1648
+ className: `${Styles$5.link} ${open ? Styles$5.hiddenLinkCount : ''}`,
1649
+ children: /*#__PURE__*/jsxRuntime.jsx(DropDown, {
1650
+ arrow: true,
1651
+ showIcon: false,
1652
+ disabled: !instance?.trackLinkCount,
1653
+ stopCloseOnClickSelf: true,
1654
+ buttonLabel:
1655
+ /*#__PURE__*/
1656
+ // [TODO] 显示 trackLinkCount
1657
+ jsxRuntime.jsxs("div", {
1658
+ children: [/*#__PURE__*/jsxRuntime.jsx("i", {
1659
+ children: instance?.trackLinkCount || ''
1660
+ }), /*#__PURE__*/jsxRuntime.jsx(Icon.StaticIcon, {
1661
+ className: `${Styles$5.hover}`,
1662
+ type: "icon-front-link1"
1663
+ })]
1664
+ }),
1665
+ onOpen: setOpen,
1666
+ children: Components.TrackLinkList && instance ? /*#__PURE__*/jsxRuntime.jsx(Components.TrackLinkList, {
1667
+ number: instance.number
1668
+ }) : null
1669
+ })
1643
1670
  }), /*#__PURE__*/jsxRuntime.jsxs(DropDown, {
1671
+ arrow: true,
1644
1672
  showIcon: false,
1645
1673
  buttonLabel: /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
1646
1674
  className: Styles$5.hover,
@@ -21,7 +21,7 @@ import React__default, { useState, useEffect, useMemo, useCallback, useRef, Susp
21
21
  import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
22
22
  import { useSettings } from 'onchain-lexical-context/settings';
23
23
  import DropDown, { DropDownItem } from 'onchain-lexical-ui/DropDown';
24
- import { Icon } from 'onchain-lexical-ui/Icon';
24
+ import { Icon, StaticIcon } from 'onchain-lexical-ui/Icon';
25
25
  import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
26
26
  import { $textToRichNodes } from 'onchain-lexical-markdown';
27
27
  import { $setBlocksType } from '@lexical/selection';
@@ -1549,8 +1549,8 @@ function isFixedAddress(instance) {
1549
1549
  return !!instance && Object.keys(instance).length === 1 && typeof instance.value === 'object';
1550
1550
  }
1551
1551
 
1552
- var css_248z$5 = ".styles-module_left__CN0nC{align-items:center;display:flex;flex-direction:column;left:0;position:absolute;transform:translate(-26px);user-select:none;width:26px}.styles-module_left__CN0nC .styles-module_link__M-1Wq{margin-bottom:10px}.styles-module_left__CN0nC>*{align-items:center;display:inline-flex;justify-content:center}.styles-module_left__CN0nC>span:first-of-type{height:38px}.styles-module_right__sxVYl{align-items:center;display:inline-flex;height:40px;justify-content:flex-end;position:absolute;right:0;top:0;user-select:none}.styles-module_hasChildren__FqxrJ,.styles-module_hover__IeKlt:hover,.styles-module_selected__dpCTX{color:#0563b0}";
1553
- var Styles$5 = {"left":"styles-module_left__CN0nC","link":"styles-module_link__M-1Wq","right":"styles-module_right__sxVYl","selected":"styles-module_selected__dpCTX","hasChildren":"styles-module_hasChildren__FqxrJ","hover":"styles-module_hover__IeKlt"};
1552
+ var css_248z$5 = ".styles-module_left__CN0nC{align-items:center;display:flex;flex-direction:column;left:0;position:absolute;transform:translate(-26px);user-select:none;width:26px}.styles-module_left__CN0nC .styles-module_link__M-1Wq{margin-bottom:6px}.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div{position:relative}.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div>i{align-items:center;background-color:#0563b0;border-radius:50%;bottom:-2px;color:#fff;display:flex;font-size:10px;font-style:normal;height:12px;justify-content:center;position:absolute;right:-2px;width:12px}.styles-module_left__CN0nC .styles-module_hiddenLinkCount__ThNp5>button>span>div>i,.styles-module_left__CN0nC .styles-module_link__M-1Wq>button>span>div>i:empty{display:none}.styles-module_left__CN0nC>*{align-items:center;display:inline-flex;justify-content:center}.styles-module_left__CN0nC>span:first-of-type{height:38px}.styles-module_right__sxVYl{align-items:center;display:inline-flex;height:40px;justify-content:flex-end;position:absolute;right:0;top:0;user-select:none}.styles-module_hasChildren__FqxrJ,.styles-module_hover__IeKlt:hover,.styles-module_selected__dpCTX{color:#0563b0}";
1553
+ var Styles$5 = {"left":"styles-module_left__CN0nC","link":"styles-module_link__M-1Wq","hiddenLinkCount":"styles-module_hiddenLinkCount__ThNp5","right":"styles-module_right__sxVYl","selected":"styles-module_selected__dpCTX","hasChildren":"styles-module_hasChildren__FqxrJ","hover":"styles-module_hover__IeKlt"};
1554
1554
  styleInject(css_248z$5);
1555
1555
 
1556
1556
  /**
@@ -1571,11 +1571,13 @@ const Bar = props => {
1571
1571
  const {
1572
1572
  preview,
1573
1573
  selectedInstance,
1574
- getInstanceIcon
1574
+ getInstanceIcon,
1575
+ components
1575
1576
  } = useInstanceConfig();
1576
1577
  const {
1577
1578
  extra
1578
1579
  } = useSettings();
1580
+ const [open, setOpen] = useState(false);
1579
1581
 
1580
1582
  // icon-front-link1
1581
1583
  const isSelected = useMemo(() => {
@@ -1614,6 +1616,11 @@ const Bar = props => {
1614
1616
  }
1615
1617
  return 'demand1';
1616
1618
  }, [instance]);
1619
+ const Components = useMemo(() => {
1620
+ return {
1621
+ ...components
1622
+ };
1623
+ }, [components]);
1617
1624
  const hasChildren = !!instance?.children?.length || instance?.insBom;
1618
1625
  return /*#__PURE__*/jsxs(Fragment$1, {
1619
1626
  children: [/*#__PURE__*/jsxs("div", {
@@ -1623,10 +1630,31 @@ const Bar = props => {
1623
1630
  className: hasChildren ? Styles$5.hasChildren : undefined,
1624
1631
  type: `icon-front-${icon}`
1625
1632
  }), !preview && extra.showLeftToolbar !== false ? /*#__PURE__*/jsxs(Fragment$1, {
1626
- children: [/*#__PURE__*/jsx(Icon, {
1627
- className: `${Styles$5.hover} ${Styles$5.link}`,
1628
- type: "icon-front-link1"
1633
+ children: [/*#__PURE__*/jsx("span", {
1634
+ className: `${Styles$5.link} ${open ? Styles$5.hiddenLinkCount : ''}`,
1635
+ children: /*#__PURE__*/jsx(DropDown, {
1636
+ arrow: true,
1637
+ showIcon: false,
1638
+ disabled: !instance?.trackLinkCount,
1639
+ stopCloseOnClickSelf: true,
1640
+ buttonLabel:
1641
+ /*#__PURE__*/
1642
+ // [TODO] 显示 trackLinkCount
1643
+ jsxs("div", {
1644
+ children: [/*#__PURE__*/jsx("i", {
1645
+ children: instance?.trackLinkCount || ''
1646
+ }), /*#__PURE__*/jsx(StaticIcon, {
1647
+ className: `${Styles$5.hover}`,
1648
+ type: "icon-front-link1"
1649
+ })]
1650
+ }),
1651
+ onOpen: setOpen,
1652
+ children: Components.TrackLinkList && instance ? /*#__PURE__*/jsx(Components.TrackLinkList, {
1653
+ number: instance.number
1654
+ }) : null
1655
+ })
1629
1656
  }), /*#__PURE__*/jsxs(DropDown, {
1657
+ arrow: true,
1630
1658
  showIcon: false,
1631
1659
  buttonLabel: /*#__PURE__*/jsx(Icon, {
1632
1660
  className: Styles$5.hover,
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "instance"
8
8
  ],
9
9
  "license": "MIT",
10
- "version": "0.0.3",
10
+ "version": "0.0.4",
11
11
  "types": "index.d.ts",
12
12
  "files": [
13
13
  "dist",
@@ -23,9 +23,9 @@
23
23
  "@lexical/table": "^0.30.0",
24
24
  "@lexical/utils": "^0.30.0",
25
25
  "lexical": "0.30.0",
26
- "onchain-lexical-context": "^0.0.2",
27
- "onchain-lexical-markdown": "^0.0.2",
28
- "onchain-lexical-ui": "^0.0.2",
26
+ "onchain-lexical-context": "^0.0.3",
27
+ "onchain-lexical-markdown": "^0.0.3",
28
+ "onchain-lexical-ui": "^0.0.3",
29
29
  "onchain-utility": "^0.0.4"
30
30
  },
31
31
  "sideEffects": false,
@@ -11,9 +11,9 @@ import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
11
11
  import {useInstanceConfig} from 'onchain-lexical-context/instanceConfig';
12
12
  import {useSettings} from 'onchain-lexical-context/settings';
13
13
  import DropDown, {DropDownItem} from 'onchain-lexical-ui/DropDown';
14
- import {Icon} from 'onchain-lexical-ui/Icon';
14
+ import {Icon, StaticIcon} from 'onchain-lexical-ui/Icon';
15
15
  import {translateI18n} from 'onchain-utility';
16
- import {useCallback, useMemo} from 'react';
16
+ import {useCallback, useMemo, useState} from 'react';
17
17
 
18
18
  import {OPEN_CREATE_WINDOW} from '../const';
19
19
  import {Instance} from '../types';
@@ -26,8 +26,10 @@ const Bar = (props: {
26
26
  }): JSX.Element => {
27
27
  const {insNodeKey, instance} = props;
28
28
  const [editor] = useLexicalComposerContext();
29
- const {preview, selectedInstance, getInstanceIcon} = useInstanceConfig();
29
+ const {preview, selectedInstance, getInstanceIcon, components} =
30
+ useInstanceConfig();
30
31
  const {extra} = useSettings();
32
+ const [open, setOpen] = useState(false);
31
33
 
32
34
  // icon-front-link1
33
35
  const isSelected = useMemo(() => {
@@ -72,6 +74,12 @@ const Bar = (props: {
72
74
  return 'demand1';
73
75
  }, [instance]);
74
76
 
77
+ const Components = useMemo(() => {
78
+ return {
79
+ ...components,
80
+ };
81
+ }, [components]);
82
+
75
83
  const hasChildren = !!instance?.children?.length || instance?.insBom;
76
84
 
77
85
  return (
@@ -83,11 +91,33 @@ const Bar = (props: {
83
91
  />
84
92
  {!preview && extra.showLeftToolbar !== false ? (
85
93
  <>
86
- <Icon
87
- className={`${Styles.hover} ${Styles.link}`}
88
- type="icon-front-link1"
89
- />
94
+ <span
95
+ className={`${Styles.link} ${
96
+ open ? Styles.hiddenLinkCount : ''
97
+ }`}>
98
+ <DropDown
99
+ arrow={true}
100
+ showIcon={false}
101
+ disabled={!instance?.trackLinkCount}
102
+ stopCloseOnClickSelf={true}
103
+ buttonLabel={
104
+ // [TODO] 显示 trackLinkCount
105
+ <div>
106
+ <i>{instance?.trackLinkCount || ''}</i>
107
+ <StaticIcon
108
+ className={`${Styles.hover}`}
109
+ type="icon-front-link1"
110
+ />
111
+ </div>
112
+ }
113
+ onOpen={setOpen}>
114
+ {Components.TrackLinkList && instance ? (
115
+ <Components.TrackLinkList number={instance.number!} />
116
+ ) : null}
117
+ </DropDown>
118
+ </span>
90
119
  <DropDown
120
+ arrow={true}
91
121
  showIcon={false}
92
122
  buttonLabel={
93
123
  <Icon className={Styles.hover} type="icon-front-xinzeng1" />
@@ -11,7 +11,33 @@
11
11
  flex-direction: column;
12
12
  align-items: center;
13
13
  .link {
14
- margin-bottom: 10px;
14
+ margin-bottom: 6px;
15
+ > button > span > div {
16
+ position: relative;
17
+ > i {
18
+ position: absolute;
19
+ font-size: 10px;
20
+ color: #fff;
21
+ right: -2px;
22
+ bottom: -2px;
23
+ width: 12px;
24
+ height: 12px;
25
+ border-radius: 50%;
26
+ display: flex;
27
+ font-style: normal;
28
+ align-items: center;
29
+ justify-content: center;
30
+ background-color: @themeColor;
31
+ &:empty {
32
+ display: none;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ .hiddenLinkCount {
38
+ > button > span > div > i {
39
+ display: none;
40
+ }
15
41
  }
16
42
  > * {
17
43
  display: inline-flex;
package/src/types.d.ts CHANGED
@@ -25,6 +25,7 @@ export interface Instance
25
25
  extends InstanceBaseInfo,
26
26
  Partial<InstanceExtraAttributes> {
27
27
  children?: Instance[];
28
+ trackLinkCount?: number | null
28
29
  __contentText?: string;
29
30
  }
30
31