@panda-lingo/goldendict 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -20,6 +20,30 @@ await view.lookup("example");
20
20
  Importing the package registers `<goldendict-view>` automatically. Call
21
21
  `defineGoldendictView("my-dictionary-view")` when a custom tag name is useful.
22
22
 
23
+ The component is responsive by default. It fills the width of its containing
24
+ layout, uses container-aware host chrome, and remeasures article height whenever
25
+ its iframe reflows. A separate browser override layer constrains legacy
26
+ fixed-width dictionary media, makes wide tables and preformatted text locally
27
+ scrollable, unwraps common floated wiki panels on narrow screens, and keeps
28
+ article headers usable with coarse pointers. The pinned GoldenDict-ng CSS stays
29
+ unchanged so upstream updates remain straightforward.
30
+
31
+ ```css
32
+ .dictionary-column {
33
+ min-width: 0;
34
+ }
35
+
36
+ goldendict-view {
37
+ width: 100%;
38
+ max-width: 72rem;
39
+ margin-inline: auto;
40
+ }
41
+ ```
42
+
43
+ Consumer `theme.cssText` is emitted after the responsive layer and can override
44
+ it when a particular dictionary requires different behavior. Set
45
+ `--gd-responsive-gutter` there to customize the article's fluid inner spacing.
46
+
23
47
  The public API includes:
24
48
 
25
49
  - `DictionaryClient` for dictionary listing and lookup, plus the backend's
@@ -35,6 +59,11 @@ explicit `"sandboxed"` policy retains them inside the iframe, which never gets
35
59
  `allow-same-origin`. Lookup, media, and external-link events are cancelable so a
36
60
  host application can replace the default navigation behavior.
37
61
 
62
+ The bundled demo deliberately selects `"sandboxed"` for locally mounted
63
+ dictionaries so script-dependent formats such as OALDPE render with their full
64
+ GoldenDict typography and interactions. This demo choice does not change the
65
+ component's safer `"none"` default for consumers.
66
+
38
67
  In sandboxed mode, external sidecars such as `bres://.../Dictionary-UI.js` are
39
68
  routed through the article's `resourceBaseUrl` without changing filename case.
40
69
  Because the iframe has an opaque origin, dictionary XHR/fetch requests send
@@ -3,7 +3,7 @@ import type { DictionaryClientOptions, GoldenDictTheme, LookupResponse, ScriptPo
3
3
  export declare class GoldenDictView extends HTMLElement {
4
4
  static readonly observedAttributes: string[];
5
5
  readonly instanceId: string;
6
- private readonly frame;
6
+ private frame;
7
7
  private readonly statusElement;
8
8
  private readonly brandElement;
9
9
  private readonly brandImage;
@@ -11,6 +11,8 @@ export declare class GoldenDictView extends HTMLElement {
11
11
  private clientValue;
12
12
  private requestController?;
13
13
  private requestSequence;
14
+ private renderSequence;
15
+ private activeBridgeInstanceId?;
14
16
  private responseValue?;
15
17
  private themeValue;
16
18
  private stateValue;
@@ -39,6 +41,8 @@ export declare class GoldenDictView extends HTMLElement {
39
41
  clear(): void;
40
42
  scrollToArticle(dictionaryId: string): void;
41
43
  private renderResponse;
44
+ private resetFrame;
45
+ private replaceFrame;
42
46
  private handleFrameLoaded;
43
47
  private readonly handleBridgeMessage;
44
48
  private handleLookupMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"goldendict-view.d.ts","sourceRoot":"","sources":["../../src/element/goldendict-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,KAAK,EAGV,uBAAuB,EAEvB,eAAe,EAEf,cAAc,EAEd,YAAY,EACZ,SAAS,EAEV,MAAM,UAAU,CAAC;AAsClB,qBAAa,cAAe,SAAQ,WAAW;IAC7C,MAAM,CAAC,QAAQ,CAAC,kBAAkB,WAMhC;IAEF,QAAQ,CAAC,UAAU,SAAoB;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,iBAAiB,CAAC,CAAkB;IAC5C,OAAO,CAAC,eAA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