@dou-ui/code 0.1.0-alpha.0 → 0.1.0-alpha.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.
@@ -15,14 +15,14 @@ export interface CodeMessages {
15
15
  selectAll: string;
16
16
  /** Toolbar button of a language server (`@dou-ui/code/lsp`): go to where the name is defined. */
17
17
  goToDefinition: string;
18
- /** The bar of symbol keys above a phone's keyboard. */
18
+ /** The bar of symbol keys on a touch screen. */
19
19
  keys: string;
20
+ /** The grip that moves the bar of symbol keys. */
21
+ moveKeys: string;
20
22
  /** The Tab key on that bar. */
21
23
  indent: string;
22
- cursorLeft: string;
23
- cursorRight: string;
24
- cursorUp: string;
25
- cursorDown: string;
24
+ /** The stick at the end of the bar of keys, which moves the cursor. */
25
+ moveCursor: string;
26
26
  undo: string;
27
27
  redo: string;
28
28
  error: string;
@@ -69,7 +69,7 @@ export interface CodeEditorProps {
69
69
  /** Replaces any of the editor's texts, which otherwise follow DouUI's locale. */
70
70
  messages?: Partial<CodeMessages>;
71
71
  /**
72
- * The bar of symbol keys above a phone's keyboard, shown on touch screens
72
+ * The bar of symbol keys below the editor, moved by its grip, shown on touch screens
73
73
  * while the editor can be typed in. An array sets the keys that scroll;
74
74
  * a string is a key that types itself. `false` leaves the bar out. On by default.
75
75
  */
@@ -210,7 +210,7 @@ export interface CodeInputProps {
210
210
  * the page by default. `false` keeps them inside the box.
211
211
  */
212
212
  teleport?: string | HTMLElement | false;
213
- /** The bar of symbol keys above a phone's keyboard; off by default. */
213
+ /** The bar of symbol keys below the box, moved by its grip; off by default. */
214
214
  keys?: boolean | ReadonlyArray<CodeKey | string>;
215
215
  messages?: Partial<CodeMessages>;
216
216
  autofocus?: boolean;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The part of the window in view, above a phone's keyboard and inside a
3
+ * pinch zoom, in the coordinates `getBoundingClientRect` gives.
4
+ *
5
+ * Browsers disagree on what those coordinates are relative to: the layout
6
+ * viewport (so the visual viewport sits `offsetTop` into them), or the
7
+ * visual viewport itself (iOS Safari, where adding `offsetTop` counts the
8
+ * scroll twice). The page's own box tells which: the visual viewport's place
9
+ * in the page, plus where the page starts in those coordinates.
10
+ */
11
+ export declare function visibleViewport(): {
12
+ left: number;
13
+ top: number;
14
+ width: number;
15
+ height: number;
16
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ // src/view/viewport.ts
2
+ /**
3
+ * The part of the window in view, above a phone's keyboard and inside a
4
+ * pinch zoom, in the coordinates `getBoundingClientRect` gives.
5
+ *
6
+ * Browsers disagree on what those coordinates are relative to: the layout
7
+ * viewport (so the visual viewport sits `offsetTop` into them), or the
8
+ * visual viewport itself (iOS Safari, where adding `offsetTop` counts the
9
+ * scroll twice). The page's own box tells which: the visual viewport's place
10
+ * in the page, plus where the page starts in those coordinates.
11
+ */
12
+ function visibleViewport() {
13
+ const root = document.documentElement;
14
+ const vv = window.visualViewport;
15
+ if (!vv) return {
16
+ left: 0,
17
+ top: 0,
18
+ width: root.clientWidth,
19
+ height: root.clientHeight
20
+ };
21
+ const page = root.getBoundingClientRect();
22
+ return {
23
+ left: vv.pageLeft + page.left,
24
+ top: vv.pageTop + page.top,
25
+ width: vv.width,
26
+ height: vv.height
27
+ };
28
+ }
29
+ export { visibleViewport };
30
+
31
+ //# sourceMappingURL=viewport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport.js","names":[],"sources":["../../src/view/viewport.ts"],"sourcesContent":["/**\n * The part of the window in view, above a phone's keyboard and inside a\n * pinch zoom, in the coordinates `getBoundingClientRect` gives.\n *\n * Browsers disagree on what those coordinates are relative to: the layout\n * viewport (so the visual viewport sits `offsetTop` into them), or the\n * visual viewport itself (iOS Safari, where adding `offsetTop` counts the\n * scroll twice). The page's own box tells which: the visual viewport's place\n * in the page, plus where the page starts in those coordinates.\n */\nexport function visibleViewport(): { left: number; top: number; width: number; height: number } {\n const root = document.documentElement\n const vv = window.visualViewport\n if (!vv) return { left: 0, top: 0, width: root.clientWidth, height: root.clientHeight }\n const page = root.getBoundingClientRect()\n return {\n left: vv.pageLeft + page.left,\n top: vv.pageTop + page.top,\n width: vv.width,\n height: vv.height,\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,kBAAgF;CAC9F,MAAM,OAAO,SAAS;CACtB,MAAM,KAAK,OAAO;CAClB,IAAI,CAAC,IAAI,OAAO;EAAE,MAAM;EAAG,KAAK;EAAG,OAAO,KAAK;EAAa,QAAQ,KAAK;CAAa;CACtF,MAAM,OAAO,KAAK,sBAAsB;CACxC,OAAO;EACL,MAAM,GAAG,WAAW,KAAK;EACzB,KAAK,GAAG,UAAU,KAAK;EACvB,OAAO,GAAG;EACV,QAAQ,GAAG;CACb;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dou-ui/code",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "DouUI 的代码编辑器:大文件流畅编辑、输入法友好、多光标与协同",
5
5
  "keywords": [
6
6
  "vue",
@@ -63,10 +63,10 @@
63
63
  "build": "vite build && vue-tsc -p tsconfig.build.json && bun scripts/build-style.ts"
64
64
  },
65
65
  "dependencies": {
66
- "@dou-ui/icons": "0.1.0-alpha.0"
66
+ "@dou-ui/icons": "0.1.0-alpha.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "dou-ui": "0.1.0-alpha.0",
69
+ "dou-ui": "0.1.0-alpha.2",
70
70
  "vue": "^3.5.0",
71
71
  "yjs": "^13.6.0",
72
72
  "shiki": "^1.0.0 || ^2.0.0 || ^3.0.0"