@innovastudio/contentbuilder 1.4.84 → 1.4.86
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@innovastudio/contentbuilder",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.4.
|
4
|
+
"version": "1.4.86",
|
5
5
|
"description": "",
|
6
6
|
"main": "public/contentbuilder/contentbuilder.esm.js",
|
7
7
|
"files": [
|
@@ -58,6 +58,6 @@
|
|
58
58
|
"rangy": "^1.3.0",
|
59
59
|
"socket.io-client": "^4.7.1",
|
60
60
|
"sortablejs": "^1.14.0",
|
61
|
-
"string-similarity": "^
|
61
|
+
"string-similarity-js": "^2.1.4"
|
62
62
|
}
|
63
63
|
}
|
@@ -8547,7 +8547,7 @@ class Dom {
|
|
8547
8547
|
|
8548
8548
|
var js$1 = {exports: {}};
|
8549
8549
|
|
8550
|
-
var src
|
8550
|
+
var src = {};
|
8551
8551
|
|
8552
8552
|
var javascript = {exports: {}};
|
8553
8553
|
|
@@ -13686,9 +13686,9 @@ function style_html(html_source, options, js, css) {
|
|
13686
13686
|
}
|
13687
13687
|
style_html.defaultOptions = html_beautify.defaultOptions;
|
13688
13688
|
|
13689
|
-
src
|
13690
|
-
src
|
13691
|
-
src
|
13689
|
+
src.js = js_beautify;
|
13690
|
+
src.css = css_beautify;
|
13691
|
+
src.html = style_html;
|
13692
13692
|
|
13693
13693
|
/*jshint node:true */
|
13694
13694
|
|
@@ -13731,7 +13731,7 @@ function get_beautify(js_beautify, css_beautify, html_beautify) {
|
|
13731
13731
|
|
13732
13732
|
{
|
13733
13733
|
(function(mod) {
|
13734
|
-
var beautifier = src
|
13734
|
+
var beautifier = src;
|
13735
13735
|
beautifier.js_beautify = beautifier.js;
|
13736
13736
|
beautifier.css_beautify = beautifier.css;
|
13737
13737
|
beautifier.html_beautify = beautifier.html;
|
@@ -58804,6 +58804,33 @@ class ColumnTool {
|
|
58804
58804
|
util.clearControls();
|
58805
58805
|
});
|
58806
58806
|
|
58807
|
+
/*
|
58808
|
+
const fixLayout = (row) => {
|
58809
|
+
let hasFixed = false;
|
58810
|
+
let elm = row.firstElementChild;
|
58811
|
+
let cols = this.builder.cols;
|
58812
|
+
cols.forEach(item=>{
|
58813
|
+
let elmClass = elm.getAttribute('class');
|
58814
|
+
if(elmClass) {
|
58815
|
+
// console.log(elmClass, item);
|
58816
|
+
if(elmClass.indexOf(item)!==-1) {
|
58817
|
+
hasFixed=true;
|
58818
|
+
}
|
58819
|
+
}
|
58820
|
+
});
|
58821
|
+
// console.log('result:' + hasFixed);
|
58822
|
+
if(!hasFixed) {
|
58823
|
+
if(this.builder.framework==='foundation') Array.from(row.children).map((item) => {
|
58824
|
+
if(item.classList.contains('is-row-tool')) return;
|
58825
|
+
if(item.classList.contains('is-col-tool')) return;
|
58826
|
+
if(item.classList.contains('is-rowadd-tool')) return;
|
58827
|
+
item.classList.remove('column');
|
58828
|
+
});
|
58829
|
+
util.fixLayout(row);
|
58830
|
+
}
|
58831
|
+
};
|
58832
|
+
*/
|
58833
|
+
|
58807
58834
|
// Increase
|
58808
58835
|
elm = columnMore.querySelector('.cell-increase');
|
58809
58836
|
dom.addEventListener(elm, 'click', () => {
|
@@ -58831,7 +58858,10 @@ class ColumnTool {
|
|
58831
58858
|
});
|
58832
58859
|
util.fixLayout(row);
|
58833
58860
|
}
|
58861
|
+
|
58862
|
+
// fixLayout(row);
|
58834
58863
|
}
|
58864
|
+
|
58835
58865
|
this.grid.increaseColumn();
|
58836
58866
|
|
58837
58867
|
// Refresh Module
|
@@ -58875,7 +58905,10 @@ class ColumnTool {
|
|
58875
58905
|
});
|
58876
58906
|
util.fixLayout(row);
|
58877
58907
|
}
|
58908
|
+
|
58909
|
+
// fixLayout(row);
|
58878
58910
|
}
|
58911
|
+
|
58879
58912
|
this.grid.decreaseColumn();
|
58880
58913
|
|
58881
58914
|
// Refresh Module
|
@@ -77583,6 +77616,9 @@ class Dictation {
|
|
77583
77616
|
transform: rotate(450deg);
|
77584
77617
|
}
|
77585
77618
|
}
|
77619
|
+
.inp-command::placeholder {
|
77620
|
+
color: #aaa;
|
77621
|
+
}
|
77586
77622
|
</style>
|
77587
77623
|
<div class="is-overlay page-command-overlay">
|
77588
77624
|
<svg class="spinner" width="40px" height="40px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
|
@@ -77980,9 +78016,15 @@ class Dictation {
|
|
77980
78016
|
if (transcript && message.data.is_final) {
|
77981
78017
|
finalTranscripts += ' ' + transcript;
|
77982
78018
|
}
|
78019
|
+
|
78020
|
+
// Format
|
78021
|
+
finalTranscripts = finalTranscripts.charAt(0).toUpperCase() + finalTranscripts.slice(1);
|
78022
|
+
finalTranscripts = finalTranscripts.trim();
|
77983
78023
|
inpCommand.value = finalTranscripts;
|
77984
78024
|
clearTimeout(speechTimeout);
|
78025
|
+
console.log('Writing..');
|
77985
78026
|
speechTimeout = setTimeout(() => {
|
78027
|
+
console.log('Clear');
|
77986
78028
|
this.builder.commandText = '';
|
77987
78029
|
finalTranscripts = '';
|
77988
78030
|
if (this.builder.autoSendCommand) {
|
@@ -78083,72 +78125,51 @@ class Dictation {
|
|
78083
78125
|
}
|
78084
78126
|
}
|
78085
78127
|
|
78086
|
-
var
|
78087
|
-
|
78088
|
-
|
78128
|
+
var stringSimilarity = {};
|
78129
|
+
|
78130
|
+
(function (exports) {
|
78131
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
78132
|
+
exports.stringSimilarity = void 0;
|
78133
|
+
/* global exports, Map */
|
78134
|
+
/**
|
78135
|
+
* Calculate similarity between two strings
|
78136
|
+
* @param {string} str1 First string to match
|
78137
|
+
* @param {string} str2 Second string to match
|
78138
|
+
* @param {number} [substringLength=2] Optional. Length of substring to be used in calculating similarity. Default 2.
|
78139
|
+
* @param {boolean} [caseSensitive=false] Optional. Whether you want to consider case in string matching. Default false;
|
78140
|
+
* @returns Number between 0 and 1, with 0 being a low match score.
|
78141
|
+
*/
|
78142
|
+
var stringSimilarity = function (str1, str2, substringLength, caseSensitive) {
|
78143
|
+
if (substringLength === void 0) { substringLength = 2; }
|
78144
|
+
if (caseSensitive === void 0) { caseSensitive = false; }
|
78145
|
+
if (!caseSensitive) {
|
78146
|
+
str1 = str1.toLowerCase();
|
78147
|
+
str2 = str2.toLowerCase();
|
78148
|
+
}
|
78149
|
+
if (str1.length < substringLength || str2.length < substringLength)
|
78150
|
+
return 0;
|
78151
|
+
var map = new Map();
|
78152
|
+
for (var i = 0; i < str1.length - (substringLength - 1); i++) {
|
78153
|
+
var substr1 = str1.substr(i, substringLength);
|
78154
|
+
map.set(substr1, map.has(substr1) ? map.get(substr1) + 1 : 1);
|
78155
|
+
}
|
78156
|
+
var match = 0;
|
78157
|
+
for (var j = 0; j < str2.length - (substringLength - 1); j++) {
|
78158
|
+
var substr2 = str2.substr(j, substringLength);
|
78159
|
+
var count = map.has(substr2) ? map.get(substr2) : 0;
|
78160
|
+
if (count > 0) {
|
78161
|
+
map.set(substr2, count - 1);
|
78162
|
+
match++;
|
78163
|
+
}
|
78164
|
+
}
|
78165
|
+
return (match * 2) / (str1.length + str2.length - ((substringLength - 1) * 2));
|
78089
78166
|
};
|
78167
|
+
exports.stringSimilarity = stringSimilarity;
|
78168
|
+
exports.default = exports.stringSimilarity;
|
78090
78169
|
|
78091
|
-
|
78092
|
-
first = first.replace(/\s+/g, '');
|
78093
|
-
second = second.replace(/\s+/g, '');
|
78094
|
-
|
78095
|
-
if (first === second) return 1; // identical or empty
|
78096
|
-
if (first.length < 2 || second.length < 2) return 0; // if either is a 0-letter or 1-letter string
|
78097
|
-
|
78098
|
-
let firstBigrams = new Map();
|
78099
|
-
for (let i = 0; i < first.length - 1; i++) {
|
78100
|
-
const bigram = first.substring(i, i + 2);
|
78101
|
-
const count = firstBigrams.has(bigram)
|
78102
|
-
? firstBigrams.get(bigram) + 1
|
78103
|
-
: 1;
|
78104
|
-
|
78105
|
-
firstBigrams.set(bigram, count);
|
78106
|
-
}
|
78107
|
-
let intersectionSize = 0;
|
78108
|
-
for (let i = 0; i < second.length - 1; i++) {
|
78109
|
-
const bigram = second.substring(i, i + 2);
|
78110
|
-
const count = firstBigrams.has(bigram)
|
78111
|
-
? firstBigrams.get(bigram)
|
78112
|
-
: 0;
|
78113
|
-
|
78114
|
-
if (count > 0) {
|
78115
|
-
firstBigrams.set(bigram, count - 1);
|
78116
|
-
intersectionSize++;
|
78117
|
-
}
|
78118
|
-
}
|
78119
|
-
|
78120
|
-
return (2.0 * intersectionSize) / (first.length + second.length - 2);
|
78121
|
-
}
|
78122
|
-
|
78123
|
-
function findBestMatch(mainString, targetStrings) {
|
78124
|
-
if (!areArgsValid(mainString, targetStrings)) throw new Error('Bad arguments: First argument should be a string, second should be an array of strings');
|
78125
|
-
|
78126
|
-
const ratings = [];
|
78127
|
-
let bestMatchIndex = 0;
|
78128
|
-
|
78129
|
-
for (let i = 0; i < targetStrings.length; i++) {
|
78130
|
-
const currentTargetString = targetStrings[i];
|
78131
|
-
const currentRating = compareTwoStrings(mainString, currentTargetString);
|
78132
|
-
ratings.push({target: currentTargetString, rating: currentRating});
|
78133
|
-
if (currentRating > ratings[bestMatchIndex].rating) {
|
78134
|
-
bestMatchIndex = i;
|
78135
|
-
}
|
78136
|
-
}
|
78137
|
-
|
78138
|
-
|
78139
|
-
const bestMatch = ratings[bestMatchIndex];
|
78140
|
-
|
78141
|
-
return { ratings: ratings, bestMatch: bestMatch, bestMatchIndex: bestMatchIndex };
|
78142
|
-
}
|
78143
|
-
|
78144
|
-
function areArgsValid(mainString, targetStrings) {
|
78145
|
-
if (typeof mainString !== 'string') return false;
|
78146
|
-
if (!Array.isArray(targetStrings)) return false;
|
78147
|
-
if (!targetStrings.length) return false;
|
78148
|
-
if (targetStrings.find( function (s) { return typeof s !== 'string'})) return false;
|
78149
|
-
return true;
|
78150
|
-
}
|
78170
|
+
}(stringSimilarity));
|
78151
78171
|
|
78172
|
+
// import stringSimilarity from 'string-similarity';
|
78152
78173
|
class Similarity {
|
78153
78174
|
constructor(builder) {
|
78154
78175
|
this.builder = builder;
|
@@ -78178,7 +78199,7 @@ class Similarity {
|
|
78178
78199
|
const normalizedCommand = command.toLowerCase();
|
78179
78200
|
let maxSimilarity = 0;
|
78180
78201
|
for (const cmd of list) {
|
78181
|
-
const similarity =
|
78202
|
+
const similarity = stringSimilarity.stringSimilarity(normalizedCommand, cmd);
|
78182
78203
|
if (similarity > maxSimilarity) {
|
78183
78204
|
// console.log(list)
|
78184
78205
|
// console.log(similarity)
|
@@ -78808,7 +78829,7 @@ class ContentBuilder {
|
|
78808
78829
|
sendCommandUrl: 'http://localhost:8081/answer',
|
78809
78830
|
// speechTranscribeUrl: 'http://192.168.1.7:8081',
|
78810
78831
|
onlineDemo: false,
|
78811
|
-
autoSendDelay:
|
78832
|
+
autoSendDelay: 4000,
|
78812
78833
|
commandPlaceholderText: '',
|
78813
78834
|
enableShortCommands: true,
|
78814
78835
|
speechRecognitionLang: 'en-US',
|