@atlaskit/media-document-viewer 0.1.0 → 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.
Files changed (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/annotations.compiled.css +13 -0
  3. package/dist/cjs/annotations.js +79 -0
  4. package/dist/cjs/documentLinks.js +49 -0
  5. package/dist/cjs/page.js +7 -0
  6. package/dist/es2019/annotations.compiled.css +13 -0
  7. package/dist/es2019/annotations.js +77 -0
  8. package/dist/es2019/documentLinks.js +41 -0
  9. package/dist/es2019/page.js +8 -1
  10. package/dist/es2019/usePageContent.js +2 -2
  11. package/dist/es2019/utils/useCachedGetImage.js +2 -2
  12. package/dist/es2019/utils/useIntersectionObserver.js +2 -2
  13. package/dist/es2019/utils/useStaticCallback.js +1 -1
  14. package/dist/esm/annotations.compiled.css +13 -0
  15. package/dist/esm/annotations.js +71 -0
  16. package/dist/esm/documentLinks.js +41 -0
  17. package/dist/esm/page.js +7 -0
  18. package/dist/esm/usePageContent.js +2 -2
  19. package/dist/esm/utils/useCachedGetImage.js +2 -2
  20. package/dist/esm/utils/useIntersectionObserver.js +2 -2
  21. package/dist/esm/utils/useStaticCallback.js +1 -1
  22. package/dist/types/annotations.d.ts +13 -0
  23. package/dist/types/documentLinks.d.ts +5 -0
  24. package/dist/types/documentViewer.d.ts +1 -1
  25. package/dist/types/page.d.ts +1 -1
  26. package/dist/types/types.d.ts +37 -0
  27. package/dist/types/usePageContent.d.ts +1 -1
  28. package/dist/types-ts4.5/annotations.d.ts +13 -0
  29. package/dist/types-ts4.5/documentLinks.d.ts +5 -0
  30. package/dist/types-ts4.5/documentViewer.d.ts +1 -1
  31. package/dist/types-ts4.5/page.d.ts +1 -1
  32. package/dist/types-ts4.5/types.d.ts +37 -0
  33. package/dist/types-ts4.5/usePageContent.d.ts +1 -1
  34. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1 +1,9 @@
1
1
  # @atlaskit/media-document-viewer
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#172332](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/172332)
8
+ [`29b26fc9964d8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/29b26fc9964d8) -
9
+ Added support for forms and links in documents
@@ -0,0 +1,13 @@
1
+
2
+ ._19itglyw{border:none}._19bvidpf{padding-left:0}
3
+ ._1bah1yb4{justify-content:space-between}
4
+ ._1bsb1osq{width:100%}
5
+ ._1e0c11p5{display:grid}
6
+ ._4cvr1h6o{align-items:center}
7
+ ._4t3i1osq{height:100%}
8
+ ._ca0qidpf{padding-top:0}
9
+ ._kqswstnw{position:absolute}
10
+ ._n3tdidpf{padding-bottom:0}
11
+ ._r06hglyw{-webkit-appearance:none;appearance:none}
12
+ ._u5f3idpf{padding-right:0}
13
+ ._yv0e1ghl{grid-template-columns:1fr auto}
@@ -0,0 +1,79 @@
1
+ /* annotations.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.TextInputFormField = exports.ComboBoxFormField = exports.Annotations = void 0;
10
+ require("./annotations.compiled.css");
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _runtime = require("@compiled/react/runtime");
13
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+ var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-down"));
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
17
+ /* eslint-disable @atlaskit/ui-styling-standard/enforce-style-prop */
18
+ var formInputBaseStyles = null;
19
+ var textInputStyles = null;
20
+ var foreignObjectProps = {
21
+ xmlns: 'http://www.w3.org/1999/xhtml'
22
+ };
23
+ var TextInputFormField = exports.TextInputFormField = function TextInputFormField(_ref) {
24
+ var field = _ref.field,
25
+ dataTestId = _ref.dataTestId;
26
+ return /*#__PURE__*/React.createElement("foreignObject", {
27
+ x: field.x,
28
+ y: -field.y,
29
+ width: field.w,
30
+ height: field.h,
31
+ "data-testid": dataTestId
32
+ }, /*#__PURE__*/React.createElement("input", (0, _extends2.default)({}, foreignObjectProps, {
33
+ style: (0, _defineProperty2.default)({}, 'fontSize', "".concat(field.f, "px")),
34
+ type: "text",
35
+ value: field.text,
36
+ readOnly: true,
37
+ className: (0, _runtime.ax)(["_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _r06hglyw", "_kqswstnw _4t3i1osq _1bsb1osq"])
38
+ })));
39
+ };
40
+ var comboBoxStyles = null;
41
+ var comboBoxInputStyles = null;
42
+ var ComboBoxFormField = exports.ComboBoxFormField = function ComboBoxFormField(_ref3) {
43
+ var field = _ref3.field,
44
+ dataTestId = _ref3.dataTestId;
45
+ return /*#__PURE__*/React.createElement("foreignObject", {
46
+ x: field.x,
47
+ y: -field.y,
48
+ width: field.w,
49
+ height: field.h,
50
+ "data-testid": dataTestId
51
+ }, /*#__PURE__*/React.createElement("div", (0, _extends2.default)({}, foreignObjectProps, {
52
+ className: (0, _runtime.ax)(["_1e0c11p5 _yv0e1ghl _4cvr1h6o _1bah1yb4 _kqswstnw _4t3i1osq _1bsb1osq"])
53
+ }), /*#__PURE__*/React.createElement("input", {
54
+ style: (0, _defineProperty2.default)({}, 'fontSize', "".concat(field.f, "px")),
55
+ type: "text",
56
+ value: field.text,
57
+ readOnly: true,
58
+ className: (0, _runtime.ax)(["_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _r06hglyw", "_1bsb1osq"])
59
+ }), /*#__PURE__*/React.createElement(_chevronDown.default, {
60
+ label: "",
61
+ size: "small"
62
+ })));
63
+ };
64
+ var Annotations = exports.Annotations = function Annotations(_ref5) {
65
+ var annotations = _ref5.annotations;
66
+ return /*#__PURE__*/React.createElement("div", null, annotations.text_form_fields.map(function (field, i) {
67
+ return /*#__PURE__*/React.createElement(TextInputFormField, {
68
+ field: field,
69
+ dataTestId: "text-form-field-".concat(i),
70
+ key: i
71
+ });
72
+ }), annotations.combobox_form_fields.map(function (field, i) {
73
+ return /*#__PURE__*/React.createElement(ComboBoxFormField, {
74
+ field: field,
75
+ dataTestId: "combobox-form-field-".concat(i),
76
+ key: i
77
+ });
78
+ }));
79
+ };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DocumentLinks = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _anchor = _interopRequireDefault(require("@atlaskit/primitives/anchor"));
11
+ /* eslint-disable @atlaskit/ui-styling-standard/enforce-style-prop */
12
+
13
+ var foreignObjectProps = {
14
+ xmlns: 'http://www.w3.org/1999/xhtml'
15
+ };
16
+ var anchorStyles = {
17
+ display: 'block',
18
+ width: '100%',
19
+ height: '100%'
20
+ };
21
+ var DocumentLink = function DocumentLink(_ref) {
22
+ var link = _ref.link,
23
+ dataTestId = _ref.dataTestId;
24
+ return /*#__PURE__*/_react.default.createElement("foreignObject", {
25
+ x: link.x,
26
+ y: -link.y,
27
+ width: link.w,
28
+ height: link.h,
29
+ "data-testid": dataTestId
30
+ }, link.type === 'uri' ? /*#__PURE__*/_react.default.createElement(_anchor.default, (0, _extends2.default)({}, foreignObjectProps, {
31
+ href: link.dest,
32
+ target: "_blank",
33
+ rel: "noopener noreferrer",
34
+ style: anchorStyles
35
+ })) : /*#__PURE__*/_react.default.createElement(_anchor.default, (0, _extends2.default)({}, foreignObjectProps, {
36
+ href: "#page-".concat(link.p_num + 1),
37
+ style: anchorStyles
38
+ })));
39
+ };
40
+ var DocumentLinks = exports.DocumentLinks = function DocumentLinks(_ref2) {
41
+ var links = _ref2.links;
42
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, links.map(function (link, i) {
43
+ return /*#__PURE__*/_react.default.createElement(DocumentLink, {
44
+ link: link,
45
+ dataTestId: "document-link-".concat(i),
46
+ key: i
47
+ });
48
+ }));
49
+ };
package/dist/cjs/page.js CHANGED
@@ -13,6 +13,8 @@ var React = _react;
13
13
  var _runtime = require("@compiled/react/runtime");
14
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _annotations = require("./annotations");
17
+ var _documentLinks = require("./documentLinks");
16
18
  var _getDocumentRoot = require("./utils/getDocumentRoot");
17
19
  var _useIntersectionObserver = require("./utils/useIntersectionObserver");
18
20
  var _useStaticCallback = require("./utils/useStaticCallback");
@@ -81,6 +83,7 @@ var PageView = /*#__PURE__*/(0, _react.forwardRef)(function (_ref4, ref) {
81
83
  ref: ref,
82
84
  style: style,
83
85
  "data-testid": "page-".concat(pageIndex),
86
+ id: "page-".concat(pageIndex + 1),
84
87
  className: (0, _runtime.ax)(["_kqswh2mm _bfhku67f"])
85
88
  }, imageSrc && /*#__PURE__*/React.createElement("img", {
86
89
  style: style,
@@ -103,6 +106,10 @@ var PageView = /*#__PURE__*/(0, _react.forwardRef)(function (_ref4, ref) {
103
106
  fonts: fonts,
104
107
  key: i
105
108
  });
109
+ }), content.annotations && /*#__PURE__*/React.createElement(_annotations.Annotations, {
110
+ annotations: content.annotations
111
+ }), content.links && /*#__PURE__*/React.createElement(_documentLinks.DocumentLinks, {
112
+ links: content.links
106
113
  })));
107
114
  });
108
115
  var Page = exports.Page = function Page(_ref5) {
@@ -0,0 +1,13 @@
1
+
2
+ ._19itglyw{border:none}._19bvidpf{padding-left:0}
3
+ ._1bah1yb4{justify-content:space-between}
4
+ ._1bsb1osq{width:100%}
5
+ ._1e0c11p5{display:grid}
6
+ ._4cvr1h6o{align-items:center}
7
+ ._4t3i1osq{height:100%}
8
+ ._ca0qidpf{padding-top:0}
9
+ ._kqswstnw{position:absolute}
10
+ ._n3tdidpf{padding-bottom:0}
11
+ ._r06hglyw{-webkit-appearance:none;appearance:none}
12
+ ._u5f3idpf{padding-right:0}
13
+ ._yv0e1ghl{grid-template-columns:1fr auto}
@@ -0,0 +1,77 @@
1
+ /* annotations.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import "./annotations.compiled.css";
4
+ import * as React from 'react';
5
+ import { ax, ix } from "@compiled/react/runtime";
6
+ /* eslint-disable @atlaskit/ui-styling-standard/enforce-style-prop */
7
+
8
+ import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
9
+ const formInputBaseStyles = null;
10
+ const textInputStyles = null;
11
+ const foreignObjectProps = {
12
+ xmlns: 'http://www.w3.org/1999/xhtml'
13
+ };
14
+ export const TextInputFormField = ({
15
+ field,
16
+ dataTestId
17
+ }) => {
18
+ return /*#__PURE__*/React.createElement("foreignObject", {
19
+ x: field.x,
20
+ y: -field.y,
21
+ width: field.w,
22
+ height: field.h,
23
+ "data-testid": dataTestId
24
+ }, /*#__PURE__*/React.createElement("input", _extends({}, foreignObjectProps, {
25
+ style: {
26
+ ['fontSize']: `${field.f}px`
27
+ },
28
+ type: "text",
29
+ value: field.text,
30
+ readOnly: true,
31
+ className: ax(["_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _r06hglyw", "_kqswstnw _4t3i1osq _1bsb1osq"])
32
+ })));
33
+ };
34
+ const comboBoxStyles = null;
35
+ const comboBoxInputStyles = null;
36
+ export const ComboBoxFormField = ({
37
+ field,
38
+ dataTestId
39
+ }) => {
40
+ return /*#__PURE__*/React.createElement("foreignObject", {
41
+ x: field.x,
42
+ y: -field.y,
43
+ width: field.w,
44
+ height: field.h,
45
+ "data-testid": dataTestId
46
+ }, /*#__PURE__*/React.createElement("div", _extends({}, foreignObjectProps, {
47
+ className: ax(["_1e0c11p5 _yv0e1ghl _4cvr1h6o _1bah1yb4 _kqswstnw _4t3i1osq _1bsb1osq"])
48
+ }), /*#__PURE__*/React.createElement("input", {
49
+ style: {
50
+ ['fontSize']: `${field.f}px`
51
+ },
52
+ type: "text",
53
+ value: field.text,
54
+ readOnly: true,
55
+ className: ax(["_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _r06hglyw", "_1bsb1osq"])
56
+ }), /*#__PURE__*/React.createElement(ChevronDownIcon, {
57
+ label: "",
58
+ size: "small"
59
+ })));
60
+ };
61
+ export const Annotations = ({
62
+ annotations
63
+ }) => {
64
+ return /*#__PURE__*/React.createElement("div", null, annotations.text_form_fields.map((field, i) => {
65
+ return /*#__PURE__*/React.createElement(TextInputFormField, {
66
+ field: field,
67
+ dataTestId: `text-form-field-${i}`,
68
+ key: i
69
+ });
70
+ }), annotations.combobox_form_fields.map((field, i) => {
71
+ return /*#__PURE__*/React.createElement(ComboBoxFormField, {
72
+ field: field,
73
+ dataTestId: `combobox-form-field-${i}`,
74
+ key: i
75
+ });
76
+ }));
77
+ };
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlaskit/ui-styling-standard/enforce-style-prop */
3
+ import React from 'react';
4
+ import Anchor from '@atlaskit/primitives/anchor';
5
+ const foreignObjectProps = {
6
+ xmlns: 'http://www.w3.org/1999/xhtml'
7
+ };
8
+ const anchorStyles = {
9
+ display: 'block',
10
+ width: '100%',
11
+ height: '100%'
12
+ };
13
+ const DocumentLink = ({
14
+ link,
15
+ dataTestId
16
+ }) => {
17
+ return /*#__PURE__*/React.createElement("foreignObject", {
18
+ x: link.x,
19
+ y: -link.y,
20
+ width: link.w,
21
+ height: link.h,
22
+ "data-testid": dataTestId
23
+ }, link.type === 'uri' ? /*#__PURE__*/React.createElement(Anchor, _extends({}, foreignObjectProps, {
24
+ href: link.dest,
25
+ target: "_blank",
26
+ rel: "noopener noreferrer",
27
+ style: anchorStyles
28
+ })) : /*#__PURE__*/React.createElement(Anchor, _extends({}, foreignObjectProps, {
29
+ href: `#page-${link.p_num + 1}`,
30
+ style: anchorStyles
31
+ })));
32
+ };
33
+ export const DocumentLinks = ({
34
+ links
35
+ }) => {
36
+ return /*#__PURE__*/React.createElement(React.Fragment, null, links.map((link, i) => /*#__PURE__*/React.createElement(DocumentLink, {
37
+ link: link,
38
+ dataTestId: `document-link-${i}`,
39
+ key: i
40
+ })));
41
+ };
@@ -3,6 +3,8 @@ import "./page.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
5
  import { forwardRef, useEffect, useState } from 'react';
