@dooc-dev/dooc 0.0.21 → 0.0.22

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.
@@ -1136,9 +1136,12 @@ ul.idx a > .nav-icon { width: 18px; height: 18px; }
1136
1136
  #sidebar:has(.nav-root[data-document-link]) .site-title,
1137
1137
  ul.idx a[data-document-link] .document-card-label {
1138
1138
  color: color-mix(in srgb, var(--doc-accent-2) 85%, var(--doc-fg)); text-decoration: underline; text-underline-offset: 2px; }
1139
- .document-web-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
1140
- .document-web-tools span { min-width: 0; overflow-wrap: anywhere; color: var(--doc-fg-2); }
1141
- .document-web-frame { display: block; width: 100%; height: 70vh; min-height: 320px; border: 1px solid var(--doc-border); background: #fff; }
1139
+ main:has(> article > .document-web) { position: relative; padding: 0; overflow: hidden; }
1140
+ main:has(> article > .document-web) > .page-actions { display: none; }
1141
+ .document-web { position: absolute; inset: 0; }
1142
+ .document-web-notice { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--doc-bg); text-align: center; }
1143
+ .document-web-notice[hidden] { display: none; }
1144
+ .document-web-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
1142
1145
  details summary { cursor: pointer; opacity: .8; }
1143
1146
  /* Figure and term file links show previews on hover. */
