@univerjs/docs-hyper-link-ui 0.2.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 +176 -0
- package/README.md +28 -0
- package/lib/cjs/index.js +1 -0
- package/lib/es/index.js +644 -0
- package/lib/index.css +1 -0
- package/lib/locale/en-US.json +21 -0
- package/lib/locale/ru-RU.json +21 -0
- package/lib/locale/zh-CN.json +21 -0
- package/lib/types/commands/commands/add-link.command.d.ts +7 -0
- package/lib/types/commands/commands/delete-link.command.d.ts +7 -0
- package/lib/types/commands/commands/update-link.command.d.ts +8 -0
- package/lib/types/commands/operations/popup.operation.d.ts +12 -0
- package/lib/types/controllers/doc-hyper-link-clipboard.controller.d.ts +13 -0
- package/lib/types/controllers/doc-hyper-link-selection.controller.d.ts +12 -0
- package/lib/types/controllers/menu.d.ts +6 -0
- package/lib/types/controllers/render-controllers/render.controller.d.ts +12 -0
- package/lib/types/controllers/ui.controller.d.ts +20 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/locale/en-US.d.ts +4 -0
- package/lib/types/locale/ru-RU.d.ts +4 -0
- package/lib/types/locale/zh-CN.d.ts +37 -0
- package/lib/types/plugin.d.ts +16 -0
- package/lib/types/services/hyper-link-popup.service.d.ts +31 -0
- package/lib/types/types/const/index.d.ts +16 -0
- package/lib/types/views/hyper-link-edit/index.d.ts +6 -0
- package/lib/types/views/hyper-link-popup/index.d.ts +6 -0
- package/lib/umd/index.js +1 -0
- package/package.json +100 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @univerjs/docs-hyper-link-ui
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/packages/@univerjs/docs-hyper-link-ui )
|
|
4
|
+
[](https://img.shields.io/npm/l/@univerjs/sheets- thread-comment)
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
`@univerjs/docs-hyper-link-ui` provides the link function of Univer Docs.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Install
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
# Use npm
|
|
17
|
+
npm install @univerjs/docs-hyper-link-ui
|
|
18
|
+
|
|
19
|
+
# Use pnpm
|
|
20
|
+
pnpm add @univerjs/docs-hyper-link-ui
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### use
|
|
24
|
+
```js
|
|
25
|
+
import { UniverDocsHyperLinkUIPlugin} from '@univerjs/docs-hyper-link-ui';
|
|
26
|
+
|
|
27
|
+
univer.registerPlugin(UniverDocsHyperLinkUIPlugin);
|
|
28
|
+
```
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var ve=Object.defineProperty;var ge=(n,e,i)=>e in n?ve(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var R=(n,e,i)=>ge(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),g=require("@wendellhu/redi"),P=require("@univerjs/docs-hyper-link"),D=require("@univerjs/engine-render"),I=require("@univerjs/ui"),k=require("@univerjs/design"),a=require("react"),h=require("@wendellhu/redi/react-bindings"),C=require("@univerjs/docs"),Y=require("@univerjs/docs-ui"),B=require("rxjs"),Q=require("clsx"),he="DOC_HYPER_LINK_UI_PLUGIN";var L=function(){return L=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},L.apply(this,arguments)},me=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(n);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(n,t[r])&&(i[t[r]]=n[t[r]]);return i},b=a.forwardRef(function(n,e){var i=n.icon,t=n.id,r=n.className,o=n.extend,c=me(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),l=a.useRef("_".concat(Ce()));return te(i,"".concat(t),{defIds:i.defIds,idSuffix:l.current},L({ref:e,className:d},c),o)});function te(n,e,i,t,r){return a.createElement(n.tag,L(L({key:e},Le(n,i,r)),t),(Ie(n,i).children||[]).map(function(o,c){return te(o,"".concat(e,"-").concat(n.tag,"-").concat(c),i,void 0,r)}))}function Le(n,e,i){var t=L({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(o){var c=o[0],d=o[1];typeof d=="string"&&(t[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function Ie(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?L(L({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?L(L({},r),{attrs:L(L({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function Ce(){return Math.random().toString(36).substring(2,8)}b.displayName="UniverIcon";var ye={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},ie=a.forwardRef(function(n,e){return a.createElement(b,Object.assign({},n,{id:"close-single",ref:e,icon:ye}))});ie.displayName="CloseSingle";var _e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},re=a.forwardRef(function(n,e){return a.createElement(b,Object.assign({},n,{id:"copy-single",ref:e,icon:_e}))});re.displayName="CopySingle";var Se={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},Z=a.forwardRef(function(n,e){return a.createElement(b,Object.assign({},n,{id:"link-single",ref:e,icon:Se}))});Z.displayName="LinkSingle";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},oe=a.forwardRef(function(n,e){return a.createElement(b,Object.assign({},n,{id:"unlink-single",ref:e,icon:ke}))});oe.displayName="UnlinkSingle";var Oe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},ce=a.forwardRef(function(n,e){return a.createElement(b,Object.assign({},n,{id:"write-single",ref:e,icon:Oe}))});ce.displayName="WriteSingle";const se={type:s.CommandType.COMMAND,id:"docs.command.delete-hyper-link",handler(n,e){if(!e)return!1;const{unitId:i,linkId:t}=e,r=n.get(s.ICommandService);if(!n.get(P.DocHyperLinkModel).getLink(i,t))return!1;const d=C.deleteCustomRangeFactory(n,{unitId:i,rangeId:t});return d?r.executeCommand(d.id,d.params):!1}},ae=n=>{var f;const e=n.get(C.TextSelectionManagerService),i=n.get(s.IUniverInstanceService),t=e.getActiveRange(),o=n.get(D.IRenderManagerService).getCurrent(),c=o==null?void 0:o.with(C.DocSkeletonManagerService).getSkeleton(),d=c==null?void 0:c.getViewModel().getEditArea();if(d===D.DocumentEditArea.FOOTER||d===D.DocumentEditArea.HEADER)return!0;const l=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!l||!t||t.collapsed)return!0;const p=(f=l.getBody())==null?void 0:f.paragraphs;if(!p)return!0;for(let v=0,u=p.length;v<u;v++){const m=p[v];if(t.startOffset<=m.startIndex&&t.endOffset>m.startIndex)return!0;if(m.startIndex>t.endOffset)break}return!1},F={type:s.CommandType.OPERATION,id:"docs.operation.show-hyper-link-edit-popup",handler(n,e){const i=e==null?void 0:e.link;return ae(n)&&!i?!1:(n.get(M).showEditPopup(i),!0)}},Ee="univer-doc-link",Me="univer-doc-link-type",Pe="univer-doc-link-content",Re="univer-doc-link-content-error",De="univer-doc-link-url",xe="univer-doc-link-operations",be="univer-doc-link-operation",Te="univer-doc-link-operation-error",E={docLink:Ee,docLinkType:Me,docLinkContent:Pe,docLinkContentError:Re,docLinkUrl:De,docLinkOperations:xe,docLinkOperation:be,docLinkOperationError:Te},K=()=>{const n=h.useDependency(M),e=h.useDependency(P.DocHyperLinkModel),i=h.useDependency(s.ICommandService),t=h.useDependency(I.IMessageService),r=h.useDependency(s.LocaleService),o=I.useObservable(n.showingLink$);if(!o)return null;const{unitId:c,linkId:d}=o,l=e.getLink(c,d);return l?a.createElement("div",{className:E.docLink,onClick:()=>{n.hideInfoPopup()}},a.createElement("div",{className:Q(E.docLinkContent),onClick:()=>window.open(l.payload)},a.createElement("div",{className:E.docLinkType},a.createElement(Z,null)),a.createElement(k.Tooltip,{showIfEllipsis:!0,title:l.payload},a.createElement("span",{className:E.docLinkUrl},l.payload))),a.createElement("div",{className:E.docLinkOperations},a.createElement("div",{className:Q(E.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(l.payload),t.show({content:r.t("docLink.info.coped"),type:k.MessageType.Info})}},a.createElement(k.Tooltip,{placement:"bottom",title:r.t("docLink.info.copy")},a.createElement(re,null))),a.createElement("div",{className:E.docLinkOperation,onClick:()=>{i.executeCommand(F.id,{link:o})}},a.createElement(k.Tooltip,{placement:"bottom",title:r.t("docLink.info.edit")},a.createElement(ce,null))),a.createElement("div",{className:E.docLinkOperation,onClick:()=>{i.executeCommand(se.id,{unitId:c,linkId:l.id})}},a.createElement(k.Tooltip,{placement:"bottom",title:r.t("docLink.info.cancel")},a.createElement(oe,null))))):null};K.componentKey="univer.doc.link-info-popup";var Ue=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Ne=(n,e,i,t)=>{for(var r=t>1?void 0:t?we(e,i):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(r=(t?c(e,i,r):c(r))||r);return t&&r&&Ue(e,i,r),r},U=(n,e)=>(i,t)=>e(i,t,n);let M=class extends s.Disposable{constructor(e,i,t,r,o){super();R(this,"_editingLink$",new B.BehaviorSubject(null));R(this,"_showingLink$",new B.BehaviorSubject(null));R(this,"editingLink$",this._editingLink$.asObservable());R(this,"showingLink$",this._showingLink$.asObservable());R(this,"_editPopup",null);R(this,"_infoPopup",null);this._docCanvasPopupManagerService=e,this._textSelectionManagerService=i,this._docHyperLinkModel=t,this._univerInstanceService=r,this._commandService=o}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e){var t,r;this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(e);let i=this._textSelectionManagerService.getActiveRange();if(e){const{unitId:o,rangeIndex:c}=e,d=this._univerInstanceService.getUnit(o,s.UniverInstanceType.UNIVER_DOC),l=(r=(t=d==null?void 0:d.getBody())==null?void 0:t.customRanges)==null?void 0:r[c];l&&(i={collapsed:!1,startOffset:l.startIndex,endOffset:l.endIndex+1},this._textSelectionManagerService.replaceTextRanges([{startOffset:l.startIndex,endOffset:l.endIndex+1}]))}return i?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(i,{componentKey:V.componentKey,direction:"bottom"}),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var l,p,f,v;const{linkId:i,unitId:t,rangeIndex:r}=e;if(((l=this.showing)==null?void 0:l.linkId)===i&&((p=this.showing)==null?void 0:p.unitId)===t&&this.showing.rangeIndex===r)return;this._infoPopup&&this._infoPopup.dispose();const o=this._docHyperLinkModel.getLink(t,i),c=this._univerInstanceService.getUnit(t,s.UniverInstanceType.UNIVER_DOC);if(!c||!o)return;const d=(v=(f=c.getBody())==null?void 0:f.customRanges)==null?void 0:v[r];if(this._showingLink$.next({unitId:t,linkId:i,rangeIndex:r}),!!d)return this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:d.startIndex,endOffset:d.endIndex+1},{componentKey:K.componentKey,direction:"top",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideInfoPopup()}}),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};M=Ne([U(0,g.Inject(Y.DocCanvasPopManagerService)),U(1,g.Inject(C.TextSelectionManagerService)),U(2,g.Inject(P.DocHyperLinkModel)),U(3,s.IUniverInstanceService),U(4,s.ICommandService)],M);const de={type:s.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(n,e){if(!e)return!1;const{payload:i,unitId:t}=e,r=n.get(s.ICommandService),o=s.Tools.generateRandomId(),c=C.addCustomRangeBySelectionFactory(n,{rangeId:o,rangeType:s.CustomRangeType.HYPERLINK});if(c){const d={id:P.AddDocHyperLinkMutation.id,params:{unitId:t,link:{payload:i,id:o}}};return(await s.sequenceExecuteAsync([d,c],r)).result}return!1}},le={id:"docs.command.update-hyper-link",type:s.CommandType.COMMAND,handler(n,e){return e?n.get(s.ICommandService).executeCommand(P.UpdateDocHyperLinkMutation.id,e):!1}},He="univer-docs-link-edit",je="univer-docs-link-edit-title",$e="univer-docs-link-edit-close",Ae="univer-docs-link-edit-buttons",Be="univer-docs-link-edit-button",x={docsLinkEdit:He,docsLinkEditTitle:je,docsLinkEditClose:$e,docsLinkEditButtons:Ae,docsLinkEditButton:Be};function Ke(n){return/^[a-zA-Z]+:\/\//.test(n)}function Ve(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function Fe(n){return Ke(n)?n:Ve(n)?`mailto://${n}`:`https://${n}`}const V=()=>{const n=h.useDependency(M),e=h.useDependency(s.LocaleService),i=h.useDependency(P.DocHyperLinkModel),t=h.useObservable(n.editingLink$),r=h.useDependency(s.ICommandService),o=h.useDependency(s.IUniverInstanceService),c=h.useDependency(D.ITextSelectionRenderManager),d=h.useDependency(C.TextSelectionManagerService),[l,p]=a.useState(""),[f,v]=a.useState(!1),u=s.Tools.isLegalUrl(l),m=t?o.getUnit(t.unitId,s.UniverInstanceType.UNIVER_DOC):o.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);a.useEffect(()=>{var z,G,X,J;if(t){const S=t?i.getLink(t.unitId,t.linkId):null;p((z=S==null?void 0:S.payload)!=null?z:"");return}const y=d.getActiveRange();if(!y)return;const T=o.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),W=(X=(G=T==null?void 0:T.getBody())==null?void 0:G.customRanges)==null?void 0:X.find(S=>Math.max(y.startOffset,S.startIndex)<=Math.min(y.endOffset-1,S.endIndex));if(T&&W){const S=i.getLink(T.getUnitId(),W.rangeId);p((J=S==null?void 0:S.payload)!=null?J:"")}},[t,i,d,o]),a.useEffect(()=>(c.blur(),()=>{c.focus()}),[c]);const _=()=>{n.hideEditPopup()},O=()=>{if(v(!0),!u||!m)return;const y=Fe(l);t?r.executeCommand(le.id,{unitId:m.getUnitId(),payload:y,linkId:t.linkId}):r.executeCommand(de.id,{unitId:m.getUnitId(),payload:y}),n.hideEditPopup()};if(m)return a.createElement("div",{className:x.docsLinkEdit},a.createElement("div",{className:x.docsLinkEditTitle},a.createElement("span",null,e.t("docLink.edit.title")),a.createElement(ie,{className:x.docsLinkEditClose,onClick:_})),a.createElement("div",null,a.createElement(k.FormLayout,{label:e.t("docLink.edit.address"),error:f&&!u?e.t("docLink.edit.addressError"):""},a.createElement(k.Input,{value:l,onChange:p,autoFocus:!0}))),a.createElement("div",{className:x.docsLinkEditButtons},a.createElement(k.Button,{className:x.docsLinkEditButton,onClick:_},e.t("docLink.edit.cancel")),a.createElement(k.Button,{disabled:!l,className:x.docsLinkEditButton,type:"primary",onClick:O},e.t("docLink.edit.confirm"))))};V.componentKey="docs-hyper-link-edit";const ue="doc-hyper-link-icon";function qe(n){return{id:F.id,group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.BUTTON,icon:ue,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",positions:[I.MenuPosition.TOOLBAR_START,I.MenuPosition.CONTEXT_MENU],hidden$:I.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_DOC),disabled$:new B.Observable(function(e){const t=n.get(C.TextSelectionManagerService).textSelection$.pipe(B.debounceTime(16)).subscribe(()=>{e.next(ae(n))});return()=>{t.unsubscribe()}})}}const Ye={id:F.id,binding:I.MetaKeys.CTRL_COMMAND|I.KeyCode.K,description:"docLink.menu.tooltip",preconditions:Y.whenDocAndEditorFocused};var Ze=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=(n,e,i,t)=>{for(var r=t>1?void 0:t?We(e,i):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(r=(t?c(e,i,r):c(r))||r);return t&&r&&Ze(e,i,r),r},w=(n,e)=>(i,t)=>e(i,t,n);let N=class extends s.Disposable{constructor(n,e,i,t,r,o){super(),this._config=n,this._componentManager=e,this._commandService=i,this._menuService=t,this._injector=r,this._shortcutService=o,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[V,V.componentKey],[K,K.componentKey],[Z,ue]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[de,le,se,F].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[Ye].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){[qe].forEach(n=>{this.disposeWithMe(this._menuService.addMenuItem(n(this._injector),{}))})}};N=ze([s.OnLifecycle(s.LifecycleStages.Starting,N),w(1,g.Inject(I.ComponentManager)),w(2,s.ICommandService),w(3,I.IMenuService),w(4,g.Inject(g.Injector)),w(5,I.IShortcutService)],N);var Ge=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,Je=(n,e,i,t)=>{for(var r=t>1?void 0:t?Xe(e,i):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(r=(t?c(e,i,r):c(r))||r);return t&&r&&Ge(e,i,r),r},H=(n,e)=>(i,t)=>e(i,t,n);let $=class extends s.Disposable{constructor(n,e,i,t){super(),this._commandService=n,this._univerInstanceService=e,this._docHyperLinkService=i,this._renderMangerService=t,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var e,i;if(n.id===C.SetTextSelectionsOperation.id){const t=n.params,{unitId:r,ranges:o}=t,c=this._renderMangerService.getRenderById(r),d=c==null?void 0:c.with(C.DocSkeletonManagerService).getSkeleton();if((d==null?void 0:d.getViewModel().getEditArea())!==D.DocumentEditArea.BODY){this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup();return}const p=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_DOC),f=o[0];if(f&&p){const{startOffset:v,endOffset:u,collapsed:m}=f,_=(e=p.getBody())==null?void 0:e.customRanges;if(m){const O=(i=_==null?void 0:_.findIndex(y=>y.startIndex<v&&y.endIndex>u-1))!=null?i:-1;if(O>-1){const y=_[O];this._docHyperLinkService.showInfoPopup({unitId:r,linkId:y.rangeId,rangeIndex:O});return}}else if(_!=null&&_.find(O=>O.startIndex<=v&&O.endIndex>=u-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};$=Je([s.OnLifecycle(s.LifecycleStages.Ready,$),H(0,s.ICommandService),H(1,s.IUniverInstanceService),H(2,g.Inject(M)),H(3,D.IRenderManagerService)],$);var Qe=Object.defineProperty,en=Object.getOwnPropertyDescriptor,nn=(n,e,i,t)=>{for(var r=t>1?void 0:t?en(e,i):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(r=(t?c(e,i,r):c(r))||r);return t&&r&&Qe(e,i,r),r},ee=(n,e)=>(i,t)=>e(i,t,n);let q=class extends s.Disposable{constructor(n,e,i){super(),this._context=n,this._docInterceptorService=e,this._hyperLinkService=i,this._init()}_init(){this._docInterceptorService.intercept(C.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(n,e,i)=>{if(!n)return i(n);const{unitId:t}=e,r=this._hyperLinkService.editing,{linkId:o,unitId:c}=r||{},d=c===t&&n.rangeId===o;return i({...n,active:d})}})}};q=nn([ee(1,g.Inject(C.DocInterceptorService)),ee(2,g.Inject(M))],q);var tn=Object.defineProperty,rn=Object.getOwnPropertyDescriptor,on=(n,e,i,t)=>{for(var r=t>1?void 0:t?rn(e,i):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(r=(t?c(e,i,r):c(r))||r);return t&&r&&tn(e,i,r),r},j=(n,e)=>(i,t)=>e(i,t,n);let A=class extends s.Disposable{constructor(n,e,i,t){super(),this._docClipboardService=n,this._univerInstanceService=e,this._hyperLinkModel=i,this._textSelectionManagerService=t,this._initClipboard()}_initClipboard(){this.disposeWithMe(this._docClipboardService.addClipboardHook({onBeforePaste:n=>{var o,c;const e=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);if(!e)return n;const i=this._textSelectionManagerService.getActiveRange(),t=(o=e.getBody())==null?void 0:o.customRanges;if(!(t!=null&&t.length))return n;if(i?t.find(d=>d.rangeType===s.CustomRangeType.HYPERLINK&&d.startIndex<=i.startOffset&&d.endIndex>=i.endOffset-1):null){const{customRanges:d=[],...l}=n,f=d.filter(u=>u.rangeType===s.CustomRangeType.HYPERLINK).map(u=>[u.startIndex,u.endIndex]).flat().sort((u,m)=>u-m),v={...l,customRanges:d.filter(u=>u.rangeType!==s.CustomRangeType.HYPERLINK)};for(let u=0;u<f.length;u++)s.updateAttributeByDelete(v,1,f[u]-u);return v}else{const d=new Set(t.map(l=>l.rangeType===s.CustomRangeType.HYPERLINK&&l.rangeId));(c=n.customRanges)==null||c.forEach(l=>{if(l.rangeType===s.CustomRangeType.HYPERLINK&&d.has(l.rangeId)){const p=this._hyperLinkModel.getLink(e.getUnitId(),l.rangeId);if(p){const f=s.Tools.generateRandomId();this._hyperLinkModel.addLink(e.getUnitId(),{payload:p.payload,id:f}),l.rangeId=f}}})}return n}}))}};A=on([s.OnLifecycle(s.LifecycleStages.Ready,A),j(0,g.Inject(Y.IDocClipboardService)),j(1,s.IUniverInstanceService),j(2,g.Inject(P.DocHyperLinkModel)),j(3,g.Inject(C.TextSelectionManagerService))],A);var pe=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,sn=(n,e,i)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,an=(n,e,i,t)=>{for(var r=t>1?void 0:t?cn(e,i):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(r=(t?c(e,i,r):c(r))||r);return t&&r&&pe(e,i,r),r},ne=(n,e)=>(i,t)=>e(i,t,n),fe=(n,e,i)=>sn(n,typeof e!="symbol"?e+"":e,i);exports.UniverDocsHyperLinkUIPlugin=class extends s.Plugin{constructor(e={menu:{}},i,t){super(),this._config=e,this._injector=i,this._renderManagerSrv=t}onStarting(e){[[M],[N,{useFactory:()=>this._injector.createInstance(N,this._config)}],[$],[A]].forEach(t=>{e.add(t)})}onRendered(){this._initRenderModule()}_initRenderModule(){[q].forEach(e=>{this._renderManagerSrv.registerRenderModule(s.UniverInstanceType.UNIVER_DOC,e)})}};fe(exports.UniverDocsHyperLinkUIPlugin,"pluginName",he);fe(exports.UniverDocsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=an([s.DependentOn(P.UniverDocsHyperLinkPlugin),ne(1,g.Inject(g.Injector)),ne(2,D.IRenderManagerService)],exports.UniverDocsHyperLinkUIPlugin);
|