@alwith/module-drive 0.1.0-rc.24 → 0.1.2

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.
Files changed (130) hide show
  1. package/desktop-provenance.json +14 -1
  2. package/dist/badge-react.d.ts +2 -2
  3. package/dist/badge-react.js +1 -1
  4. package/dist/badge.d.ts +1 -1
  5. package/dist/badge.js +1 -1
  6. package/dist/browse.d.ts +1 -1
  7. package/dist/browse.js +1 -1
  8. package/dist/chunk-0mx45c8q.js +2 -0
  9. package/dist/chunk-13ret1k0.js +188 -0
  10. package/dist/chunk-2343nj4p.js +2 -0
  11. package/dist/chunk-2n0p7j2f.js +2 -0
  12. package/dist/chunk-2ss7362z.js +2 -0
  13. package/dist/chunk-34qgf6be.js +2 -0
  14. package/dist/chunk-3fpcak8h.js +2 -0
  15. package/dist/chunk-4rfsdwgj.js +2 -0
  16. package/dist/chunk-52ccz07b.js +2 -0
  17. package/dist/chunk-563we221.js +2 -0
  18. package/dist/chunk-8765ztht.js +2 -0
  19. package/dist/chunk-8gmexfjt.js +3 -0
  20. package/dist/chunk-8sdw30dr.js +2 -0
  21. package/dist/chunk-ayvem7j8.js +2 -0
  22. package/dist/chunk-bh4wjd78.js +2 -0
  23. package/dist/chunk-dep1erts.js +2 -0
  24. package/dist/chunk-fkz75xv1.js +2 -0
  25. package/dist/chunk-g3pmrhm2.js +2 -0
  26. package/dist/chunk-j234gbr1.js +4 -0
  27. package/dist/chunk-j2mc48dt.js +2 -0
  28. package/dist/chunk-jxs49r5w.js +2 -0
  29. package/dist/chunk-kzjc8c8g.js +3 -0
  30. package/dist/chunk-m3kvhnag.js +3 -0
  31. package/dist/chunk-m6a9k1p0.js +2 -0
  32. package/dist/chunk-mafn36hy.js +2 -0
  33. package/dist/chunk-mz5601y4.js +2 -0
  34. package/dist/chunk-n7wnyds6.js +2 -0
  35. package/dist/chunk-n9sgwcq1.js +2 -0
  36. package/dist/chunk-nf37g7p6.js +2 -0
  37. package/dist/chunk-njfqtysa.js +2 -0
  38. package/dist/chunk-nk64fv7b.js +2 -0
  39. package/dist/chunk-p7y39rr7.js +2 -0
  40. package/dist/chunk-pbxjprxa.js +2 -0
  41. package/dist/chunk-pc21jzd8.js +3 -0
  42. package/dist/chunk-qabnvepm.js +2 -0
  43. package/dist/chunk-qf5g053e.js +2 -0
  44. package/dist/chunk-rg43mads.js +2 -0
  45. package/dist/chunk-t4vq7jva.js +2 -0
  46. package/dist/chunk-vpew2mps.js +2 -0
  47. package/dist/chunk-vtjd21bw.js +8 -0
  48. package/dist/chunk-ws1dtw35.js +2 -0
  49. package/dist/chunk-zf44znpx.js +2 -0
  50. package/dist/content/chat-condense.d.ts +4 -4
  51. package/dist/content/chat-condense.js +1 -1
  52. package/dist/content/collab.d.ts +1 -1
  53. package/dist/content/collab.js +1 -1
  54. package/dist/content/comment-anchors.js +1 -2
  55. package/dist/content/comment-decorations.d.ts +1 -1
  56. package/dist/content/comment-decorations.js +1 -3
  57. package/dist/content/comment-drawer.d.ts +2 -2
  58. package/dist/content/comment-drawer.js +1 -1
  59. package/dist/content/comment-mentions.d.ts +1 -1
  60. package/dist/content/comment-mentions.js +1 -1
  61. package/dist/content/comment-surface.d.ts +3 -3
  62. package/dist/content/comment-surface.js +1 -1
  63. package/dist/content/condense-task.d.ts +2 -2
  64. package/dist/content/condense-task.js +1 -1
  65. package/dist/content/condense.d.ts +3 -3
  66. package/dist/content/condense.js +1 -1
  67. package/dist/content/editor.d.ts +1 -1
  68. package/dist/content/editor.js +1 -1
  69. package/dist/content/file-actions.d.ts +4 -4
  70. package/dist/content/file-actions.js +1 -1
  71. package/dist/content/file-link.d.ts +1 -1
  72. package/dist/content/file-link.js +1 -1
  73. package/dist/content/frontmatter-panel.js +1 -1
  74. package/dist/content/frontmatter.js +1 -7
  75. package/dist/content/host.d.ts +2 -2
  76. package/dist/content/host.js +1 -1
  77. package/dist/content/html-bridge.js +1 -187
  78. package/dist/content/html-comments.js +1 -1
  79. package/dist/content/markdown-comments.d.ts +1 -1
  80. package/dist/content/markdown-comments.js +1 -2
  81. package/dist/content/mention-picker.d.ts +2 -2
  82. package/dist/content/mention-picker.js +1 -1
  83. package/dist/content/save-version.d.ts +1 -1
  84. package/dist/content/save-version.js +1 -1
  85. package/dist/content/translations.d.ts +1 -1
  86. package/dist/content/translations.js +1 -1
  87. package/dist/content/use-file-comments.d.ts +1 -1
  88. package/dist/content/use-file-comments.js +1 -1
  89. package/dist/content/yuplink.d.ts +1 -1
  90. package/dist/content/yuplink.js +1 -2
  91. package/dist/content.d.ts +10 -10
  92. package/dist/content.js +1 -1
  93. package/dist/contract.d.ts +775 -87
  94. package/dist/core.d.ts +4 -4
  95. package/dist/core.js +1 -1
  96. package/dist/files.d.ts +1 -1
  97. package/dist/files.js +1 -1
  98. package/dist/global-search.js +1 -1
  99. package/dist/icons.js +1 -1
  100. package/dist/launcher.d.ts +3 -3
  101. package/dist/launcher.js +1 -2
  102. package/dist/locales.d.ts +2 -2
  103. package/dist/locales.js +1 -1
  104. package/dist/mass-delete.d.ts +3 -3
  105. package/dist/mass-delete.js +1 -1
  106. package/dist/notifications.js +1 -1
  107. package/dist/pinned-docs.js +1 -1
  108. package/dist/pinned.d.ts +3 -3
  109. package/dist/pinned.js +1 -1
  110. package/dist/react.d.ts +14 -14
  111. package/dist/react.js +1 -1
  112. package/dist/roots.d.ts +1 -1
  113. package/dist/roots.js +1 -1
  114. package/dist/settings.d.ts +3 -3
  115. package/dist/settings.js +1 -1
  116. package/dist/sharing.d.ts +3 -3
  117. package/dist/sharing.js +1 -1
  118. package/dist/status.d.ts +4 -4
  119. package/dist/status.js +1 -1
  120. package/dist/summary.d.ts +1 -1
  121. package/dist/summary.js +1 -1
  122. package/dist/tauri.d.ts +1 -1
  123. package/dist/transfer-feed.d.ts +1 -1
  124. package/dist/transfer-feed.js +1 -1
  125. package/dist/ui.d.ts +4 -3
  126. package/dist/ui.js +1 -1
  127. package/package.json +16 -11
  128. package/rust/Cargo.toml +1 -1
  129. package/rust/src/contract.rs +5 -0
  130. package/rust/src/sync.rs +4 -0
