@cu-mkp/editioncrafter 0.0.4 → 0.0.6

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 (152) hide show
  1. package/dist/editioncrafter.min.js +1 -2
  2. package/dist/editioncrafter.min.js.LICENSE.txt +3 -3
  3. package/dist/es/src/component/DocumentView.js +14 -14
  4. package/dist/es/src/component/HelpPopper.js +19 -12
  5. package/dist/es/src/component/ImageGridView.js +4 -6
  6. package/dist/es/src/component/ImageView.js +0 -5
  7. package/dist/es/src/component/JumpToFolio.js +3 -3
  8. package/dist/es/src/component/Navigation.js +1 -1
  9. package/dist/es/src/component/TranscriptionView.js +11 -20
  10. package/dist/es/src/component/Watermark.js +25 -0
  11. package/dist/es/src/component/XMLView.js +21 -83
  12. package/dist/es/src/icons/howtouse-asterisk.png +0 -0
  13. package/dist/es/src/icons/howtouse-beaker.png +0 -0
  14. package/dist/es/src/icons/howtouse-curly.png +0 -0
  15. package/dist/es/src/icons/howtouse-square.png +0 -0
  16. package/dist/es/src/icons/howtouse-ups.png +0 -0
  17. package/dist/es/src/img/banner-about.png +0 -0
  18. package/dist/es/src/img/banner-essays.jpg +0 -0
  19. package/dist/es/src/img/banner-essays.png +0 -0
  20. package/dist/es/src/img/banner-how-to.png +0 -0
  21. package/dist/es/src/img/banner-resources.png +0 -0
  22. package/dist/es/src/img/book-open-cropped.png +0 -0
  23. package/dist/es/src/img/book-open.png +0 -0
  24. package/dist/es/src/img/book-spine.png +0 -0
  25. package/dist/es/src/img/bookcover-cropped.png +0 -0
  26. package/dist/es/src/img/cropped-MKLizardFilled-32x32.jpg +0 -0
  27. package/dist/es/src/img/folio48r-drawing.png +0 -0
  28. package/dist/es/src/img/howtouse-asterisk.png +0 -0
  29. package/dist/es/src/img/howtouse-beaker.png +0 -0
  30. package/dist/es/src/img/howtouse-curly.png +0 -0
  31. package/dist/es/src/img/howtouse-square.png +0 -0
  32. package/dist/es/src/img/howtouse-ups.png +0 -0
  33. package/dist/es/src/img/lizard-no-bg.png +0 -0
  34. package/dist/es/src/img/logo_center_multi_line.png +0 -0
  35. package/dist/es/src/img/logo_center_single_line.png +0 -0
  36. package/dist/es/src/img/logo_columbia.png +0 -0
  37. package/dist/es/src/img/mk-banner-logo.png +0 -0
  38. package/dist/es/src/img/mk-homepage-logo.png +0 -0
  39. package/dist/es/src/img/openseadragon/button_grouphover.png +0 -0
  40. package/dist/es/src/img/openseadragon/button_hover.png +0 -0
  41. package/dist/es/src/img/openseadragon/button_pressed.png +0 -0
  42. package/dist/es/src/img/openseadragon/button_rest.png +0 -0
  43. package/dist/es/src/img/openseadragon/fullpage_grouphover.png +0 -0
  44. package/dist/es/src/img/openseadragon/fullpage_hover.png +0 -0
  45. package/dist/es/src/img/openseadragon/fullpage_pressed.png +0 -0
  46. package/dist/es/src/img/openseadragon/fullpage_rest.png +0 -0
  47. package/dist/es/src/img/openseadragon/home_grouphover.png +0 -0
  48. package/dist/es/src/img/openseadragon/home_hover.png +0 -0
  49. package/dist/es/src/img/openseadragon/home_pressed.png +0 -0
  50. package/dist/es/src/img/openseadragon/home_rest.png +0 -0
  51. package/dist/es/src/img/openseadragon/next_grouphover.png +0 -0
  52. package/dist/es/src/img/openseadragon/next_hover.png +0 -0
  53. package/dist/es/src/img/openseadragon/next_pressed.png +0 -0
  54. package/dist/es/src/img/openseadragon/next_rest.png +0 -0
  55. package/dist/es/src/img/openseadragon/previous_grouphover.png +0 -0
  56. package/dist/es/src/img/openseadragon/previous_hover.png +0 -0
  57. package/dist/es/src/img/openseadragon/previous_pressed.png +0 -0
  58. package/dist/es/src/img/openseadragon/previous_rest.png +0 -0
  59. package/dist/es/src/img/openseadragon/rotateleft_grouphover.png +0 -0
  60. package/dist/es/src/img/openseadragon/rotateleft_hover.png +0 -0
  61. package/dist/es/src/img/openseadragon/rotateleft_pressed.png +0 -0
  62. package/dist/es/src/img/openseadragon/rotateleft_rest.png +0 -0
  63. package/dist/es/src/img/openseadragon/rotateright_grouphover.png +0 -0
  64. package/dist/es/src/img/openseadragon/rotateright_hover.png +0 -0
  65. package/dist/es/src/img/openseadragon/rotateright_pressed.png +0 -0
  66. package/dist/es/src/img/openseadragon/rotateright_rest.png +0 -0
  67. package/dist/es/src/img/openseadragon/zoomin_grouphover.png +0 -0
  68. package/dist/es/src/img/openseadragon/zoomin_hover.png +0 -0
  69. package/dist/es/src/img/openseadragon/zoomin_pressed.png +0 -0
  70. package/dist/es/src/img/openseadragon/zoomin_rest.png +0 -0
  71. package/dist/es/src/img/openseadragon/zoomout_grouphover.png +0 -0
  72. package/dist/es/src/img/openseadragon/zoomout_hover.png +0 -0
  73. package/dist/es/src/img/openseadragon/zoomout_pressed.png +0 -0
  74. package/dist/es/src/img/openseadragon/zoomout_rest.png +0 -0
  75. package/dist/es/src/img/spinner.gif +0 -0
  76. package/dist/es/src/img/text-bg.png +0 -0
  77. package/dist/es/src/img/watermark.png +0 -0
  78. package/dist/es/src/index.js +1 -0
  79. package/dist/es/src/scss/_base.scss +0 -13
  80. package/dist/es/src/scss/_navigation.scss +9 -1
  81. package/dist/es/src/scss/_xmlView.scss +7 -3
  82. package/package.json +6 -12
  83. package/dist/cjs/src/action/CommentActions.js +0 -20
  84. package/dist/cjs/src/action/DiplomaticActions.js +0 -19
  85. package/dist/cjs/src/action/DocumentActions.js +0 -188
  86. package/dist/cjs/src/action/GlossaryActions.js +0 -20
  87. package/dist/cjs/src/action/initialState/commentInitialState.js +0 -13
  88. package/dist/cjs/src/action/initialState/diplomaticInitialState.js +0 -10
  89. package/dist/cjs/src/action/initialState/documentInitialState.js +0 -17
  90. package/dist/cjs/src/action/initialState/glossaryInitialState.js +0 -13
  91. package/dist/cjs/src/action/rootReducer.js +0 -30
  92. package/dist/cjs/src/component/AlphabetLinks.js +0 -76
  93. package/dist/cjs/src/component/CustomizedTooltops.js +0 -173
  94. package/dist/cjs/src/component/DiploMatic.js +0 -90
  95. package/dist/cjs/src/component/DocumentView.js +0 -427
  96. package/dist/cjs/src/component/EditorComment.js +0 -124
  97. package/dist/cjs/src/component/ErrorBoundary.js +0 -71
  98. package/dist/cjs/src/component/FigureImage.js +0 -82
  99. package/dist/cjs/src/component/GlossaryView.js +0 -166
  100. package/dist/cjs/src/component/HelpPopper.js +0 -83
  101. package/dist/cjs/src/component/ImageGridView.js +0 -193
  102. package/dist/cjs/src/component/ImageView.js +0 -125
  103. package/dist/cjs/src/component/ImageZoomControl.js +0 -67
  104. package/dist/cjs/src/component/JumpToFolio.js +0 -103
  105. package/dist/cjs/src/component/Navigation.js +0 -266
  106. package/dist/cjs/src/component/Pagination.js +0 -81
  107. package/dist/cjs/src/component/RouteListener.js +0 -66
  108. package/dist/cjs/src/component/SeaDragonComponent.js +0 -51
  109. package/dist/cjs/src/component/SinglePaneView.js +0 -46
  110. package/dist/cjs/src/component/SplitPaneView.js +0 -164
  111. package/dist/cjs/src/component/TranscriptionView.js +0 -147
  112. package/dist/cjs/src/component/XMLView.js +0 -154
  113. package/dist/cjs/src/globals.d.ts +0 -1
  114. package/dist/cjs/src/hocs/withRouter.js +0 -29
  115. package/dist/cjs/src/icons/ByIcon.js +0 -27
  116. package/dist/cjs/src/icons/CcIcon.js +0 -27
  117. package/dist/cjs/src/icons/NcIcon.js +0 -27
  118. package/dist/cjs/src/icons/SaIcon.js +0 -27
  119. package/dist/cjs/src/icons/SideMenuIconLeft.js +0 -49
  120. package/dist/cjs/src/icons/SideMenuIconRight.js +0 -49
  121. package/dist/cjs/src/index.js +0 -34
  122. package/dist/cjs/src/lib/copyObject.js +0 -11
  123. package/dist/cjs/src/lib/registerServiceWorker.js +0 -95
  124. package/dist/cjs/src/model/DocumentHelper.js +0 -17
  125. package/dist/cjs/src/model/Folio.js +0 -92
  126. package/dist/cjs/src/model/ReduxStore.js +0 -110
  127. package/dist/cjs/src/model/folioLayout.js +0 -416
  128. package/dist/cjs/src/polyfills.js +0 -212
  129. package/dist/cjs/src/saga/RouteListenerSaga.js +0 -198
  130. package/dist/cjs/src/saga/rootSaga.js +0 -23
  131. package/dist/cjs/src/scss/_CETEIcean.scss +0 -914
  132. package/dist/cjs/src/scss/_base.scss +0 -187
  133. package/dist/cjs/src/scss/_diplomatic.scss +0 -332
  134. package/dist/cjs/src/scss/_globalNavigation.scss +0 -34
  135. package/dist/cjs/src/scss/_glossary.scss +0 -105
  136. package/dist/cjs/src/scss/_imageGridView.scss +0 -60
  137. package/dist/cjs/src/scss/_imageView.scss +0 -16
  138. package/dist/cjs/src/scss/_imageZoomControl.scss +0 -51
  139. package/dist/cjs/src/scss/_jumpbox.scss +0 -42
  140. package/dist/cjs/src/scss/_navigation.scss +0 -135
  141. package/dist/cjs/src/scss/_pagination.scss +0 -36
  142. package/dist/cjs/src/scss/_spinner.scss +0 -60
  143. package/dist/cjs/src/scss/_splitPaneView.scss +0 -35
  144. package/dist/cjs/src/scss/_thumbnails.scss +0 -17
  145. package/dist/cjs/src/scss/_transcriptView.scss +0 -178
  146. package/dist/cjs/src/scss/_watermark.scss +0 -19
  147. package/dist/cjs/src/scss/_xmlView.scss +0 -25
  148. package/dist/cjs/src/scss/editioncrafter.scss +0 -109
  149. package/dist/editioncrafter.css +0 -2462
  150. package/dist/editioncrafter.css.map +0 -1
  151. package/dist/editioncrafter.min.js.map +0 -1
  152. package/dist/es/src/polyfills.js +0 -216
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.loadFolio = loadFolio;
7
- var _openseadragon = _interopRequireDefault(require("openseadragon"));
8
- var _axios = _interopRequireDefault(require("axios"));
9
- var _folioLayout = require("./folioLayout");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
- function loadFolio(folioData) {
20
- if (folioData.loading) {
21
- // promise to resolve this immediately
22
- return new Promise(function (resolve) {
23
- resolve(folioData);
24
- });
25
- }
26
- folioData.loading = true;
27
- var folio = _objectSpread({}, folioData);
28
-
29
- // promise to load all the data for this folio
30
- return new Promise(function (resolve, reject) {
31
- var transcriptionTypes = Object.keys(folio.annotationURLs);
32
- if (transcriptionTypes.length > 0) {
33
- _axios["default"].get(folio.image_zoom_url).then(function (imageServerResponse) {
34
- // Handle the image server response
35
- folio.tileSource = new _openseadragon["default"].IIIFTileSource(imageServerResponse.data);
36
- var _iterator = _createForOfIteratorHelper(transcriptionTypes),
37
- _step;
38
- try {
39
- var _loop = function _loop() {
40
- var transcriptionType = _step.value;
41
- var _folio$annotationURLs = folio.annotationURLs[transcriptionType],
42
- htmlURL = _folio$annotationURLs.htmlURL,
43
- xmlURL = _folio$annotationURLs.xmlURL;
44
- if (!folio.transcription) folio.transcription = {};
45
- folio.transcription[transcriptionType] = {};
46
- _axios["default"].all([_axios["default"].get(htmlURL), _axios["default"].get(xmlURL)]).then(_axios["default"].spread(function (htmlResponse, xmlResponse) {
47
- var transcription = parseTranscription(htmlResponse.data, xmlResponse.data);
48
- if (!transcription) {
49
- reject(new Error("Unable to load transcription: ".concat(htmlURL)));
50
- } else {
51
- folio.transcription[transcriptionType] = transcription;
52
- folio.loading = false;
53
- resolve(folio);
54
- }
55
- }))["catch"](function (error) {
56
- folioData.loading = false;
57
- reject(error);
58
- });
59
- };
60
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
61
- _loop();
62
- }
63
- } catch (err) {
64
- _iterator.e(err);
65
- } finally {
66
- _iterator.f();
67
- }
68
- })["catch"](function (error) {
69
- folioData.loading = false;
70
- reject(error);
71
- });
72
- } else {
73
- // if there is no annotatation list, just load the image and provide a blank transcription
74
- _axios["default"].get(folio.image_zoom_url).then(function (imageServerResponse) {
75
- folio.tileSource = new _openseadragon["default"].IIIFTileSource(imageServerResponse.data);
76
- folio.loading = false;
77
- resolve(folio);
78
- })["catch"](function (error) {
79
- folioData.loading = false;
80
- reject(error);
81
- });
82
- }
83
- });
84
- }
85
-
86
- // returns transcription or error message if unable to parse
87
- function parseTranscription(html, xml) {
88
- var transcriptionData = (0, _folioLayout.layoutMargin3)(html);
89
- return _objectSpread(_objectSpread({}, transcriptionData), {}, {
90
- xml: xml
91
- });
92
- }
@@ -1,110 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createReducer = createReducer;
7
- exports.createReduxStore = createReduxStore;
8
- exports.dispatchAction = dispatchAction;
9
- exports.putResolveAction = putResolveAction;
10
- var _redux = require("redux");
11
- var _reduxSaga = _interopRequireDefault(require("redux-saga"));
12
- var _effects = require("redux-saga/effects");
13
- var _rootReducer = _interopRequireDefault(require("../action/rootReducer"));
14
- var _rootSaga = _interopRequireDefault(require("../saga/rootSaga"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
20
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
21
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
22
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
24
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
25
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
26
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
27
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
28
- var _marked = /*#__PURE__*/_regeneratorRuntime().mark(putResolveAction);
29
- // Call this once to create a new redux store that is properly configured.
30
- function createReduxStore(config) {
31
- var sagaMiddleware = (0, _reduxSaga["default"])();
32
- var store = (0, _redux.createStore)((0, _rootReducer["default"])(config), window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(), (0, _redux.applyMiddleware)(sagaMiddleware));
33
- sagaMiddleware.run(_rootSaga["default"]);
34
- return store;
35
- }
36
-
37
- // Dispatch the action with the given parameters.
38
- function dispatchAction(props, action) {
39
- for (var _len = arguments.length, params = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
40
- params[_key - 2] = arguments[_key];
41
- }
42
- props.dispatch({
43
- type: action,
44
- payload: {
45
- params: params,
46
- dispatcher: {
47
- dispatch: props.dispatch
48
- }
49
- }
50
- });
51
- }
52
-
53
- // Dispatch the action via Redux Saga.
54
- function putResolveAction(action) {
55
- var _len2,
56
- params,
57
- _key2,
58
- _args = arguments;
59
- return _regeneratorRuntime().wrap(function putResolveAction$(_context) {
60
- while (1) switch (_context.prev = _context.next) {
61
- case 0:
62
- for (_len2 = _args.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
63
- params[_key2 - 1] = _args[_key2];
64
- }
65
- _context.next = 3;
66
- return (0, _effects.put)({
67
- type: action,
68
- payload: {
69
- params: params
70
- }
71
- });
72
- case 3:
73
- return _context.abrupt("return", _context.sent);
74
- case 4:
75
- case "end":
76
- return _context.stop();
77
- }
78
- }, _marked);
79
- }
80
-
81
- // Take the action and call it with the current redux state.
82
- function reducer(state, actionFn, action) {
83
- var params = action.payload && action.payload.params ? action.payload.params : [];
84
- return actionFn.apply(void 0, [state].concat(_toConsumableArray(params), [action.payload.dispatcher]));
85
- }
86
- function getActionFn(action, actionModule) {
87
- var parts = action.split('.');
88
- return actionModule[parts[1]];
89
- }
90
-
91
- // Create a reducer that only services actions in the action set.
92
- function createReducer(actionModuleName, actionModule, initialState) {
93
- // get the function keys from the module itself
94
- var actionNames = [];
95
- for (var _i = 0, _Object$keys = Object.keys(actionModule); _i < _Object$keys.length; _i++) {
96
- var action = _Object$keys[_i];
97
- actionNames.push("".concat(actionModuleName, ".").concat(action));
98
- }
99
- function scopedReducer() {
100
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
101
- var action = arguments.length > 1 ? arguments[1] : undefined;
102
- var validActions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : actionNames;
103
- var mod = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : actionModule;
104
- if (validActions.includes(action.type)) {
105
- return reducer(state, getActionFn(action.type, mod), action);
106
- }
107
- return _objectSpread({}, state);
108
- }
109
- return scopedReducer;
110
- }
@@ -1,416 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.layoutGrid = layoutGrid;
7
- exports.layoutMargin3 = layoutMargin3;
8
- exports.layoutMargin4 = layoutMargin4;
9
- var _copyObject = _interopRequireDefault(require("../lib/copyObject"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
16
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
- var ROW_CODES = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
19
- var emptyMarginFrame = {
20
- middle: false,
21
- top: false,
22
- 'left-middle': false,
23
- 'right-middle': false,
24
- bottom: false,
25
- 'left-top': false,
26
- 'right-top': false,
27
- 'left-bottom': false,
28
- 'right-bottom': false
29
- };
30
- var hintCodes = ['tall', 'extra-tall', 'wide', 'full'];
31
- function layoutMargin4(html) {
32
- var emptyZoneFrame = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']];
33
- return layoutMargin(html, emptyZoneFrame, layoutDecoder4);
34
- }
35
- function layoutMargin3(html) {
36
- var emptyZoneFrame = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']];
37
- return layoutMargin(html, emptyZoneFrame, layoutDecoder3);
38
- }
39
- function layoutDecoder4(layoutCode, zoneFrame, hint, block) {
40
- switch (layoutCode) {
41
- case 'top':
42
- zoneFrame[0][1] = block.id;
43
- if (hint === 'wide') {
44
- zoneFrame[0][2] = block.id;
45
- }
46
- if (hint === 'full') {
47
- zoneFrame[0][0] = block.id;
48
- zoneFrame[0][2] = block.id;
49
- zoneFrame[0][3] = block.id;
50
- }
51
- break;
52
- case 'left-middle':
53
- zoneFrame[1][0] = block.id;
54
- if (hint === 'tall') zoneFrame[2][0] = block.id;else if (hint === 'wide') {
55
- zoneFrame[1][1] = block.id;
56
- zoneFrame[1][2] = block.id;
57
- }
58
- break;
59
- case 'right-middle':
60
- zoneFrame[1][3] = block.id;
61
- if (hint === 'tall') zoneFrame[2][3] = block.id;
62
- break;
63
- case 'bottom':
64
- zoneFrame[2][1] = block.id;
65
- zoneFrame[2][2] = block.id;
66
- if (hint === 'wide') {
67
- zoneFrame[2][3] = block.id;
68
- }
69
- if (hint === 'full') {
70
- zoneFrame[2][0] = block.id;
71
- zoneFrame[2][3] = block.id;
72
- }
73
- break;
74
- case 'left-top':
75
- zoneFrame[0][0] = block.id;
76
- if (hint === 'tall') zoneFrame[1][0] = block.id;else if (hint === 'wide') {
77
- zoneFrame[0][1] = block.id;
78
- zoneFrame[0][2] = block.id;
79
- }
80
- break;
81
- case 'right-top':
82
- zoneFrame[0][3] = block.id;
83
- if (hint === 'tall') zoneFrame[1][3] = block.id;
84
- break;
85
- case 'left-bottom':
86
- zoneFrame[2][0] = block.id;
87
- if (hint === 'wide') {
88
- zoneFrame[2][1] = block.id;
89
- zoneFrame[2][2] = block.id;
90
- }
91
- break;
92
- case 'right-bottom':
93
- zoneFrame[2][3] = block.id;
94
- break;
95
- default:
96
- zoneFrame[1][1] = block.id;
97
- zoneFrame[1][2] = block.id;
98
- if (hint === 'wide') {
99
- zoneFrame[1][3] = block.id;
100
- }
101
- if (hint === 'full') {
102
- zoneFrame[1][0] = block.id;
103
- zoneFrame[1][3] = block.id;
104
- }
105
- }
106
- }
107
- function layoutDecoder3(layoutCode, zoneFrame, hint, block) {
108
- switch (layoutCode) {
109
- case 'top':
110
- zoneFrame[0][1] = block.id;
111
- if (hint === 'wide') {
112
- zoneFrame[0][2] = block.id;
113
- }
114
- if (hint === 'full') {
115
- zoneFrame[0][0] = block.id;
116
- zoneFrame[0][2] = block.id;
117
- }
118
- break;
119
- case 'left-middle':
120
- zoneFrame[1][0] = block.id;
121
- if (hint === 'tall') zoneFrame[2][0] = block.id;else if (hint === 'wide') {
122
- zoneFrame[1][1] = block.id;
123
- zoneFrame[1][2] = block.id;
124
- }
125
- break;
126
- case 'right-middle':
127
- zoneFrame[1][2] = block.id;
128
- if (hint === 'tall') zoneFrame[2][2] = block.id;
129
- break;
130
- case 'bottom':
131
- zoneFrame[2][1] = block.id;
132
- if (hint === 'wide') {
133
- zoneFrame[2][2] = block.id;
134
- }
135
- if (hint === 'full') {
136
- zoneFrame[2][0] = block.id;
137
- zoneFrame[2][2] = block.id;
138
- }
139
- break;
140
- case 'left-top':
141
- zoneFrame[0][0] = block.id;
142
- if (hint === 'tall') zoneFrame[1][0] = block.id;else if (hint === 'wide') {
143
- zoneFrame[0][1] = block.id;
144
- zoneFrame[0][2] = block.id;
145
- }
146
- break;
147
- case 'right-top':
148
- zoneFrame[0][2] = block.id;
149
- if (hint === 'tall') zoneFrame[1][2] = block.id;
150
- break;
151
- case 'left-bottom':
152
- zoneFrame[2][0] = block.id;
153
- if (hint === 'wide') {
154
- zoneFrame[2][1] = block.id;
155
- zoneFrame[2][2] = block.id;
156
- }
157
- break;
158
- case 'right-bottom':
159
- zoneFrame[2][2] = block.id;
160
- break;
161
- default:
162
- zoneFrame[1][1] = block.id;
163
- zoneFrame[1][2] = block.id;
164
- if (hint === 'full') {
165
- zoneFrame[1][0] = block.id;
166
- }
167
- }
168
- }
169
- function layoutMargin(html, emptyZoneFrame, layoutDecoder) {
170
- // load the surface into a DOM element to retrieve the grid data
171
- var folioDiv = document.createElement('div');
172
- folioDiv.innerHTML = html;
173
- var zones = folioDiv.getElementsByTagName('tei-body')[0].children;
174
- var validLayoutCode = function validLayoutCode(block) {
175
- var layoutCode = block.getAttribute("rend");
176
- if (Object.keys(emptyMarginFrame).includes(layoutCode)) {
177
- return layoutCode;
178
- }
179
- return 'middle';
180
- };
181
- function validLayoutHint(block) {
182
- var layoutHint = block.getAttribute('style');
183
- if (hintCodes.includes(layoutHint)) {
184
- return layoutHint;
185
- }
186
- return null;
187
- }
188
- var zoneGrid = [];
189
- var gridContent = '';
190
- var zoneIndex = 0;
191
- var rowIndex = 0;
192
- // for each zone, take its margin data and populate the grid
193
- try {
194
- var _iterator = _createForOfIteratorHelper(zones),
195
- _step;
196
- try {
197
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
198
- var zone = _step.value;
199
- // create a rolling frame that is ORed on to grid with each step
200
- var zoneFrame = (0, _copyObject["default"])(emptyZoneFrame);
201
- var marginFrame = (0, _copyObject["default"])(emptyMarginFrame);
202
- var entryID = zone.id;
203
- var blocks = zone.children;
204
- var _iterator2 = _createForOfIteratorHelper(blocks),
205
- _step2;
206
- try {
207
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
208
- var block = _step2.value;
209
- var layoutCode = validLayoutCode(block);
210
- var hint = validLayoutHint(block);
211
- block.setAttribute('data-entry-id', entryID);
212
-
213
- // group all the blocks together that share a layout code
214
- if (marginFrame[layoutCode]) {
215
- block.id = marginFrame[layoutCode][0].id;
216
- marginFrame[layoutCode].push(block);
217
- } else {
218
- zoneIndex++;
219
- block.id = "z".concat(zoneIndex);
220
- marginFrame[layoutCode] = [block];
221
- }
222
-
223
- // decode the layout
224
- layoutDecoder(layoutCode, zoneFrame, hint, block);
225
- }
226
- } catch (err) {
227
- _iterator2.e(err);
228
- } finally {
229
- _iterator2.f();
230
- }
231
- for (var _i = 0, _Object$values = Object.values(marginFrame); _i < _Object$values.length; _i++) {
232
- var blockSet = _Object$values[_i];
233
- if (blockSet) {
234
- gridContent = gridContent.concat(renderBlockSet(blockSet));
235
- }
236
- }
237
-
238
- // integrate frame into grid
239
- zoneGrid[rowIndex] = mergeRow(zoneFrame[0], zoneGrid[rowIndex]);
240
- zoneGrid[rowIndex + 1] = mergeRow(zoneFrame[1], zoneGrid[rowIndex + 1]);
241
- zoneGrid[rowIndex + 2] = mergeRow(zoneFrame[2], zoneGrid[rowIndex + 2]);
242
- rowIndex += 1;
243
- }
244
- } catch (err) {
245
- _iterator.e(err);
246
- } finally {
247
- _iterator.f();
248
- }
249
- } catch (error) {
250
- console.log(error);
251
- }
252
- var gridLayout = zoneGridToLayout(zoneGrid);
253
-
254
- // set the grid-template-areas
255
- return {
256
- html: gridContent,
257
- layout: gridLayout
258
- };
259
- }
260
-
261
- // transform zone grid into the grid layout string
262
- function zoneGridToLayout(zoneGrid) {
263
- var zoneGridFinal = _toConsumableArray(zoneGrid);
264
-
265
- // ignore the first row if there are no block sets in it
266
- if (zoneGrid[0] && zoneGrid[0][0] === '.' && zoneGrid[0][1] === '.') {
267
- zoneGridFinal.shift();
268
- }
269
- var gridLayout = '';
270
- var _iterator3 = _createForOfIteratorHelper(zoneGridFinal),
271
- _step3;
272
- try {
273
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
274
- var row = _step3.value;
275
- var rowString = row.join(' ');
276
- gridLayout += " '".concat(rowString, "'");
277
- }
278
- } catch (err) {
279
- _iterator3.e(err);
280
- } finally {
281
- _iterator3.f();
282
- }
283
- return gridLayout;
284
- }
285
- function renderBlockSet(blockSet) {
286
- // use ID and class from the first block in the set
287
- var firstBlock = blockSet[0];
288
- var elementID = firstBlock.id;
289
- var entryID = firstBlock.attributes['data-entry-id'].value;
290
- var classStr = '';
291
- for (var i = 0; i < firstBlock.classList.length; i++) {
292
- classStr = "".concat(classStr, " ").concat(firstBlock.classList.item(i));
293
- }
294
-
295
- // combine the blocks in the block set. divs are all merged into a single div
296
- // other element types become children of the single div.
297
- var el = "<div id=\"".concat(elementID, "\" className=\"").concat(classStr, "\" data-entry-id=\"").concat(entryID, "\">");
298
- var _iterator4 = _createForOfIteratorHelper(blockSet),
299
- _step4;
300
- try {
301
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
302
- var block = _step4.value;
303
- block.setAttribute('className', 'block');
304
- if (block.name === 'div') {
305
- el = el.concat("".concat(block.innerHTML, " <br/>"));
306
- } else {
307
- el = el.concat("".concat(block.outerHTML));
308
- }
309
- }
310
- } catch (err) {
311
- _iterator4.e(err);
312
- } finally {
313
- _iterator4.f();
314
- }
315
- return el.concat('</div>');
316
- }
317
- function mergeRow(sourceRow, targetRow) {
318
- if (targetRow) {
319
- var result = [];
320
- for (var i = 0; i < 4; i++) {
321
- // if the source isn't blank, copy it, otherwise use existing
322
- if (sourceRow[i] !== '.') {
323
- result[i] = sourceRow[i];
324
- } else {
325
- result[i] = targetRow[i];
326
- }
327
- }
328
- return result;
329
- }
330
- return sourceRow;
331
- }
332
-
333
- /// //////////
334
- // WARNING: This code needs to be refactored, it hasn't been used in the project since early days
335
- function layoutGrid(html) {
336
- // load the surface into a DOM element to retrieve the grid data
337
- var zoneDiv = document.createElement('div');
338
- zoneDiv.innerHTML = html;
339
- var zones = zoneDiv.children;
340
-
341
- // move blocks into the gridContent as they are identified.
342
- var gridContent = '';
343
- var zoneGrid = [];
344
- var index = 0;
345
- // for each zone, take its grid data and populate the grid, throw an error on any dupes
346
- try {
347
- var _iterator5 = _createForOfIteratorHelper(zones),
348
- _step5;
349
- try {
350
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
351
- var zone = _step5.value;
352
- var blocks = zone.children;
353
- var _iterator6 = _createForOfIteratorHelper(blocks),
354
- _step6;
355
- try {
356
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
357
- var block = _step6.value;
358
- var blockID = "z".concat(index++);
359
- // TODO renderBlock() definition missing, needs refactoring
360
- // gridContent = gridContent.concat( renderBlock(blockID, block) );
361
- var gridData = block.dataset.layout;
362
- if (typeof gridData !== 'string') throw new Error("Grid data not found for zone: ".concat(block));
363
- var gridDataList = gridData.split(' ');
364
- var _iterator7 = _createForOfIteratorHelper(gridDataList),
365
- _step7;
366
- try {
367
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
368
- var gridDatum = _step7.value;
369
- var rowIndex = rowCodeToIndex(gridDatum[0]);
370
- var columnIndex = columnCodeToIndex(gridDatum[1]);
371
- if (zoneGrid[rowIndex] === undefined) zoneGrid[rowIndex] = ['.', '.', '.'];
372
- if (zoneGrid[rowIndex][columnIndex] === '.') {
373
- zoneGrid[rowIndex][columnIndex] = blockID;
374
- } else {
375
- throw new Error("Grid location ".concat(gridDatum, " already assigned to ").concat(zoneGrid[rowIndex][columnIndex], "."));
376
- }
377
- }
378
- } catch (err) {
379
- _iterator7.e(err);
380
- } finally {
381
- _iterator7.f();
382
- }
383
- }
384
- } catch (err) {
385
- _iterator6.e(err);
386
- } finally {
387
- _iterator6.f();
388
- }
389
- }
390
- } catch (err) {
391
- _iterator5.e(err);
392
- } finally {
393
- _iterator5.f();
394
- }
395
- } catch (error) {
396
- console.log(error);
397
- }
398
- var gridLayout = zoneGridToLayout(zoneGrid);
399
-
400
- // set the grid-template-areas
401
- return {
402
- content: gridContent,
403
- layout: gridLayout
404
- };
405
- }
406
- function rowCodeToIndex(rowCode) {
407
- if (typeof rowCode !== 'string' || rowCode.length > 1) throw new Error('Invalid row code, must be a single letter.');
408
- var index = ROW_CODES.indexOf(rowCode.toLowerCase());
409
- if (index === -1) throw new Error('Invalid row code must be a letter a-j.');
410
- return index;
411
- }
412
- function columnCodeToIndex(columnCode) {
413
- if (typeof columnCode !== 'string') throw new Error('Invalid column code, must be a single digit.');
414
- var index = parseInt(columnCode, 10) - 1;
415
- return index;
416
- }