1144
1147
  .figref, .dictref { color: var(--doc-accent-2); text-decoration: none;
@@ -1888,6 +1891,8 @@ main.editor-workspace { padding: 0; height: 100vh; display: flex; flex-direction
1888
1891
  #preview-panes.split .pane-actions { top: -16px; margin: -16px -16px 16px; padding-inline: 10px; }
1889
1892
  #preview-panes.split .preview-pane + .preview-pane { border-left: 1px solid var(--c-line); }
1890
1893
  #preview-panes.split .preview-pane.active { border-top-color: var(--c-accent); }
1894
+ #preview-panes .preview-pane:has(> .pane-resource .document-web, > .preview-content:not([hidden]) .document-web) { position: relative; padding: 0; border: 0; overflow: hidden; }
1895
+ .preview-pane:has(> .preview-content:not([hidden]) .document-web) > .pane-actions { display: none; }
1891
1896
  .preview-pane:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
1892
1897
  @media (max-width: 820px) {
1893
1898
  body.edit:has(#panel) { display: grid; grid-template-columns: 52px minmax(0, 1fr); grid-template-rows: 50dvh 50dvh; height: 100dvh; min-height: 0; overflow: hidden; }
@@ -3318,7 +3323,7 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
3318
3323
  const entryMain = (site, e) => {
3319
3324
  if (e.url && /^https?:\/\//i.test(e.url)) {
3320
3325
  const title = docDisplayName(e.frontmatter, e.id);
3321
- return `<article><section class="document-web" data-web-url="${escapeHtml(e.url)}" data-title="${escapeHtml(title)}"><div class="document-web-tools"><span>${escapeHtml(e.url)}</span><a href="${escapeHtml(e.url)}" data-web-open data-i18n="Open externally">Open externally</a></div><p data-web-status role="status" data-i18n="Loading website…">Loading website…</p></section></article>`;
3326
+ return `<article><section class="document-web" data-web-url="${escapeHtml(e.url)}" data-title="${escapeHtml(title)}"><div class="document-web-notice"><p data-web-status role="status" data-i18n="Loading website…">Loading website…</p><a href="${escapeHtml(e.url)}" data-web-open data-i18n="Open externally" hidden>Open externally</a></div></section></article>`;
3322
3327
  }
3323
3328
  if (e.url && pageUrlKind(e.url) === "file")
3324
3329
  return (linkedFilePage(site, e.url)?.main ??
@@ -1,7 +1,6 @@
1
1
  /** Self-contained so live readers and standalone HTML use the same click behavior. */
2
2
  export const mountDocumentLinks = (dialog, network = true, request) => {
3
3
  const t = (text) => window.__docsTranslate?.(text) ?? text;
4
- const mobile = () => matchMedia("(max-width: 600px), (hover: none) and (pointer: coarse)").matches;
5
4
  const webUrl = (value) => {
6
5
  if (!value)
7
6
  return;
@@ -45,7 +44,7 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
45
44
  event.preventDefault();
46
45
  window.open(url, "_blank", "noopener,noreferrer");
47
46
  }
48
- else if (link.hasAttribute("data-web-open") || mobile() || !network) {
47
+ else if (link.hasAttribute("data-web-open") || !network) {
49
48
  event.preventDefault();
50
49
  void confirm(url);
51
50
  }
@@ -55,16 +54,19 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
55
54
  const mounted = new WeakSet();
56
55
  const mount = () => {
57
56
  for (const host of document.querySelectorAll(".document-web[data-web-url]")) {
58
- if (mounted.has(host))
57
+ if (mounted.has(host) || host.querySelector(".document-web-frame"))
59
58
  continue;
60
59
  mounted.add(host);
61
60
  const url = webUrl(host.dataset.webUrl);
61
+ const notice = host.querySelector(".document-web-notice");
62
62
  const status = host.querySelector("[data-web-status]");
63
- if (!url || !status)
63
+ const external = host.querySelector("[data-web-open]");
64
+ if (!url || !notice || !status || !external)
64
65
  continue;
65
- if (mobile() || !network) {
66
+ if (!network) {
66
67
  status.dataset.i18n = "Open this website externally to view it.";
67
68
  status.textContent = t(status.dataset.i18n);
69
+ external.hidden = false;
68
70
  void confirm(url);
69
71
  continue;
70
72
  }
@@ -73,32 +75,40 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
73
75
  frame.title = host.dataset.title || url;
74
76
  frame.referrerPolicy = "no-referrer";
75
77
  frame.sandbox.add("allow-scripts", "allow-forms", "allow-popups");
76
- let failed = false;
77
- const fail = (message = "This website could not be displayed here. Open it externally?") => {
78
- if (failed)
78
+ let blocked = false;
79
+ const showStatus = (message) => {
80
+ if (blocked || !host.isConnected)
79
81
  return;
80
- failed = true;
81
- clearTimeout(timer);
82
- document.removeEventListener("securitypolicyviolation", violation);
83
- if (!host.isConnected)
84
- return;
85
- status.hidden = false;
82
+ notice.hidden = false;
86
83
  status.dataset.i18n = message;
87
84
  status.textContent = t(message);
85
+ };
86
+ const denied = () => {
87
+ if (blocked || !host.isConnected)
88
+ return;
89
+ const message = "This website could not be displayed here. Open it externally?";
90
+ showStatus(message);
91
+ blocked = true;
92
+ clearTimeout(timer);
93
+ document.removeEventListener("securitypolicyviolation", violation);
94
+ external.hidden = false;
88
95
  void confirm(url, message);
89
96
  };
90
- const timer = setTimeout(() => fail("This website has not loaded. Open it externally?"), 12000);
91
- frame.onerror = () => fail();
97
+ const timer = setTimeout(() => showStatus("This website has not loaded."), 12000);
98
+ frame.onerror = () => {
99
+ clearTimeout(timer);
100
+ showStatus("This website could not be loaded.");
101
+ };
92
102
  frame.onload = () => {
93
103
  clearTimeout(timer);
94
104
  document.removeEventListener("securitypolicyviolation", violation);
95
- if (!failed)
96
- status.hidden = true;
105
+ if (!blocked)
106
+ notice.hidden = true;
97
107
  };
98
- // shortcut: Browsers hide some cross-origin frame denials; retain the explicit external action.
108
+ // shortcut: Browsers hide some cross-origin frame denials; retain new-tab navigation as a fallback.
99
109
  const violation = (event) => {
100
110
  if (event.effectiveDirective === "frame-src" && event.blockedURI === url)
101
- fail();
111
+ denied();
102
112
  };
103
113
  document.addEventListener("securitypolicyviolation", violation);
104
114
  frame.src = url;
@@ -107,7 +117,7 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
107
117
  void request(`/api/frame-policy?url=${encodeURIComponent(host.dataset.webUrl ?? url)}&parent=${encodeURIComponent(location.origin)}`)
108
118
  .then(async (response) => {
109
119
  if (response.ok && (await response.json()).blocked === true)
110
- fail();
120
+ denied();
111
121
  })
112
122
  .catch(() => { });
113
123
  }
@@ -448,6 +448,7 @@
448
448
  "Open this website in a new tab?": "Open this website in a new tab?",
449
449
  "Open this website externally to view it.": "Open this website externally to view it.",
450
450
  "This website could not be displayed here. Open it externally?": "This website could not be displayed here. Open it externally?",
451
- "This website has not loaded. Open it externally?": "This website has not loaded. Open it externally?",
451
+ "This website has not loaded.": "This website has not loaded.",
452
+ "This website could not be loaded.": "This website could not be loaded.",
452
453
  "Loading website…": "Loading website…"
453
454
  }
@@ -448,6 +448,7 @@
448
448
  "Open this website in a new tab?": "このWebサイトを新しいタブで開きますか?",
449
449
  "Open this website externally to view it.": "このWebサイトは外部で開いて表示できます。",
450
450
  "This website could not be displayed here. Open it externally?": "ここではWebサイトを表示できませんでした。外部で開きますか?",
451
- "This website has not loaded. Open it externally?": "Webサイトの読み込みが完了していません。外部で開きますか?",
451
+ "This website has not loaded.": "Webサイトの読み込みが完了していません。",
452
+ "This website could not be loaded.": "Webサイトを読み込めませんでした。",
452
453
  "Loading website…": "Webサイトを読み込み中…"
453
454
  }
@@ -448,6 +448,7 @@
448
448
  "Open this website in a new tab?": "在新标签页中打开此网站?",
449
449
  "Open this website externally to view it.": "请在外部打开此网站。",
450
450
  "This website could not be displayed here. Open it externally?": "无法在此显示该网站。在外部打开?",
451
- "This website has not loaded. Open it externally?": "此网站尚未加载。在外部打开?",
451
+ "This website has not loaded.": "此网站尚未加载。",
452
+ "This website could not be loaded.": "无法加载此网站。",
452
453
  "Loading website…": "正在加载网站…"
453
454
  }