@@ -1,7 +1 @@
1
- var h=new Set(["topics","tags","keywords","owners","reviewers","专题","标签"]);function f(n){let t=n.trim();if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")))return t.slice(1,-1);return t}function m(n){return n.split(",").map((t)=>f(t)).filter((t)=>t.length>0)}function w(n){let t=n.replace(/^---\r?\n/,"").replace(/(^|\r?\n)---[ \t]*(?:\r?\n|$)$/,"");if(!t.trim())return[];let e=t.split(/\r?\n/),i=[],s=0;while(s<e.length){let l=e[s];if(!l.trim()||l.trimStart().startsWith("#")){s++;continue}let c=/^([A-Za-z0-9_\-一-鿿㐀-䶿.]+)\s*:(.*)$/.exec(l);if(!c||/^\s/.test(l)){let u=i.at(-1);if(u?.raw!==void 0)u.raw+=`
2
- ${l}`;else i.push({key:"",value:"",list:!1,raw:l});s++;continue}let a=c[1],o=c[2].trim();if(o===""&&e[s+1]!==void 0&&/^\s+-\s/.test(e[s+1])){let u=[],r=s+1;while(r<e.length&&/^\s+-\s/.test(e[r]))u.push(f(e[r].replace(/^\s+-\s?/,""))),r++;i.push({key:a,value:u.join("、"),list:!0}),s=r;continue}if(o===""||o==="|"||o===">"||o==="|-"||o===">-"){let u=l,r=s+1;while(r<e.length&&(/^\s+\S/.test(e[r])||!e[r].trim()))u+=`
3
- ${e[r]}`,r++;i.push({key:a,value:"",list:!1,raw:u.replace(/\n+$/,"")}),s=r;continue}if(o.startsWith("[")&&o.endsWith("]"))i.push({key:a,value:m(o.slice(1,-1)).join("、"),list:!0});else i.push({key:a,value:f(o),list:h.has(a.toLowerCase())});s++}return i}function d(n){if(n==="")return!0;if(/^[\d.+-]/.test(n)&&!Number.isNaN(Number(n)))return!1;if(/^(true|false|null|yes|no|~)$/i.test(n))return!1;return/[:#[\]{}&*!|>'"%@`,]/.test(n)||/^\s|\s$/.test(n)}function p(n){let t=n.trim();if(!d(t))return t;return`"${t.replaceAll("\\",String.raw`\\`).replaceAll('"',String.raw`\"`)}"`}function g(n){let t=[];for(let e of n){if(e.raw!==void 0){t.push(e.raw);continue}let i=e.key.trim();if(!i)continue;if(e.list){let s=e.value.split(/[、,,]/).map((l)=>l.trim()).filter((l)=>l.length>0);t.push(`${i}: [${s.map(p).join(", ")}]`)}else t.push(`${i}: ${p(e.value)}`)}if(t.length===0)return"";return`---
4
- ${t.join(`
5
- `)}
6
- ---
7
- `}var S=["title","status","owner","topics","department","tags","updated"];export{S as SUGGESTED_KEYS,g as buildFrontmatter,w as parseFrontmatterEntries};
1
+ import{j,te,ne}from"../chunk-vtjd21bw.js";export{ne as SUGGESTED_KEYS,te as buildFrontmatter,j as parseFrontmatterEntries};
@@ -1,6 +1,6 @@
1
1
  import { type ComponentProps, type ComponentType, type ReactNode } from "react";
2
- import type { UserBrief } from "../contract.js";
3
- import type { DriveTransport } from "../core.js";
2
+ import type { UserBrief } from "../contract";
3
+ import type { DriveTransport } from "../core";
4
4
  export interface DriveContentHost {
5
5
  transport: DriveTransport;
6
6
  userName: string;
@@ -1 +1 @@
1
- import{jsx as n}from"react/jsx-runtime";import{createContext as u,useContext as c}from"react";var e=u(null);function a({host:t,children:o}){return n(e.Provider,{value:t,children:o})}function r(){let t=c(e);if(!t)throw Error("Drive content requires a host provider");return t}function l(t){let o=r();return{t:o.translate,i18n:{language:o.language}}}function x(...t){return t.filter(Boolean).join(" ")}function p(t){let o=r().controls.Button;return n(o,{...t})}function f(t){let o=r().controls.Input;return n(o,{...t})}function C(t){let o=r().controls.Textarea;return n(o,{...t})}function h(t){let o=r().controls.Checkbox;return n(o,{...t})}export{p as Button,h as Checkbox,a as DriveContentProvider,f as Input,C as Textarea,x as cn,r as useContentHost,l as useTranslation};
1
+ import{Be,o,i,s,a,L,P,re}from"../chunk-mafn36hy.js";export{a as Button,re as Checkbox,Be as DriveContentProvider,L as Input,P as Textarea,s as cn,o as useContentHost,i as useTranslation};
@@ -1,187 +1 @@
1
- var n=`;(function () {
2
- "use strict"
3
- if (window.__yupCommentBridge) return
4
- window.__yupCommentBridge = true
5
-
6
- var HIGHLIGHT_CLASS = "yup-comment-highlight"
7
- var MARKER_CLASS = "yup-comment-marker"
8
- var STYLE_ID = "yup-comment-style"
9
- var FLASH_CLASS = "yup-comment-flash"
10
-
11
- function post(message) {
12
- try {
13
- window.parent.postMessage(message, "*")
14
- } catch (error) { console.warn("Drive comment bridge could not notify its host", error) }
15
- }
16
-
17
- function ensureStyle() {
18
- if (document.getElementById(STYLE_ID)) return
19
- var style = document.createElement("style")
20
- style.id = STYLE_ID
21
- style.textContent = [
22
- "." + HIGHLIGHT_CLASS + "{background:color-mix(in srgb,var(--primary,currentColor) 18%,transparent);border-bottom:2px solid var(--primary,currentColor);cursor:pointer;}",
23
- "." + HIGHLIGHT_CLASS + ":hover{background:color-mix(in srgb,var(--primary,currentColor) 42%,transparent);}",
24
- "." +
25
- MARKER_CLASS +
26
- "{display:inline-flex;align-items:center;justify-content:center;min-width:15px;height:15px;" +
27
- "margin:0 2px;padding:0 3px;border-radius:8px;background:var(--primary,currentColor);color:var(--primary-foreground,Canvas);font-size:10px;" +
28
- "line-height:1;font-weight:600;font-style:normal;vertical-align:super;cursor:pointer;user-select:none;}",
29
- "." + FLASH_CLASS + "{animation:yup-comment-flash 1.2s ease-out;}",
30
- "@keyframes yup-comment-flash{0%{background:color-mix(in srgb,var(--primary,currentColor) 35%,transparent);}100%{background:color-mix(in srgb,var(--primary,currentColor) 18%,transparent);}}"
31
- ].join("")
32
- ;(document.head || document.documentElement).appendChild(style)
33
- }
34
-
35
-
36
- function flatten() {
37
- var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)
38
- var segments = []
39
- var text = ""
40
- var node
41
- while ((node = walker.nextNode())) {
42
- var value = node.nodeValue || ""
43
- if (value.length === 0) continue
44
- segments.push({ start: text.length, end: text.length + value.length, node: node })
45
- text += value
46
- }
47
- return { text: text, segments: segments }
48
- }
49
-
50
-
51
- function clearMarkers() {
52
- var marks = document.querySelectorAll("." + MARKER_CLASS)
53
- for (var i = 0; i < marks.length; i++) {
54
- if (marks[i].parentNode) marks[i].parentNode.removeChild(marks[i])
55
- }
56
- var spans = document.querySelectorAll("." + HIGHLIGHT_CLASS)
57
- for (var j = 0; j < spans.length; j++) {
58
- var span = spans[j]
59
- var parent = span.parentNode
60
- if (!parent) continue
61
- while (span.firstChild) parent.insertBefore(span.firstChild, span)
62
- parent.removeChild(span)
63
- }
64
- document.body.normalize()
65
- }
66
-
67
-
68
- function wrapRange(segments, start, end, threadId) {
69
- var wrapped = []
70
- for (var i = 0; i < segments.length; i++) {
71
- var segment = segments[i]
72
- var from = Math.max(segment.start, start)
73
- var to = Math.min(segment.end, end)
74
- if (from >= to) continue
75
- try {
76
- var range = document.createRange()
77
- range.setStart(segment.node, from - segment.start)
78
- range.setEnd(segment.node, to - segment.start)
79
- var span = document.createElement("span")
80
- span.className = HIGHLIGHT_CLASS
81
- span.setAttribute("data-thread-id", threadId)
82
- range.surroundContents(span)
83
- wrapped.push(span)
84
- } catch (error) { console.warn("Drive comment quote changed during anchoring", error) }
85
- }
86
- return wrapped
87
- }
88
-
89
- var applying = false
90
-
91
-
92
- function applyAnchors(anchors) {
93
- applying = true
94
- try {
95
- clearMarkers()
96
- ensureStyle()
97
- var flat = flatten()
98
- var anchored = []
99
- for (var i = 0; i < anchors.length; i++) {
100
- var anchor = anchors[i]
101
- var spans = wrapRange(flat.segments, anchor.start, anchor.end, String(anchor.threadId))
102
- if (spans.length === 0) continue
103
- var marker = document.createElement("span")
104
- marker.className = MARKER_CLASS
105
- marker.setAttribute("data-thread-id", String(anchor.threadId))
106
- marker.textContent = String(anchor.index)
107
- var last = spans[spans.length - 1]
108
- if (last.parentNode) last.parentNode.insertBefore(marker, last.nextSibling)
109
- anchored.push(anchor.threadId)
110
- }
111
- post({ type: "yup:anchored", threadIds: anchored })
112
- } finally {
113
- applying = false
114
- }
115
- }
116
-
117
- function scrollToThread(threadId) {
118
- var target = document.querySelector("." + HIGHLIGHT_CLASS + '[data-thread-id="' + threadId + '"]')
119
- if (!target) return
120
- target.scrollIntoView({ behavior: "smooth", block: "center" })
121
- target.classList.remove(FLASH_CLASS)
122
- void target.offsetWidth // Restart the highlight animation.
123
- target.classList.add(FLASH_CLASS)
124
- }
125
-
126
- document.addEventListener("click", function (event) {
127
- var node = event.target
128
- while (node && node !== document.body) {
129
- if (node.classList && (node.classList.contains(MARKER_CLASS) || node.classList.contains(HIGHLIGHT_CLASS))) {
130
- post({ type: "yup:marker-click", threadId: node.getAttribute("data-thread-id") })
131
- return
132
- }
133
- node = node.parentNode
134
- }
135
- })
136
-
137
- document.addEventListener("selectionchange", function () {
138
- if (applying) return
139
- var selection = document.getSelection()
140
- if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
141
- post({ type: "yup:selection", quote: null })
142
- return
143
- }
144
- var quote = selection.toString().trim()
145
- if (quote.length === 0 || quote.length > 1000) {
146
- post({ type: "yup:selection", quote: null })
147
- return
148
- }
149
- var range = selection.getRangeAt(0)
150
- var offset = 0
151
- var walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)
152
- var node
153
- var located = false
154
- while ((node = walker.nextNode())) {
155
- if (node === range.startContainer) {
156
- offset += range.startOffset
157
- located = true
158
- break
159
- }
160
- offset += (node.nodeValue || "").length
161
- }
162
- var rect = range.getBoundingClientRect()
163
- post({
164
- type: "yup:selection",
165
- quote: quote,
166
- quoteOffset: located ? offset : null,
167
- rect: { top: rect.top, left: rect.left, bottom: rect.bottom, right: rect.right }
168
- })
169
- })
170
-
171
- window.addEventListener("message", function (event) {
172
- if (event.source !== window.parent) return
173
- var data = event.data
174
- if (!data || typeof data.type !== "string") return
175
- if (data.type === "yup:anchors") applyAnchors(data.anchors || [])
176
- else if (data.type === "yup:scroll-to") scrollToThread(String(data.threadId))
177
- else if (data.type === "yup:flatten") post({ type: "yup:flat", text: flatten().text })
178
- })
179
-
180
- function announce() {
181
- post({ type: "yup:ready", text: flatten().text })
182
- }
183
-
184
- if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", announce)
185
- else announce()
186
- })()
187
- `;export{n as htmlCommentBridge};
1
+ import{Y}from"../chunk-13ret1k0.js";export{Y as htmlCommentBridge};
@@ -1 +1 @@
1
- import{jsx as h,Fragment as b}from"react/jsx-runtime";import{useCallback as q,useEffect as x,useRef as I,useState as c}from"react";import{locateQuote as v}from"./comment-anchors.js";import{SelectionCommentButton as E}from"./comment-drawer.js";import{useCommentAnchoring as S}from"./comment-surface.js";var T=1000;function H({iframeRef:r}){let[l,i]=c(null),[p,m]=c(null),[w,O]=c(null),[A,C]=c(new Set),y=I(null),g=I([]),o=q((n)=>{r.current?.contentWindow?.postMessage(n,"*")},[r]),{source:F,anchors:a}=S({selection:p,onSelectionUsed:()=>m(null),onFocusQuote:(n)=>o({type:"yup:scroll-to",threadId:n}),focusRequest:w,anchoredThreadIds:A}),d=F.context;g.current=a;let u=q((n)=>{let s=y.current;if(s===null)return;let e=n.flatMap((t)=>{let f=v(s,t.quote,t.quoteOffset);if(f===null)return[];return[{threadId:t.threadId,index:t.index,start:f.start,end:f.end}]});o({type:"yup:anchors",anchors:e})},[o]);if(x(()=>{if(d===null)return;let n=(s)=>{if(s.source!==r.current?.contentWindow)return;let e=s.data;if(e===null||typeof e!=="object"||typeof e.type!=="string")return;switch(e.type){case"yup:ready":case"yup:flat":if(typeof e.text!=="string")return;y.current=e.text,u(g.current);return;case"yup:anchored":if(!Array.isArray(e.threadIds)||!e.threadIds.every((t)=>typeof t==="string"))return;C(new Set(e.threadIds));return;case"yup:marker-click":if(typeof e.threadId!=="string")return;O((t)=>({threadId:e.threadId,nonce:(t?.nonce??0)+1}));return;case"yup:selection":{if(typeof e.quote!=="string"||e.quote.length===0||e.quote.length>T||!e.rect||!Number.isFinite(e.rect.top)||!Number.isFinite(e.rect.left)||e.quoteOffset!=null&&(!Number.isInteger(e.quoteOffset)||e.quoteOffset<0)){i(null);return}let t=r.current?.getBoundingClientRect();if(t===void 0)return;i({quote:e.quote,quoteOffset:e.quoteOffset??null,rect:{top:e.rect.top+t.top,left:e.rect.left+t.left}});return}}};return window.addEventListener("message",n),o({type:"yup:flatten"}),()=>window.removeEventListener("message",n)},[d,r,u,o]),x(()=>{u(a)},[u,a]),d===null)return null;return h(b,{children:l!==null&&p===null&&h(E,{rect:l.rect,onClick:()=>{m(l),i(null)}})})}export{H as HtmlComments};
1
+ import{G}from"../chunk-j2mc48dt.js";import"../chunk-rg43mads.js";import"../chunk-2ss7362z.js";import"../chunk-zf44znpx.js";import"../chunk-bh4wjd78.js";import"../chunk-mafn36hy.js";import"../chunk-pc21jzd8.js";import"../chunk-qabnvepm.js";export{G as HtmlComments};
@@ -1,4 +1,4 @@
1
- import { type CommentAnchorBridge } from "./comment-decorations.js";
1
+ import { type CommentAnchorBridge } from "./comment-decorations";
2
2
  export declare function MarkdownComments({ bridge }: {
3
3
  bridge: CommentAnchorBridge;
4
4
  }): import("react").JSX.Element | null;
@@ -1,2 +1 @@
1
- import{jsx as g,Fragment as q}from"react/jsx-runtime";import{useCallback as w,useEffect as m,useState as r}from"react";import{charIndexAt as E,flattenDocument as L,pushAnchors as y}from"./comment-decorations.js";import{SelectionCommentButton as D}from"./comment-drawer.js";import{useCommentAnchoring as F}from"./comment-surface.js";var I=1000;function H({bridge:t}){let[l,c]=r(null),[f,h]=r(null),[A,S]=r(null),[k,x]=r(new Set),M=w((o)=>{let n=t.view;if(n===null)return;let e=n.dom.querySelector(`.yup-comment-highlight[data-thread-id="${o}"]`);if(e===null)return;e.scrollIntoView({behavior:"smooth",block:"center"}),e.classList.remove("yup-comment-flash"),e.offsetWidth,e.classList.add("yup-comment-flash")},[t]),{source:O,anchors:d}=F({selection:f,onSelectionUsed:()=>h(null),onFocusQuote:M,focusRequest:A,anchoredThreadIds:k}),u=O.context,C=w((o)=>{S((n)=>({threadId:o,nonce:(n?.nonce??0)+1}))},[]);if(m(()=>(t.onMarkerClick=C,t.onAnchoredChange=(o)=>x(new Set(o)),()=>{t.onMarkerClick=()=>{},t.onAnchoredChange=()=>{}}),[t,C]),m(()=>{if(t.view===null)return;y(t.view,d)},[t,d]),m(()=>{if(u===null)return;let o=()=>{let n=t.view;if(n===null)return;let e=document.getSelection();if(e===null||e.isCollapsed||e.rangeCount===0){c(null);return}let s=e.getRangeAt(0);if(!n.dom.contains(s.commonAncestorContainer)){c(null);return}let a=n.posAtDOM(s.startContainer,s.startOffset),p=n.posAtDOM(s.endContainer,s.endOffset);if(a>=p){c(null);return}let i=n.state.doc.textBetween(a,p,`
2
- `).trim();if(i.length===0||i.length>I){c(null);return}let{segments:T}=L(n.state.doc),v=s.getBoundingClientRect();c({quote:i,quoteOffset:E(T,a),rect:{top:v.top,left:v.left}})};return document.addEventListener("selectionchange",o),()=>document.removeEventListener("selectionchange",o)},[u,t]),u===null)return null;return g(q,{children:l!==null&&f===null&&g(D,{rect:l.rect,onClick:()=>{h(l),c(null)}})})}export{H as MarkdownComments};
1
+ import{H}from"../chunk-kzjc8c8g.js";import"../chunk-rg43mads.js";import"../chunk-2ss7362z.js";import"../chunk-zf44znpx.js";import"../chunk-bh4wjd78.js";import"../chunk-mafn36hy.js";import"../chunk-j234gbr1.js";import"../chunk-pc21jzd8.js";import"../chunk-qabnvepm.js";export{H as MarkdownComments};
@@ -1,5 +1,5 @@
1
- import type { UserBrief } from "../contract.js";
2
- import { type MentionQuery } from "./comment-mentions.js";
1
+ import type { UserBrief } from "../contract";
2
+ import { type MentionQuery } from "./comment-mentions";
3
3
  export declare function MentionPicker({ mention, onPick }: {
4
4
  mention: MentionQuery | null;
5
5
  onPick: (person: UserBrief) => void;
@@ -1 +1 @@
1
- import{jsx as s,jsxs as y,Fragment as p}from"react/jsx-runtime";import{useEffect as h,useMemo as b,useState as f}from"react";import{createDebouncedSearch as v,mentionNameOf as x}from"./comment-mentions.js";import{cn as N,useContentHost as w,useTranslation as M}from"./host.js";function k({mention:a,onPick:m}){let{t:i}=M("common"),[c,o]=f([]),[n,e]=f(0),t=w(),r=b(()=>v(t.searchUsers,o,t.onError),[t.searchUsers,t.onError]);h(()=>()=>r.cancel(),[r]);let u=a?.query??null;if(h(()=>{if(u===null){r.cancel(),o([]);return}e(0),r.query(u)},[u,r]),a===null)return null;return s("div",{"data-testid":"mention-picker",className:"bg-popover mt-1 max-h-40 overflow-y-auto rounded-md border p-1 shadow-md",children:c.length===0?s("div",{className:"text-muted-foreground px-2 py-1.5 text-[11px]",children:a.query===""?i("drive.comments.mention.hint"):i("drive.comments.mention.empty")}):c.map((l,d)=>y("button",{type:"button",className:N("flex w-full items-baseline gap-1.5 rounded px-2 py-1 text-start text-[11px]",d===n?"bg-accent":"hover:bg-accent/60"),onMouseEnter:()=>e(d),onMouseDown:(g)=>{g.preventDefault(),m(l)},children:[s("span",{className:"truncate font-medium",children:x(l)}),s("span",{className:"text-muted-foreground truncate text-[10px]",children:l.employeeNo})]},String(l.id)))})}function D({body:a,mentions:m}){let i=(m??[]).map(x).filter((e)=>e.length>0);if(i.length===0)return s(p,{children:a});let c=[...new Set(i)].toSorted((e,t)=>t.length-e.length),o=[],n=a;while(n.length>0){let e=null;for(let t of c){let r=n.indexOf(`@${t}`);if(r===-1)continue;if(e===null||r<e.index)e={index:r,name:t}}if(e===null)break;if(e.index>0)o.push(n.slice(0,e.index));o.push({name:e.name}),n=n.slice(e.index+1+e.name.length)}if(n.length>0)o.push(n);return s(p,{children:o.map((e,t)=>typeof e==="string"?s("span",{children:e},t):s("span",{"data-testid":"mention-chip",className:"bg-primary/15 text-primary rounded px-0.5 font-medium",children:`@${e.name}`},t))})}export{k as MentionPicker,D as MentionedBody};
1
+ import{J,Q}from"../chunk-bh4wjd78.js";import"../chunk-mafn36hy.js";import"../chunk-qabnvepm.js";export{J as MentionPicker,Q as MentionedBody};
@@ -1,2 +1,2 @@
1
- import type { DriveContentHost } from "./host.js";
1
+ import type { DriveContentHost } from "./host";
2
2
  export declare function createVersionSaver(host: DriveContentHost, path: string, canSave: () => boolean, onSaving: (saving: boolean) => void): () => Promise<void>;
@@ -1 +1 @@
1
- function o(e,n,a,i){let t=!1;return async()=>{if(t||!a())return;t=!0,i(!0);try{if(await e.saveDocument(n),!a())throw Error("Drive write access changed while saving the document");let r=await e.transport.request({type:"saveVersion",path:n});if(r.type!=="id")throw Error("Invalid Drive save-version response");if(r.data===null)e.notify.error(e.translate("editor.markdown.frontmatter.notInDrive"));else e.notify.success(e.translate("editor.markdown.frontmatter.saved"))}catch(r){e.notify.error(e.translate("editor.markdown.frontmatter.saveFailed"),{description:String(r)})}finally{t=!1,i(!1)}}}export{o as createVersionSaver};
1
+ import{Z}from"../chunk-34qgf6be.js";export{Z as createVersionSaver};
@@ -1,2 +1,2 @@
1
- import { type DriveLocale } from "../locales.js";
1
+ import { type DriveLocale } from "../locales";
2
2
  export declare function driveContentTranslator(locale: DriveLocale): (key: string, values?: Record<string, unknown>) => string;
@@ -1 +1 @@
1
- import{driveTranslator as s}from"../locales.js";var m={en:{"frontmatter.title":"Properties","frontmatter.count":"{{count}} items","frontmatter.saveVersion":"Save version now","frontmatter.saving":"Saving…","frontmatter.saved":"Saved as a new version","frontmatter.saveFailed":"Failed to save version","frontmatter.notInDrive":"This file is not in the Drive index","frontmatter.listPlaceholder":"Separate values with 、","frontmatter.remove":"Remove property","frontmatter.addCustom":"Custom…","collab.live":"Live collaboration","collab.readOnly":"Read only","collab.alone":"No other collaborators yet"},"zh-CN":{"frontmatter.title":"属性","frontmatter.count":"{{count}} 项","frontmatter.saveVersion":"立即保存版本","frontmatter.saving":"保存中…","frontmatter.saved":"已保存为新版本","frontmatter.saveFailed":"保存版本失败","frontmatter.notInDrive":"此文件不在云盘索引中","frontmatter.listPlaceholder":"使用顿号分隔多个值","frontmatter.remove":"移除属性","frontmatter.addCustom":"自定义…","collab.live":"实时协作","collab.readOnly":"只读","collab.alone":"暂无其他协作者"}};function v(o){let l=s(o);return(r,n={})=>{if(!r.startsWith("editor.markdown."))return l(r,Object.fromEntries(Object.entries(n).map(([i,t])=>[i,typeof t==="number"?t:String(t)])));let a=m[o][r.slice(16)];if(!a)throw Error(`Missing Drive content translation: ${r}`);return a.replaceAll(/\{\{(\w+)\}\}/g,(i,t)=>{let e=n[t];return typeof e==="string"||typeof e==="number"?String(e):`{{${t}}}`})}}export{v as driveContentTranslator};
1
+ import{Te}from"../chunk-8sdw30dr.js";import"../chunk-3fpcak8h.js";export{Te as driveContentTranslator};
@@ -1,4 +1,4 @@
1
- import type { CommentContext, CreateCommentRequest, FileComment, RemoteId } from "../contract.js";
1
+ import type { CommentContext, CreateCommentRequest, FileComment, RemoteId } from "../contract";
2
2
  export interface FileComments {
3
3
  context: CommentContext | null;
4
4
  comments: FileComment[];
@@ -1 +1 @@
1
- import{useCallback as v,useEffect as I,useRef as x,useState as l}from"react";import{useContentHost as g}from"./host.js";function S(c){let{transport:e,onError:s}=g(),[m,f]=l({path:c,context:null}),d=m.path===c?m.context:null,[h,p]=l([]),[C,u]=l(!0),i=x(0),y=x(0),o=d?.fileId??null,a=v(async()=>{if(o===null)return;let t=i.current,r=++y.current,n=await e.request({type:"comments",fileId:o});if(n.type!=="comments")throw Error("Invalid comments response");if(t===i.current&&r===y.current)p(n.data)},[e,o]);return I(()=>{let t=i,r=++i.current;return f({path:c,context:null}),p([]),u(!0),e.request({type:"commentContext",path:c}).then((n)=>{if(n.type!=="commentContext")throw Error("Invalid comment context response");if(r!==i.current)return;if(f({path:c,context:n.data}),n.data===null)u(!1)}).catch((n)=>{if(r===i.current)u(!1),s(n)}),()=>{t.current++}},[c,e,s]),I(()=>{if(o===null)return;let t=!1,r=crypto.randomUUID(),n;return(async()=>{let w=await e.subscribe((q)=>{if(q.payload.type==="comment"&&String(q.payload.data.fileId)===String(o))a().catch(s)});if(t){w();return}if(n=w,await e.request({type:"commentWatch",ownerId:r,fileIds:[o]}),t){await e.request({type:"commentWatch",ownerId:r,fileIds:[]});return}await a()})().catch(s).finally(()=>{if(!t)u(!1)}),()=>{t=!0,n?.(),e.request({type:"commentWatch",ownerId:r,fileIds:[]}).catch(s)}},[o,e,a,s]),{context:d,comments:h,loading:C,reload:a,create:async(t)=>{if(o===null)throw Error("The file is not available for comments");await e.request({type:"commentCreate",fileId:o,request:t}),await a()},update:async(t,r)=>{await e.request({type:"commentUpdate",commentId:t,body:r}),await a()},remove:async(t)=>{await e.request({type:"commentDelete",commentId:t}),await a()},apply:async(t)=>{await e.request({type:"commentApply",commentId:t}),await a()}}}export{S as useFileComments};
1
+ import{K}from"../chunk-2ss7362z.js";import"../chunk-mafn36hy.js";export{K as useFileComments};
@@ -1,4 +1,4 @@
1
- import type { RemoteId } from "../contract.js";
1
+ import type { RemoteId } from "../contract";
2
2
  export declare const YUPLINK_EXTENSION = ".yuplink";
3
3
  export declare function isYuplinkName(name: string): boolean;
4
4
  export declare function yuplinkDisplayName(name: string): string;
@@ -1,2 +1 @@
1
- var p=".yuplink";function u(n){return n.toLowerCase().endsWith(".yuplink")}function s(n){return u(n)?n.slice(0,-8):n}function a(n){let r;try{r=JSON.parse(n)}catch{return null}if(r===null||typeof r!=="object"||Array.isArray(r))return null;let l=r,{targetFileId:e,name:t,webUrl:i}=l;if(!(typeof e==="number"&&Number.isFinite(e)||typeof e==="string"&&e!==""))return null;if(typeof t!=="string"||t==="")return null;if(typeof i!=="string")return null;return{targetFileId:e,name:t,webUrl:i}}function f(n){return`${JSON.stringify({targetFileId:n.targetFileId,name:n.name,webUrl:n.webUrl},null,2)}
2
- `}export{p as YUPLINK_EXTENSION,f as buildYuplinkContent,u as isYuplinkName,a as parseYuplink,s as yuplinkDisplayName};
1
+ import{dt,X,_e,ze,Ue}from"../chunk-8gmexfjt.js";export{dt as YUPLINK_EXTENSION,Ue as buildYuplinkContent,X as isYuplinkName,ze as parseYuplink,_e as yuplinkDisplayName};
package/dist/content.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { DriveContentProvider, type DriveContentHost } from "./content/host.js";
2
- export { CommentSurface, commentPathOf } from "./content/comment-surface.js";
3
- export { drivePreviewIntegrations, createDriveMarkdownIntegration } from "./content/editor.js";
4
- export { parseYuplink, buildYuplinkContent, yuplinkDisplayName, isYuplinkName, type YuplinkTarget } from "./content/yuplink.js";
5
- export { driveFileWebUrl, driveFileDeepLink, parseDriveFileDeepLinkPath } from "./content/file-link.js";
6
- export { splitFrontmatter } from "./content/collab.js";
7
- export { DriveCondense, type DriveCondenseProps, type CondenseScope } from "./content/condense.js";
8
- export { driveContentTranslator } from "./content/translations.js";
9
- export { DriveFileActions, DriveMoveDialog, resolveDriveRoot, resolveCondenseScope, type DriveFileActionHost, type DriveMoveHost } from "./content/file-actions.js";
10
- export { ChatCondenseEntry, type ChatCondenseEntryProps, type CondenseSnoozeHost } from "./content/chat-condense.js";
1
+ export { DriveContentProvider, type DriveContentHost } from "./content/host";
2
+ export { CommentSurface, commentPathOf } from "./content/comment-surface";
3
+ export { drivePreviewIntegrations, createDriveMarkdownIntegration } from "./content/editor";
4
+ export { parseYuplink, buildYuplinkContent, yuplinkDisplayName, isYuplinkName, type YuplinkTarget } from "./content/yuplink";
5
+ export { driveFileWebUrl, driveFileDeepLink, parseDriveFileDeepLinkPath } from "./content/file-link";
6
+ export { splitFrontmatter } from "./content/collab";
7
+ export { DriveCondense, type DriveCondenseProps, type CondenseScope } from "./content/condense";
8
+ export { driveContentTranslator } from "./content/translations";
9
+ export { DriveFileActions, DriveMoveDialog, resolveDriveRoot, resolveCondenseScope, type DriveFileActionHost, type DriveMoveHost } from "./content/file-actions";
10
+ export { ChatCondenseEntry, type ChatCondenseEntryProps, type CondenseSnoozeHost } from "./content/chat-condense";
package/dist/content.js CHANGED
@@ -1 +1 @@
1
- import{DriveContentProvider as o}from"./content/host.js";import{CommentSurface as i,commentPathOf as n}from"./content/comment-surface.js";import{drivePreviewIntegrations as a,createDriveMarkdownIntegration as m}from"./content/editor.js";import{parseYuplink as v,buildYuplinkContent as s,yuplinkDisplayName as f,isYuplinkName as D}from"./content/yuplink.js";import{driveFileWebUrl as x,driveFileDeepLink as C,parseDriveFileDeepLinkPath as k}from"./content/file-link.js";import{splitFrontmatter as c}from"./content/collab.js";import{DriveCondense as P}from"./content/condense.js";import{driveContentTranslator as h}from"./content/translations.js";import{DriveFileActions as Y,DriveMoveDialog as b,resolveDriveRoot as w,resolveCondenseScope as I}from"./content/file-actions.js";import{ChatCondenseEntry as M}from"./content/chat-condense.js";export{M as ChatCondenseEntry,i as CommentSurface,P as DriveCondense,o as DriveContentProvider,Y as DriveFileActions,b as DriveMoveDialog,s as buildYuplinkContent,n as commentPathOf,m as createDriveMarkdownIntegration,h as driveContentTranslator,C as driveFileDeepLink,x as driveFileWebUrl,a as drivePreviewIntegrations,D as isYuplinkName,k as parseDriveFileDeepLinkPath,v as parseYuplink,I as resolveCondenseScope,w as resolveDriveRoot,c as splitFrontmatter,f as yuplinkDisplayName};
1
+ import{Be}from"./chunk-mafn36hy.js";import"./chunk-pc21jzd8.js";import"./chunk-qabnvepm.js";import"./chunk-bh4wjd78.js";import"./chunk-zf44znpx.js";import"./chunk-2ss7362z.js";import{W,Oe}from"./chunk-rg43mads.js";import{b}from"./chunk-m6a9k1p0.js";import"./chunk-j234gbr1.js";import"./chunk-vtjd21bw.js";import"./chunk-nf37g7p6.js";import"./chunk-13ret1k0.js";import"./chunk-j2mc48dt.js";import"./chunk-kzjc8c8g.js";import"./chunk-34qgf6be.js";import{B,Me}from"./chunk-n9sgwcq1.js";import{X,_e,ze,Ue}from"./chunk-8gmexfjt.js";import{k,R,qe}from"./chunk-njfqtysa.js";import"./chunk-3fpcak8h.js";import"./chunk-ayvem7j8.js";import"./chunk-ws1dtw35.js";import"./chunk-pbxjprxa.js";import{Ge}from"./chunk-4rfsdwgj.js";import{Te}from"./chunk-8sdw30dr.js";import{x,h,Le,Fe}from"./chunk-563we221.js";import{je}from"./chunk-jxs49r5w.js";export{je as ChatCondenseEntry,Oe as CommentSurface,Ge as DriveCondense,Be as DriveContentProvider,Le as DriveFileActions,Fe as DriveMoveDialog,Ue as buildYuplinkContent,W as commentPathOf,B as createDriveMarkdownIntegration,Te as driveContentTranslator,R as driveFileDeepLink,k as driveFileWebUrl,Me as drivePreviewIntegrations,X as isYuplinkName,qe as parseDriveFileDeepLinkPath,ze as parseYuplink,h as resolveCondenseScope,x as resolveDriveRoot,b as splitFrontmatter,_e as yuplinkDisplayName};