6
+ import { Annotations } from './annotations';
7
+ import { DocumentLinks } from './documentLinks';
6
8
  import { getDocumentRoot } from './utils/getDocumentRoot';
7
9
  import { useIntersectionObserver } from './utils/useIntersectionObserver';
8
10
  import { useStaticCallback } from './utils/useStaticCallback';
@@ -71,6 +73,7 @@ const PageView = /*#__PURE__*/forwardRef(({
71
73
  ref: ref,
72
74
  style: style,
73
75
  "data-testid": `page-${pageIndex}`,
76
+ id: `page-${pageIndex + 1}`,
74
77
  className: ax(["_kqswh2mm _bfhku67f"])
75
78
  }, imageSrc && /*#__PURE__*/React.createElement("img", {
76
79
  style: style,
@@ -91,7 +94,11 @@ const PageView = /*#__PURE__*/forwardRef(({
91
94
  rotation: line.r,
92
95
  fonts: fonts,
93
96
  key: i
94
- }))));
97
+ })), content.annotations && /*#__PURE__*/React.createElement(Annotations, {
98
+ annotations: content.annotations
99
+ }), content.links && /*#__PURE__*/React.createElement(DocumentLinks, {
100
+ links: content.links
101
+ })));
95
102
  });
96
103
  export const Page = ({
97
104
  getPageSrc,
@@ -1,5 +1,5 @@
1
- import { useMemo, useRef, useState } from "react";
2
- import { useStaticCallback } from "./utils/useStaticCallback";
1
+ import { useMemo, useRef, useState } from 'react';
2
+ import { useStaticCallback } from './utils/useStaticCallback';
3
3
  export function usePageContent(getContent, paginationSize) {
4
4
  const [contentRanges, setContentRanges] = useState([]);
5
5
  const contentRangesRequestRef = useRef({});
@@ -1,5 +1,5 @@
1
- import { useRef } from "react";
2
- import { useStaticCallback } from "./useStaticCallback";
1
+ import { useRef } from 'react';
2
+ import { useStaticCallback } from './useStaticCallback';
3
3
  export const useCachedGetImage = getPageImageUrl => {
4
4
  const imageUrlRefs = useRef({});
5
5
  const getImageUrl = useStaticCallback(async (pageNumber, zoom) => {
@@ -1,5 +1,5 @@
1
- import { useEffect, useRef } from "react";
2
- import { useStaticCallback } from "./useStaticCallback";
1
+ import { useEffect, useRef } from 'react';
2
+ import { useStaticCallback } from './useStaticCallback';
3
3
  export const useIntersectionObserver = (options, onVisible) => {
4
4
  const staticOnVisible = useStaticCallback(onVisible);
5
5
  const observerRef = useRef(null);
@@ -1,4 +1,4 @@
1
- import { useCallback, useRef } from "react";
1
+ import { useCallback, useRef } from 'react';
2
2
  export const useStaticCallback = callback => {
3
3
  const callbackRef = useRef(callback);
4
4
  callbackRef.current = callback;
@@ -0,0 +1,13 @@
1
+
2
+ ._19itglyw{border:none}._19bvidpf{padding-left:0}
3
+ ._1bah1yb4{justify-content:space-between}
4
+ ._1bsb1osq{width:100%}
5
+ ._1e0c11p5{display:grid}
6
+ ._4cvr1h6o{align-items:center}
7
+ ._4t3i1osq{height:100%}
8
+ ._ca0qidpf{padding-top:0}
9
+ ._kqswstnw{position:absolute}
10
+ ._n3tdidpf{padding-bottom:0}
11
+ ._r06hglyw{-webkit-appearance:none;appearance:none}
12
+ ._u5f3idpf{padding-right:0}
13
+ ._yv0e1ghl{grid-template-columns:1fr auto}
@@ -0,0 +1,71 @@
1
+ /* annotations.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import "./annotations.compiled.css";
5
+ import * as React from 'react';
6
+ import { ax, ix } from "@compiled/react/runtime";
7
+ /* eslint-disable @atlaskit/ui-styling-standard/enforce-style-prop */
8
+
9
+ import ChevronDownIcon from '@atlaskit/icon/core/chevron-down';
10
+ var formInputBaseStyles = null;
11
+ var textInputStyles = null;
12
+ var foreignObjectProps = {
13
+ xmlns: 'http://www.w3.org/1999/xhtml'
14
+ };
15
+ export var TextInputFormField = function TextInputFormField(_ref) {
16
+ var field = _ref.field,
17
+ dataTestId = _ref.dataTestId;
18
+ return /*#__PURE__*/React.createElement("foreignObject", {
19
+ x: field.x,
20
+ y: -field.y,
21
+ width: field.w,
22
+ height: field.h,
23
+ "data-testid": dataTestId
24
+ }, /*#__PURE__*/React.createElement("input", _extends({}, foreignObjectProps, {
25
+ style: _defineProperty({}, 'fontSize', "".concat(field.f, "px")),
26
+ type: "text",
27
+ value: field.text,
28
+ readOnly: true,
29
+ className: ax(["_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _r06hglyw", "_kqswstnw _4t3i1osq _1bsb1osq"])
30
+ })));
31
+ };
32
+ var comboBoxStyles = null;
33
+ var comboBoxInputStyles = null;
34
+ export var ComboBoxFormField = function ComboBoxFormField(_ref3) {
35
+ var field = _ref3.field,
36
+ dataTestId = _ref3.dataTestId;
37
+ return /*#__PURE__*/React.createElement("foreignObject", {
38
+ x: field.x,
39
+ y: -field.y,
40
+ width: field.w,
41
+ height: field.h,
42
+ "data-testid": dataTestId
43
+ }, /*#__PURE__*/React.createElement("div", _extends({}, foreignObjectProps, {
44
+ className: ax(["_1e0c11p5 _yv0e1ghl _4cvr1h6o _1bah1yb4 _kqswstnw _4t3i1osq _1bsb1osq"])
45
+ }), /*#__PURE__*/React.createElement("input", {
46
+ style: _defineProperty({}, 'fontSize', "".concat(field.f, "px")),
47
+ type: "text",
48
+ value: field.text,
49
+ readOnly: true,
50
+ className: ax(["_19itglyw _ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _r06hglyw", "_1bsb1osq"])
51
+ }), /*#__PURE__*/React.createElement(ChevronDownIcon, {
52
+ label: "",
53
+ size: "small"
54
+ })));
55
+ };
56
+ export var Annotations = function Annotations(_ref5) {
57
+ var annotations = _ref5.annotations;
58
+ return /*#__PURE__*/React.createElement("div", null, annotations.text_form_fields.map(function (field, i) {
59
+ return /*#__PURE__*/React.createElement(TextInputFormField, {
60
+ field: field,
61
+ dataTestId: "text-form-field-".concat(i),
62
+ key: i
63
+ });
64
+ }), annotations.combobox_form_fields.map(function (field, i) {
65
+ return /*#__PURE__*/React.createElement(ComboBoxFormField, {
66
+ field: field,
67
+ dataTestId: "combobox-form-field-".concat(i),
68
+ key: i
69
+ });
70
+ }));
71
+ };
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlaskit/ui-styling-standard/enforce-style-prop */
3
+ import React from 'react';
4
+ import Anchor from '@atlaskit/primitives/anchor';
5
+ var foreignObjectProps = {
6
+ xmlns: 'http://www.w3.org/1999/xhtml'
7
+ };
8
+ var anchorStyles = {
9
+ display: 'block',
10
+ width: '100%',
11
+ height: '100%'
12
+ };
13
+ var DocumentLink = function DocumentLink(_ref) {
14
+ var link = _ref.link,
15
+ dataTestId = _ref.dataTestId;
16
+ return /*#__PURE__*/React.createElement("foreignObject", {
17
+ x: link.x,
18
+ y: -link.y,
19
+ width: link.w,
20
+ height: link.h,
21
+ "data-testid": dataTestId
22
+ }, link.type === 'uri' ? /*#__PURE__*/React.createElement(Anchor, _extends({}, foreignObjectProps, {
23
+ href: link.dest,
24
+ target: "_blank",
25
+ rel: "noopener noreferrer",
26
+ style: anchorStyles
27
+ })) : /*#__PURE__*/React.createElement(Anchor, _extends({}, foreignObjectProps, {
28
+ href: "#page-".concat(link.p_num + 1),
29
+ style: anchorStyles
30
+ })));
31
+ };
32
+ export var DocumentLinks = function DocumentLinks(_ref2) {
33
+ var links = _ref2.links;
34
+ return /*#__PURE__*/React.createElement(React.Fragment, null, links.map(function (link, i) {
35
+ return /*#__PURE__*/React.createElement(DocumentLink, {
36
+ link: link,
37
+ dataTestId: "document-link-".concat(i),
38
+ key: i
39
+ });
40
+ }));
41
+ };
package/dist/esm/page.js CHANGED
@@ -5,6 +5,8 @@ import "./page.compiled.css";
5
5
  import * as React from 'react';
6
6
  import { ax, ix } from "@compiled/react/runtime";
7
7
  import { forwardRef, useEffect, useState } from 'react';
8
+ import { Annotations } from './annotations';
9
+ import { DocumentLinks } from './documentLinks';
8
10
  import { getDocumentRoot } from './utils/getDocumentRoot';
9
11
  import { useIntersectionObserver } from './utils/useIntersectionObserver';
10
12
  import { useStaticCallback } from './utils/useStaticCallback';
@@ -72,6 +74,7 @@ var PageView = /*#__PURE__*/forwardRef(function (_ref4, ref) {
72
74
  ref: ref,
73
75
  style: style,
74
76
  "data-testid": "page-".concat(pageIndex),
77
+ id: "page-".concat(pageIndex + 1),
75
78
  className: ax(["_kqswh2mm _bfhku67f"])
76
79
  }, imageSrc && /*#__PURE__*/React.createElement("img", {
77
80
  style: style,
@@ -94,6 +97,10 @@ var PageView = /*#__PURE__*/forwardRef(function (_ref4, ref) {
94
97
  fonts: fonts,
95
98
  key: i
96
99
  });
100
+ }), content.annotations && /*#__PURE__*/React.createElement(Annotations, {
101
+ annotations: content.annotations
102
+ }), content.links && /*#__PURE__*/React.createElement(DocumentLinks, {
103
+ links: content.links
97
104
  })));
98
105
  });
99
106
  export var Page = function Page(_ref5) {
@@ -2,8 +2,8 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import { useMemo, useRef, useState } from "react";
6
- import { useStaticCallback } from "./utils/useStaticCallback";
5
+ import { useMemo, useRef, useState } from 'react';
6
+ import { useStaticCallback } from './utils/useStaticCallback';
7
7
  export function usePageContent(getContent, paginationSize) {
8
8
  var _useState = useState([]),
9
9
  _useState2 = _slicedToArray(_useState, 2),
@@ -1,7 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { useRef } from "react";
4
- import { useStaticCallback } from "./useStaticCallback";
3
+ import { useRef } from 'react';
4
+ import { useStaticCallback } from './useStaticCallback';
5
5
  export var useCachedGetImage = function useCachedGetImage(getPageImageUrl) {
6
6
  var imageUrlRefs = useRef({});
7
7
  var getImageUrl = useStaticCallback( /*#__PURE__*/function () {
@@ -1,6 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useEffect, useRef } from "react";
3
- import { useStaticCallback } from "./useStaticCallback";
2
+ import { useEffect, useRef } from 'react';
3
+ import { useStaticCallback } from './useStaticCallback';
4
4
  export var useIntersectionObserver = function useIntersectionObserver(options, onVisible) {
5
5
  var staticOnVisible = useStaticCallback(onVisible);
6
6
  var observerRef = useRef(null);
@@ -1,4 +1,4 @@
1
- import { useCallback, useRef } from "react";
1
+ import { useCallback, useRef } from 'react';
2
2
  export var useStaticCallback = function useStaticCallback(callback) {
3
3
  var callbackRef = useRef(callback);
4
4
  callbackRef.current = callback;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { type ComboBoxField, type PageAnnotations, type TextField } from './types';
3
+ export declare const TextInputFormField: ({ field, dataTestId, }: {
4
+ field: TextField;
5
+ dataTestId?: string | undefined;
6
+ }) => JSX.Element;
7
+ export declare const ComboBoxFormField: ({ field, dataTestId, }: {
8
+ field: ComboBoxField;
9
+ dataTestId?: string | undefined;
10
+ }) => JSX.Element;
11
+ export declare const Annotations: ({ annotations }: {
12
+ annotations: PageAnnotations;
13
+ }) => JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { type Link } from './types';
3
+ export declare const DocumentLinks: ({ links }: {
4
+ links: readonly Link[];
5
+ }) => React.JSX.Element;
@@ -6,5 +6,5 @@ type DocumentViewerProps = {
6
6
  paginationSize?: number;
7
7
  zoom: number;
8
8
  };
9
- export declare const DocumentViewer: ({ getContent, getPageImageUrl, paginationSize, zoom }: DocumentViewerProps) => JSX.Element;
9
+ export declare const DocumentViewer: ({ getContent, getPageImageUrl, paginationSize, zoom, }: DocumentViewerProps) => JSX.Element;
10
10
  export {};
@@ -12,5 +12,5 @@ type PageProps = {
12
12
  };
13
13
  onVisible: () => void;
14
14
  };
15
- export declare const Page: ({ getPageSrc, content, fonts, pageIndex, zoom, defaultDimensions, onVisible }: PageProps) => JSX.Element;
15
+ export declare const Page: ({ getPageSrc, content, fonts, pageIndex, zoom, defaultDimensions, onVisible, }: PageProps) => JSX.Element;
16
16
  export {};
@@ -32,6 +32,43 @@ export type PageContent = {
32
32
  width: number;
33
33
  height: number;
34
34
  lines: readonly Line[];
35
+ annotations?: PageAnnotations;
36
+ links?: readonly Link[];
37
+ };
38
+ export type PageAnnotations = {
39
+ text_form_fields: readonly TextField[];
40
+ combobox_form_fields: readonly ComboBoxField[];
41
+ };
42
+ export type TextField = {
43
+ x: number;
44
+ y: number;
45
+ w: number;
46
+ h: number;
47
+ f: number;
48
+ text: string;
49
+ };
50
+ export type ComboBoxField = {
51
+ x: number;
52
+ y: number;
53
+ w: number;
54
+ h: number;
55
+ f: number;
56
+ text: string;
57
+ };
58
+ export type Link = {
59
+ type: 'uri';
60
+ dest: string;
61
+ x: number;
62
+ y: number;
63
+ w: number;
64
+ h: number;
65
+ } | {
66
+ type: 'local';
67
+ p_num: number;
68
+ x: number;
69
+ y: number;
70
+ w: number;
71
+ h: number;
35
72
  };
36
73
  export type PageRangeContent = {
37
74
  start_index: number;
@@ -1,4 +1,4 @@
1
- import { PageRangeContent } from "./types";
1
+ import { PageRangeContent } from './types';
2
2
  export declare function usePageContent(getContent: (startIndex: number, endIndex: number) => Promise<PageRangeContent>, paginationSize: number): {
3
3
  getPageContent: (pageInd: number) => {
4
4
  page: import("./types").PageContent;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { type ComboBoxField, type PageAnnotations, type TextField } from './types';
3
+ export declare const TextInputFormField: ({ field, dataTestId, }: {
4
+ field: TextField;
5
+ dataTestId?: string | undefined;
6
+ }) => JSX.Element;
7
+ export declare const ComboBoxFormField: ({ field, dataTestId, }: {
8
+ field: ComboBoxField;
9
+ dataTestId?: string | undefined;
10
+ }) => JSX.Element;
11
+ export declare const Annotations: ({ annotations }: {
12
+ annotations: PageAnnotations;
13
+ }) => JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { type Link } from './types';
3
+ export declare const DocumentLinks: ({ links }: {
4
+ links: readonly Link[];
5
+ }) => React.JSX.Element;
@@ -6,5 +6,5 @@ type DocumentViewerProps = {
6
6
  paginationSize?: number;
7
7
  zoom: number;
8
8
  };
9
- export declare const DocumentViewer: ({ getContent, getPageImageUrl, paginationSize, zoom }: DocumentViewerProps) => JSX.Element;
9
+ export declare const DocumentViewer: ({ getContent, getPageImageUrl, paginationSize, zoom, }: DocumentViewerProps) => JSX.Element;
10
10
  export {};
@@ -12,5 +12,5 @@ type PageProps = {
12
12
  };
13
13
  onVisible: () => void;
14
14
  };
15
- export declare const Page: ({ getPageSrc, content, fonts, pageIndex, zoom, defaultDimensions, onVisible }: PageProps) => JSX.Element;
15
+ export declare const Page: ({ getPageSrc, content, fonts, pageIndex, zoom, defaultDimensions, onVisible, }: PageProps) => JSX.Element;
16
16
  export {};
@@ -32,6 +32,43 @@ export type PageContent = {
32
32
  width: number;
33
33
  height: number;
34
34
  lines: readonly Line[];
35
+ annotations?: PageAnnotations;
36
+ links?: readonly Link[];
37
+ };
38
+ export type PageAnnotations = {
39
+ text_form_fields: readonly TextField[];
40
+ combobox_form_fields: readonly ComboBoxField[];
41
+ };
42
+ export type TextField = {
43
+ x: number;
44
+ y: number;
45
+ w: number;
46
+ h: number;
47
+ f: number;
48
+ text: string;
49
+ };
50
+ export type ComboBoxField = {
51
+ x: number;
52
+ y: number;
53
+ w: number;
54
+ h: number;
55
+ f: number;
56
+ text: string;
57
+ };
58
+ export type Link = {
59
+ type: 'uri';
60
+ dest: string;
61
+ x: number;
62
+ y: number;
63
+ w: number;
64
+ h: number;
65
+ } | {
66
+ type: 'local';
67
+ p_num: number;
68
+ x: number;
69
+ y: number;
70
+ w: number;
71
+ h: number;
35
72
  };
36
73
  export type PageRangeContent = {
37
74
  start_index: number;
@@ -1,4 +1,4 @@
1
- import { PageRangeContent } from "./types";
1
+ import { PageRangeContent } from './types';
2
2
  export declare function usePageContent(getContent: (startIndex: number, endIndex: number) => Promise<PageRangeContent>, paginationSize: number): {
3
3
  getPageContent: (pageInd: number) => {
4
4
  page: import("./types").PageContent;
package/package.json CHANGED
@@ -29,8 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/css": "^0.10.0",
32
+ "@atlaskit/icon": "^27.0.0",
32
33
  "@atlaskit/primitives": "^14.8.0",
33
- "@atlaskit/tokens": "^5.1.0",
34
+ "@atlaskit/tokens": "^5.2.0",
34
35
  "@babel/runtime": "^7.0.0",
35
36
  "@compiled/react": "^0.18.3"
36
37
  },
@@ -82,7 +83,7 @@
82
83
  }
83
84
  },
84
85
  "name": "@atlaskit/media-document-viewer",
85
- "version": "0.1.0",
86
+ "version": "0.2.0",
86
87
  "description": "Modern and fast document viewer",
87
88
  "author": "Atlassian Pty Ltd",
88
89
  "license": "Apache-2.0",