UNPKG

@cmu-eberly-center/eberly-ontopic-visualization

Version:

Writing tasks require countless composing decisions that are typically beyond the conscious grasp of student writers. Much of the skill of being “text-aware” is to understand that texts are composed of highly structured and often highly predictive composi

127 lines (99 loc) 3.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _OnTopicDataTools = _interopRequireDefault(require("./OnTopicDataTools")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } /** * */ var OnTopicEditorTools = /*#__PURE__*/function () { /** * */ function OnTopicEditorTools() { _classCallCheck(this, OnTopicEditorTools); this.dataTools = new _OnTopicDataTools["default"](); } /** * */ _createClass(OnTopicEditorTools, [{ key: "getParagraphSentencePlain", value: function getParagraphSentencePlain(aPlainData, aPIndex) { console.log("getParagraphSentencePlain (" + aPIndex + ")"); var paragraphs = aPlainData.split("\n"); var index = 0; for (var i = 0; i < paragraphs.length; i++) { var para = paragraphs[i]; if (para != "") { if (index == aPIndex) { return para.substring(0, 25) + "..."; } index++; } } return ""; } /** * */ }, { key: "getParagraphSentence", value: function getParagraphSentence(aData, aPIndex, plain) { console.log("getParagraphSentence (" + aPIndex + ")"); console.log(aData); console.log(plain); var breakout = false; var index = 0; var paraCount = 0; for (var i = 0; i < aData.nodes.length; i++) { var paragraphObject = aData.nodes[i]; if (this.isEmptyParagraph(paragraphObject) == false) { console.log("Paragraph object with index " + i + " is not empty"); if (paraCount == aPIndex) { console.log("Comparing paraCount " + paraCount + ", to: " + aPIndex); return this.getParagraphText(paragraphObject); } paraCount++; } } return ""; } /** * */ }, { key: "isEmptyParagraph", value: function isEmptyParagraph(aParagraphData) { //console.log ("isEmptyParagraph ()"); if (aParagraphData.type == "paragraph") { var firstNode = aParagraphData.nodes[0]; //console.log ("Examining: [" + firstNode.text + "]"); if (this.dataTools.isBlank(firstNode.text) == true) { return true; } } return false; } /** * */ }, { key: "getParagraphText", value: function getParagraphText(aParagraphData) { //console.log ("getParagraphText ()"); if (aParagraphData.type == "paragraph") { var firstNode = aParagraphData.nodes[0]; //console.log (firstNode); return firstNode.text; } return ""; } }]); return OnTopicEditorTools; }(); var _default = OnTopicEditorTools; exports["default"] = _default;