solid-panes 3.6.2-65d80a4a → 3.6.2-b526cdb4
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.
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/outline/index.html +1 -1
- package/coverage/lcov-report/outline/outlineIcons.js.html +1 -1
- package/coverage/lcov-report/outline/propertyViews.ts.html +1 -1
- package/coverage/lcov-report/outline/viewAsImage.ts.html +1 -1
- package/coverage/lcov-report/outline/viewAsMbox.ts.html +1 -1
- package/coverage/lcov-report/trustedApplications/index.html +1 -1
- package/coverage/lcov-report/trustedApplications/trustedApplications.utils.ts.html +1 -1
- package/lib/dokieli/dokieliPane.js +34 -20
- package/lib/dokieli/dokieliPane.js.map +1 -1
- package/lib/humanReadablePane.js +46 -33
- package/lib/humanReadablePane.js.map +1 -1
- package/lib/versionInfo.d.ts +17 -10
- package/lib/versionInfo.d.ts.map +1 -1
- package/lib/versionInfo.js +26 -19
- package/lib/versionInfo.js.map +1 -1
- package/package.json +1 -1
- package/src/dokieli/dokieliPane.js +32 -24
- package/src/humanReadablePane.js +55 -39
- package/src/versionInfo.ts +26 -19
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1739460918341" clover="3.2.0">
|
|
3
|
+
<project timestamp="1739460918341" name="All files">
|
|
4
4
|
<metrics statements="125" coveredstatements="125" conditionals="6" coveredconditionals="4" methods="13" coveredmethods="13" elements="144" coveredelements="142" complexity="0" loc="125" ncloc="125" packages="2" files="5" classes="5"/>
|
|
5
5
|
<package name="outline">
|
|
6
6
|
<metrics statements="112" coveredstatements="112" conditionals="6" coveredconditionals="4" methods="7" coveredmethods="7"/>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
117
117
|
Code coverage generated by
|
|
118
118
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
119
|
-
at 2025-02-
|
|
119
|
+
at 2025-02-13T15:35:18.332Z
|
|
120
120
|
</div>
|
|
121
121
|
<script src="prettify.js"></script>
|
|
122
122
|
<script>
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
147
147
|
Code coverage generated by
|
|
148
148
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
149
|
-
at 2025-02-
|
|
149
|
+
at 2025-02-13T15:35:18.332Z
|
|
150
150
|
</div>
|
|
151
151
|
<script src="../prettify.js"></script>
|
|
152
152
|
<script>
|
|
@@ -550,7 +550,7 @@ outlineIcons.termWidgets.addTri = new outlineIcons.OutlinerIcon(
|
|
|
550
550
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
551
551
|
Code coverage generated by
|
|
552
552
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
553
|
-
at 2025-02-
|
|
553
|
+
at 2025-02-13T15:35:18.332Z
|
|
554
554
|
</div>
|
|
555
555
|
<script src="../prettify.js"></script>
|
|
556
556
|
<script>
|
|
@@ -181,7 +181,7 @@ export function viewsAddPropertyView (views, property, pviewfunc, isDefault) {
|
|
|
181
181
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
182
182
|
Code coverage generated by
|
|
183
183
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
184
|
-
at 2025-02-
|
|
184
|
+
at 2025-02-13T15:35:18.332Z
|
|
185
185
|
</div>
|
|
186
186
|
<script src="../prettify.js"></script>
|
|
187
187
|
<script>
|
|
@@ -106,7 +106,7 @@ export default (dom) => function viewAsImage (obj) {
|
|
|
106
106
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
107
107
|
Code coverage generated by
|
|
108
108
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
109
|
-
at 2025-02-
|
|
109
|
+
at 2025-02-13T15:35:18.332Z
|
|
110
110
|
</div>
|
|
111
111
|
<script src="../prettify.js"></script>
|
|
112
112
|
<script>
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
113
113
|
Code coverage generated by
|
|
114
114
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
115
|
-
at 2025-02-
|
|
115
|
+
at 2025-02-13T15:35:18.332Z
|
|
116
116
|
</div>
|
|
117
117
|
<script src="../prettify.js"></script>
|
|
118
118
|
<script>
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
102
|
Code coverage generated by
|
|
103
103
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
-
at 2025-02-
|
|
104
|
+
at 2025-02-13T15:35:18.332Z
|
|
105
105
|
</div>
|
|
106
106
|
<script src="../prettify.js"></script>
|
|
107
107
|
<script>
|
|
@@ -223,7 +223,7 @@ export function generateRandomString () {
|
|
|
223
223
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
224
224
|
Code coverage generated by
|
|
225
225
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
226
|
-
at 2025-02-
|
|
226
|
+
at 2025-02-13T15:35:18.332Z
|
|
227
227
|
</div>
|
|
228
228
|
<script src="../prettify.js"></script>
|
|
229
229
|
<script>
|
|
@@ -53,7 +53,7 @@ var _default = exports["default"] = {
|
|
|
53
53
|
|
|
54
54
|
// This data coul d come from a fetch OR from ldp comtaimner
|
|
55
55
|
var hasContentTypeIn2 = function hasContentTypeIn2(kb, x, displayables) {
|
|
56
|
-
var t = kb.findTypeURIs(
|
|
56
|
+
var t = kb.findTypeURIs(x);
|
|
57
57
|
for (var k = 0; k < displayables.length; k++) {
|
|
58
58
|
if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {
|
|
59
59
|
return true;
|
|
@@ -119,38 +119,52 @@ var _default = exports["default"] = {
|
|
|
119
119
|
div.setAttribute('class', 'docView');
|
|
120
120
|
var iframe = myDocument.createElement('IFRAME');
|
|
121
121
|
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
return response.blob();
|
|
125
|
-
}).then(function (blob) {
|
|
122
|
+
// Function to set iframe attributes
|
|
123
|
+
var setIframeAttributes = function setIframeAttributes(iframe, blob, lines) {
|
|
126
124
|
var objectURL = URL.createObjectURL(blob);
|
|
127
|
-
iframe.setAttribute('src', objectURL);
|
|
125
|
+
iframe.setAttribute('src', objectURL);
|
|
128
126
|
iframe.setAttribute('type', blob.type);
|
|
129
127
|
iframe.setAttribute('class', 'doc');
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
iframe.setAttribute('style', "border: 1px solid; padding: 1em; height:".concat(lines, "em; width:800px; resize: both; overflow: auto;"));
|
|
129
|
+
|
|
130
|
+
// Apply sandbox attribute only for HTML files
|
|
131
|
+
// @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
132
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
133
|
+
// You can;'t have any sandbox and allow plugins.
|
|
134
|
+
// We could sandbox only HTML files I suppose.
|
|
135
|
+
// HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
|
|
136
|
+
if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
|
|
137
|
+
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Fetch and process the blob
|
|
142
|
+
kb.fetcher._fetch(subject.uri).then(function (response) {
|
|
143
|
+
return response.blob();
|
|
144
|
+
}).then(function (blob) {
|
|
145
|
+
var blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('');
|
|
146
|
+
return blobTextPromise.then(function (blobText) {
|
|
147
|
+
return {
|
|
148
|
+
blob: blob,
|
|
149
|
+
blobText: blobText
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}).then(function (_ref) {
|
|
153
|
+
var blob = _ref.blob,
|
|
154
|
+
blobText = _ref.blobText;
|
|
132
155
|
var newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5;
|
|
133
156
|
var lines = Math.min(30, blobText.split(/\n/).length + newLines);
|
|
134
|
-
iframe
|
|
157
|
+
setIframeAttributes(iframe, blob, lines);
|
|
135
158
|
})["catch"](function (err) {
|
|
136
|
-
console.log(err);
|
|
159
|
+
console.log('Error fetching or processing blob:', err);
|
|
137
160
|
});
|
|
138
161
|
var cts = kb.fetcher.getHeader(subject.doc(), 'content-type');
|
|
139
|
-
var ct = cts ? cts[0] : null;
|
|
162
|
+
var ct = cts ? cts[0].split(';', 1)[0].trim() : null;
|
|
140
163
|
if (ct) {
|
|
141
164
|
console.log('dokieliPane: c-t:' + ct);
|
|
142
165
|
} else {
|
|
143
166
|
console.log('dokieliPane: unknown content-type?');
|
|
144
167
|
}
|
|
145
|
-
|
|
146
|
-
// @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
147
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
148
|
-
// You can;'t have any sandbox and allow plugins.
|
|
149
|
-
// We could sandbox only HTML files I suppose.
|
|
150
|
-
// HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
|
|
151
|
-
|
|
152
|
-
// iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
|
|
153
|
-
|
|
154
168
|
var tr = myDocument.createElement('tr');
|
|
155
169
|
tr.appendChild(iframe);
|
|
156
170
|
div.appendChild(tr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dokieliPane.js","names":["UI","_interopRequireWildcard","require","$rdf","mime","_new","_interopRequireDefault","e","__esModule","_getRequireWildcardCache","WeakMap","r","t","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_default","exports","icon","icons","iconBase","name","mintClass","ns","solid","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","findTypeURIs","Util","mediaTypeClass","uri","link","mintNew","newPaneOptions","newInstance","newBase","endsWith","slice","sym","contentType","lookup","includes","htmlContents","DOKIELI_TEMPLATE","filename","split","decodeURIComponent","encodedTitle","replace","Promise","resolve","webOperation","data","then","console","log","err","render","myDocument","dom","div","createElement","setAttribute","iframe","_fetch","response","blob","objectURL","URL","createObjectURL","type","text","blobText","newLines","lines","Math","min","concat","doc","ct","tr","appendChild"],"sources":["../../src/dokieli/dokieliPane.js"],"sourcesContent":["/* Human-readable editable \"Dokieli\" Pane\n **\n ** This outline pane contains the document contents for a Dokieli document\n ** The dokeili system allows the user to edit a document including anotations\n ** review. It does not use turtle, but RDF/a\n */\n\nimport * as UI from 'solid-ui'\nimport * as $rdf from 'rdflib'\nimport * as mime from 'mime-types'\n\n// const DOKIELI_TEMPLATE_URI = 'https://dokie.li/new' // Copy to make new dok\n\nimport DOKIELI_TEMPLATE from './new.js' // Distributed with this library\n\nexport default {\n icon: UI.icons.iconBase + 'dokieli-logo.png', // @@ improve? more like doccument?\n\n name: 'Dokieli',\n\n mintClass: UI.ns.solid('DokieliDocument'), // @@ A better class?\n\n label: function (subject, context) {\n const kb = context.session.store\n const ns = UI.ns\n const allowed = [\n // 'text/plain',\n 'text/html',\n 'application/xhtml+xml'\n // 'image/png', 'image/jpeg', 'application/pdf',\n // 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\n const cts = kb.fetcher.getHeader(x, 'content-type')\n if (cts) {\n for (let j = 0; j < cts.length; j++) {\n for (let k = 0; k < displayables.length; k++) {\n if (cts[j].indexOf(displayables[k]) >= 0) {\n return true\n }\n }\n }\n }\n return false\n }\n\n // This data coul d come from a fetch OR from ldp comtaimner\n const hasContentTypeIn2 = function (kb, x, displayables) {\n const t = kb.findTypeURIs(subject)\n for (let k = 0; k < displayables.length; k++) {\n if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {\n return true\n }\n }\n return false\n }\n\n if (!subject.uri) return null // no bnodes\n\n const t = kb.findTypeURIs(subject)\n if (t[ns.link('WebPage').uri]) return 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'Dok'\n }\n\n return null\n },\n\n // Create a new folder in a Solid system, with a dokieli editable document in it\n mintNew: function (context, newPaneOptions) {\n const kb = context.session.store\n let newInstance = newPaneOptions.newInstance\n if (!newInstance) {\n let uri = newPaneOptions.newBase\n if (uri.endsWith('/')) {\n uri = uri.slice(0, -1)\n newPaneOptions.newBase = uri\n }\n newInstance = kb.sym(uri)\n }\n\n const contentType = mime.lookup(newInstance.uri)\n if (!contentType || !contentType.includes('html')) {\n newInstance = $rdf.sym(newInstance.uri + '.html')\n }\n newPaneOptions.newInstance = newInstance // Save for creation system\n\n // console.log('New dokieli will make: ' + newInstance)\n\n let htmlContents = DOKIELI_TEMPLATE\n let filename = newInstance.uri.split('/').slice(-1)[0]\n filename = decodeURIComponent(filename.split('.')[0])\n const encodedTitle = filename\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n htmlContents = htmlContents.replace('<title>', '<title>' + encodedTitle)\n htmlContents = htmlContents.replace(\n '</article>',\n '<h1>' + encodedTitle + '</h1></article>'\n )\n // console.log('@@ New HTML for Dok:' + htmlContents)\n return new Promise(function (resolve) {\n kb.fetcher\n .webOperation('PUT', newInstance.uri, {\n data: htmlContents,\n contentType: 'text/html'\n })\n .then(function () {\n console.log(\n 'new Dokieli document created at ' + newPaneOptions.newInstance\n )\n resolve(newPaneOptions)\n })\n .catch(function (err) {\n console.log(\n 'Error creating dokieli doc at ' +\n newPaneOptions.newInstance +\n ': ' +\n err\n )\n })\n })\n },\n\n // Derived from: humanReadablePane .. share code?\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.setAttribute('class', 'docView')\n const iframe = myDocument.createElement('IFRAME')\n\n // get with authenticated fetch\n kb.fetcher._fetch(subject.uri)\n .then(function(response) {\n return response.blob()\n })\n .then(function(blob) {\n const objectURL = URL.createObjectURL(blob)\n iframe.setAttribute('src', objectURL) // w640 h480 //\n iframe.setAttribute('type', blob.type)\n iframe.setAttribute('class', 'doc')\n return blob.text()\n })\n .then(function(blobText) {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines)\n iframe.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)\n })\n .catch(err => { console.log(err) })\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0] : null\n if (ct) {\n console.log('dokieliPane: c-t:' + ct)\n } else {\n console.log('dokieliPane: unknown content-type?')\n }\n\n // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can;'t have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html\n\n // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static\n\n const tr = myDocument.createElement('tr')\n tr.appendChild(iframe)\n div.appendChild(tr)\n return div\n }\n}\n// ends\n"],"mappings":";;;;;;;AAOA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,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MAClG,IAAMiC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,EAAE,EAAEJ,QAAQ,CAAC3B,KAAK,CAAC,IAAI,CAAC,CAACtB,MAAM,GAAGkD,QAAQ,CAAC;MAClEV,MAAM,CAACD,YAAY,CAAC,OAAO,6CAAAe,MAAA,CAA6CH,KAAK,mDAAgD,CAAC;IAClI,CAAC,CAAC,SACM,CAAC,UAAAlB,GAAG,EAAI;MAAEF,OAAO,CAACC,GAAG,CAACC,GAAG,CAAC;IAAC,CAAC,CAAC;IAErC,IAAMrC,GAAG,GAAGP,EAAE,CAACQ,OAAO,CAACC,SAAS,CAACX,OAAO,CAACoE,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC;IAC/D,IAAMC,EAAE,GAAG5D,GAAG,GAAGA,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI;IAC9B,IAAI4D,EAAE,EAAE;MACNzB,OAAO,CAACC,GAAG,CAAC,mBAAmB,GAAGwB,EAAE,CAAC;IACvC,CAAC,MAAM;MACLzB,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC;IACnD;;IAEA;IACA;IACA;IACA;IACA;;IAEA;;IAED,IAAMyB,EAAE,GAAGtB,UAAU,CAACG,aAAa,CAAC,IAAI,CAAC;IACxCmB,EAAE,CAACC,WAAW,CAAClB,MAAM,CAAC;IACtBH,GAAG,CAACqB,WAAW,CAACD,EAAE,CAAC;IACnB,OAAOpB,GAAG;EACZ;AACF,CAAC,EACD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"dokieliPane.js","names":["UI","_interopRequireWildcard","require","$rdf","mime","_new","_interopRequireDefault","e","__esModule","_getRequireWildcardCache","WeakMap","r","t","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_default","exports","icon","icons","iconBase","name","mintClass","ns","solid","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","findTypeURIs","Util","mediaTypeClass","uri","link","mintNew","newPaneOptions","newInstance","newBase","endsWith","slice","sym","contentType","lookup","includes","htmlContents","DOKIELI_TEMPLATE","filename","split","decodeURIComponent","encodedTitle","replace","Promise","resolve","webOperation","data","then","console","log","err","render","myDocument","dom","div","createElement","setAttribute","iframe","setIframeAttributes","blob","lines","objectURL","URL","createObjectURL","type","concat","_fetch","response","blobTextPromise","startsWith","text","blobText","_ref","newLines","Math","min","doc","ct","trim","tr","appendChild"],"sources":["../../src/dokieli/dokieliPane.js"],"sourcesContent":["/* Human-readable editable \"Dokieli\" Pane\n **\n ** This outline pane contains the document contents for a Dokieli document\n ** The dokeili system allows the user to edit a document including anotations\n ** review. It does not use turtle, but RDF/a\n */\n\nimport * as UI from 'solid-ui'\nimport * as $rdf from 'rdflib'\nimport * as mime from 'mime-types'\n\n// const DOKIELI_TEMPLATE_URI = 'https://dokie.li/new' // Copy to make new dok\n\nimport DOKIELI_TEMPLATE from './new.js' // Distributed with this library\n\nexport default {\n icon: UI.icons.iconBase + 'dokieli-logo.png', // @@ improve? more like doccument?\n\n name: 'Dokieli',\n\n mintClass: UI.ns.solid('DokieliDocument'), // @@ A better class?\n\n label: function (subject, context) {\n const kb = context.session.store\n const ns = UI.ns\n const allowed = [\n // 'text/plain',\n 'text/html',\n 'application/xhtml+xml'\n // 'image/png', 'image/jpeg', 'application/pdf',\n // 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\n const cts = kb.fetcher.getHeader(x, 'content-type')\n if (cts) {\n for (let j = 0; j < cts.length; j++) {\n for (let k = 0; k < displayables.length; k++) {\n if (cts[j].indexOf(displayables[k]) >= 0) {\n return true\n }\n }\n }\n }\n return false\n }\n\n // This data coul d come from a fetch OR from ldp comtaimner\n const hasContentTypeIn2 = function (kb, x, displayables) {\n const t = kb.findTypeURIs(x)\n for (let k = 0; k < displayables.length; k++) {\n if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {\n return true\n }\n }\n return false\n }\n\n if (!subject.uri) return null // no bnodes\n\n const t = kb.findTypeURIs(subject)\n if (t[ns.link('WebPage').uri]) return 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'Dok'\n }\n\n return null\n },\n\n // Create a new folder in a Solid system, with a dokieli editable document in it\n mintNew: function (context, newPaneOptions) {\n const kb = context.session.store\n let newInstance = newPaneOptions.newInstance\n if (!newInstance) {\n let uri = newPaneOptions.newBase\n if (uri.endsWith('/')) {\n uri = uri.slice(0, -1)\n newPaneOptions.newBase = uri\n }\n newInstance = kb.sym(uri)\n }\n\n const contentType = mime.lookup(newInstance.uri)\n if (!contentType || !contentType.includes('html')) {\n newInstance = $rdf.sym(newInstance.uri + '.html')\n }\n newPaneOptions.newInstance = newInstance // Save for creation system\n\n // console.log('New dokieli will make: ' + newInstance)\n\n let htmlContents = DOKIELI_TEMPLATE\n let filename = newInstance.uri.split('/').slice(-1)[0]\n filename = decodeURIComponent(filename.split('.')[0])\n const encodedTitle = filename\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n htmlContents = htmlContents.replace('<title>', '<title>' + encodedTitle)\n htmlContents = htmlContents.replace(\n '</article>',\n '<h1>' + encodedTitle + '</h1></article>'\n )\n // console.log('@@ New HTML for Dok:' + htmlContents)\n return new Promise(function (resolve) {\n kb.fetcher\n .webOperation('PUT', newInstance.uri, {\n data: htmlContents,\n contentType: 'text/html'\n })\n .then(function () {\n console.log(\n 'new Dokieli document created at ' + newPaneOptions.newInstance\n )\n resolve(newPaneOptions)\n })\n .catch(function (err) {\n console.log(\n 'Error creating dokieli doc at ' +\n newPaneOptions.newInstance +\n ': ' +\n err\n )\n })\n })\n },\n\n // Derived from: humanReadablePane .. share code?\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.setAttribute('class', 'docView')\n const iframe = myDocument.createElement('IFRAME')\n\n // Function to set iframe attributes\n const setIframeAttributes = (iframe, blob, lines) => {\n const objectURL = URL.createObjectURL(blob)\n iframe.setAttribute('src', objectURL)\n iframe.setAttribute('type', blob.type)\n iframe.setAttribute('class', 'doc')\n iframe.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)\n\n // Apply sandbox attribute only for HTML files\n // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can;'t have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html\n if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {\n iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin')\n }\n }\n\n // Fetch and process the blob\n kb.fetcher._fetch(subject.uri)\n .then(response => response.blob())\n .then(blob => {\n const blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('')\n return blobTextPromise.then(blobText => ({ blob, blobText }))\n })\n .then(({ blob, blobText }) => {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines)\n setIframeAttributes(iframe, blob, lines)\n })\n .catch(err => {\n console.log('Error fetching or processing blob:', err)\n })\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null\n if (ct) {\n console.log('dokieliPane: c-t:' + ct)\n } else {\n console.log('dokieliPane: unknown content-type?')\n }\n\n const tr = myDocument.createElement('tr')\n tr.appendChild(iframe)\n div.appendChild(tr)\n return div\n }\n}\n// ends\n"],"mappings":";;;;;;;AAOA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,uB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,CAAC,CAACuC,IAAI,CAAC,CAAC,GAAG,IAAI;IACtD,IAAID,EAAE,EAAE;MACN7B,OAAO,CAACC,GAAG,CAAC,mBAAmB,GAAG4B,EAAE,CAAC;IACvC,CAAC,MAAM;MACL7B,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC;IACnD;IAED,IAAM8B,EAAE,GAAG3B,UAAU,CAACG,aAAa,CAAC,IAAI,CAAC;IACxCwB,EAAE,CAACC,WAAW,CAACvB,MAAM,CAAC;IACtBH,GAAG,CAAC0B,WAAW,CAACD,EAAE,CAAC;IACnB,OAAOzB,GAAG;EACZ;AACF,CAAC,EACD","ignoreList":[]}
|
package/lib/humanReadablePane.js
CHANGED
|
@@ -40,7 +40,7 @@ var humanReadablePane = {
|
|
|
40
40
|
|
|
41
41
|
// This data could come from a fetch OR from ldp container
|
|
42
42
|
var hasContentTypeIn2 = function hasContentTypeIn2(kb, x, displayables) {
|
|
43
|
-
var t = kb.findTypeURIs(
|
|
43
|
+
var t = kb.findTypeURIs(x);
|
|
44
44
|
for (var k = 0; k < displayables.length; k++) {
|
|
45
45
|
if (_rdflib.Util.mediaTypeClass(displayables[k]).uri in t) {
|
|
46
46
|
return true;
|
|
@@ -62,7 +62,7 @@ var humanReadablePane = {
|
|
|
62
62
|
var div = myDocument.createElement('div');
|
|
63
63
|
var kb = context.session.store;
|
|
64
64
|
var cts = kb.fetcher.getHeader(subject.doc(), 'content-type');
|
|
65
|
-
var ct = cts ? cts[0] : null;
|
|
65
|
+
var ct = cts ? cts[0].split(';', 1)[0].trim() : null; // remove content-type parameters
|
|
66
66
|
if (ct) {
|
|
67
67
|
// console.log('humanReadablePane: c-t:' + ct)
|
|
68
68
|
} else {
|
|
@@ -73,46 +73,59 @@ var humanReadablePane = {
|
|
|
73
73
|
div.setAttribute('class', 'docView');
|
|
74
74
|
var element = ct === 'text/markdown' ? 'DIV' : 'IFRAME';
|
|
75
75
|
var frame = myDocument.createElement(element);
|
|
76
|
+
var setIframeAttributes = function setIframeAttributes(frame, blob, lines) {
|
|
77
|
+
frame.setAttribute('src', URL.createObjectURL(blob));
|
|
78
|
+
frame.setAttribute('type', blob.type);
|
|
79
|
+
frame.setAttribute('class', 'doc');
|
|
80
|
+
frame.setAttribute('style', "border: 1px solid; padding: 1em; height: ".concat(lines, "em; width: 100%; max-width: 800px; resize: both; overflow: auto;"));
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
frame.setAttribute('class', 'doc');
|
|
86
|
-
frame.setAttribute('style', "border: 1px solid; padding: 1em; height: ".concat(lines, "em; width: 800px; resize: both; overflow: auto;"));
|
|
87
|
-
});
|
|
82
|
+
// Apply sandbox attribute only for HTML files
|
|
83
|
+
// @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
84
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
85
|
+
// You can't have any sandbox and allow plugins.
|
|
86
|
+
// We could sandbox only HTML files I suppose.
|
|
87
|
+
if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
|
|
88
|
+
frame.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
89
|
+
}
|
|
88
90
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
var processMarkdown = function processMarkdown(frame, markdownText) {
|
|
92
|
+
var lines = Math.min(30, markdownText.split(/\n/).length + 5);
|
|
93
|
+
var res = _marked.marked.parse(markdownText);
|
|
94
|
+
var clean = _dompurify["default"].sanitize(res);
|
|
95
|
+
frame.innerHTML = clean;
|
|
96
|
+
frame.setAttribute('class', 'doc');
|
|
97
|
+
frame.setAttribute('style', "border: 1px solid; padding: 1em; height: ".concat(lines, "em; width: 100%; max-width: 800px; resize: both; overflow: auto;"));
|
|
98
|
+
};
|
|
99
|
+
var fetchAndProcessBlob = function fetchAndProcessBlob(kb, subject, frame) {
|
|
93
100
|
kb.fetcher._fetch(subject.uri).then(function (response) {
|
|
94
101
|
return response.blob();
|
|
95
102
|
}).then(function (blob) {
|
|
96
|
-
var
|
|
97
|
-
frame
|
|
98
|
-
frame.setAttribute('type', blob.type);
|
|
99
|
-
frame.setAttribute('class', 'doc');
|
|
103
|
+
var lines = blob.type.startsWith('text') ? Math.min(30, blob.text().split(/\n/).length + 5) : 5;
|
|
104
|
+
setIframeAttributes(frame, blob, lines);
|
|
100
105
|
return blob.type.startsWith('text') ? blob.text() : '';
|
|
101
106
|
}).then(function (blobText) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
if (blobText) {
|
|
108
|
+
var newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5;
|
|
109
|
+
var lines = Math.min(30, blobText.split(/\n/).length + newLines);
|
|
110
|
+
frame.setAttribute('style', "border: 1px solid; padding: 1em; height: ".concat(lines, "em; width: 100%; max-width: 800px; resize: both; overflow: auto;"));
|
|
111
|
+
}
|
|
112
|
+
})["catch"](function (error) {
|
|
113
|
+
console.error('Error processing blob:', error);
|
|
114
|
+
frame.setAttribute('style', 'border: 1px solid; padding: 1em; height: 5em; width: 100%; max-width: 800px; resize: both; overflow: auto;');
|
|
115
|
+
frame.textContent = 'Error loading content';
|
|
105
116
|
});
|
|
117
|
+
};
|
|
118
|
+
if (ct === 'text/markdown') {
|
|
119
|
+
kb.fetcher.webOperation('GET', subject.uri).then(function (response) {
|
|
120
|
+
var markdownText = response.responseText;
|
|
121
|
+
processMarkdown(frame, markdownText);
|
|
122
|
+
})["catch"](function (error) {
|
|
123
|
+
console.error('Error fetching markdown content:', error);
|
|
124
|
+
frame.innerHTML = '<p>Error loading content</p>';
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
fetchAndProcessBlob(kb, subject, frame);
|
|
106
128
|
}
|
|
107
|
-
|
|
108
|
-
// @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
109
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
110
|
-
// You can't have any sandbox and allow plugins.
|
|
111
|
-
// We could sandbox only HTML files I suppose.
|
|
112
|
-
// HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
|
|
113
|
-
|
|
114
|
-
// iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
|
|
115
|
-
|
|
116
129
|
var tr = myDocument.createElement('TR');
|
|
117
130
|
tr.appendChild(frame);
|
|
118
131
|
div.appendChild(tr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"humanReadablePane.js","names":["_solidUi","require","_rdflib","_marked","_dompurify","_interopRequireDefault","e","__esModule","humanReadablePane","icon","icons","originalIconBase","name","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","t","findTypeURIs","Util","mediaTypeClass","uri","ns","link","render","myDocument","dom","div","createElement","doc","ct","console","log","setAttribute","element","frame","markdownHtml","webOperation","then","response","markdownText","responseText","lines","Math","min","split","res","marked","parse","clean","DOMPurify","sanitize","innerHTML","concat","_fetch","blob","objectURL","URL","createObjectURL","type","startsWith","text","blobText","newLines","includes","tr","appendChild","_default","exports"],"sources":["../src/humanReadablePane.js"],"sourcesContent":["/* Human-readable Pane\n **\n ** This outline pane contains the document contents for an HTML document\n ** This is for peeking at a page, because the user might not want to leave the data browser.\n */\nimport { icons, ns } from 'solid-ui'\nimport { Util } from 'rdflib'\nimport { marked } from 'marked'\nimport DOMPurify from 'dompurify';\n\nconst humanReadablePane = {\n icon: icons.originalIconBase + 'tango/22-text-x-generic.png',\n\n name: 'humanReadable',\n\n label: function (subject, context) {\n const kb = context.session.store\n\n // See also the source pane, which has lower precedence.\n\n const allowed = [\n 'text/plain',\n 'text/html',\n 'text/markdown',\n 'application/xhtml+xml',\n 'image/png',\n 'image/jpeg',\n 'application/pdf',\n 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\n const cts = kb.fetcher.getHeader(x, 'content-type')\n if (cts) {\n for (let j = 0; j < cts.length; j++) {\n for (let k = 0; k < displayables.length; k++) {\n if (cts[j].indexOf(displayables[k]) >= 0) {\n return true\n }\n }\n }\n }\n return false\n }\n\n // This data could come from a fetch OR from ldp container\n const hasContentTypeIn2 = function (kb, x, displayables) {\n const t = kb.findTypeURIs(subject)\n for (let k = 0; k < displayables.length; k++) {\n if (Util.mediaTypeClass(displayables[k]).uri in t) {\n return true\n }\n }\n return false\n }\n\n if (!subject.uri) return null // no bnodes\n\n const t = kb.findTypeURIs(subject)\n if (t[ns.link('WebPage').uri]) return 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'View'\n }\n\n return null\n },\n\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0] : null\n if (ct) {\n // console.log('humanReadablePane: c-t:' + ct)\n } else {\n console.log('humanReadablePane: unknown content-type?')\n }\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.setAttribute('class', 'docView')\n const element = ct === 'text/markdown' ? 'DIV' : 'IFRAME'\n const frame = myDocument.createElement(element)\n\n // render markdown to html\n const markdownHtml = function () {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const markdownText = response.responseText\n const lines = Math.min(30, markdownText.split(/\\n/).length + 5)\n const res = marked.parse(markdownText)\n const clean = DOMPurify.sanitize(res)\n frame.innerHTML = clean\n frame.setAttribute('class', 'doc')\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`)\n })\n }\n\n if (ct === 'text/markdown') {\n markdownHtml()\n } else {\n // get with authenticated fetch\n kb.fetcher._fetch(subject.uri)\n .then(function(response) {\n return response.blob()\n })\n .then(function(blob) {\n const objectURL = URL.createObjectURL(blob)\n frame.setAttribute('src', objectURL)\n frame.setAttribute('type', blob.type)\n frame.setAttribute('class', 'doc')\n return blob.type.startsWith('text') ? blob.text() : ''\n })\n .then(function(blobText) {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines)\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)\n })\n }\n\n // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can't have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html\n\n // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static\n\n const tr = myDocument.createElement('TR')\n tr.appendChild(frame)\n div.appendChild(tr)\n return div\n }\n}\n\nexport default humanReadablePane\n// ends\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAkC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AARlC;AACA;AACA;AACA;AACA;;AAMA,IAAME,iBAAiB,GAAG;EACxBC,IAAI,EAAEC,cAAK,CAACC,gBAAgB,GAAG,6BAA6B;EAE5DC,IAAI,EAAE,eAAe;EAErBC,KAAK,EAAE,SAAPA,KAAKA,CAAYC,OAAO,EAAEC,OAAO,EAAE;IACjC,IAAMC,EAAE,GAAGD,OAAO,CAACE,OAAO,CAACC,KAAK;;IAEhC;;IAEA,IAAMC,OAAO,GAAG,CACd,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AAQ,CAAC,oDAAoD,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;QAClG,IAAMtB,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,EAAE,EAAEkB,QAAQ,CAACjB,KAAK,CAAC,IAAI,CAAC,CAAChC,MAAM,GAAGkD,QAAQ,CAAC;QAClE5B,KAAK,CAACF,YAAY,CAAC,OAAO,6CAAAoB,MAAA,CAA6CX,KAAK,mDAAgD,CAAC;MAC/H,CAAC,CAAC;IACN;;IAEA;IACA;IACA;IACA;IACA;;IAEA;;IAEA,IAAMuB,EAAE,GAAGxC,UAAU,CAACG,aAAa,CAAC,IAAI,CAAC;IACzCqC,EAAE,CAACC,WAAW,CAAC/B,KAAK,CAAC;IACrBR,GAAG,CAACuC,WAAW,CAACD,EAAE,CAAC;IACnB,OAAOtC,GAAG;EACZ;AACF,CAAC;AAAA,IAAAwC,QAAA,GAAAC,OAAA,cAEc1E,iBAAiB,EAChC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"humanReadablePane.js","names":["_solidUi","require","_rdflib","_marked","_dompurify","_interopRequireDefault","e","__esModule","humanReadablePane","icon","icons","originalIconBase","name","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","t","findTypeURIs","Util","mediaTypeClass","uri","ns","link","render","myDocument","dom","div","createElement","doc","ct","split","trim","console","log","setAttribute","element","frame","setIframeAttributes","blob","lines","URL","createObjectURL","type","concat","processMarkdown","markdownText","Math","min","res","marked","parse","clean","DOMPurify","sanitize","innerHTML","fetchAndProcessBlob","_fetch","then","response","startsWith","text","blobText","newLines","includes","error","textContent","webOperation","responseText","tr","appendChild","_default","exports"],"sources":["../src/humanReadablePane.js"],"sourcesContent":["/* Human-readable Pane\n **\n ** This outline pane contains the document contents for an HTML document\n ** This is for peeking at a page, because the user might not want to leave the data browser.\n */\nimport { icons, ns } from 'solid-ui'\nimport { Util } from 'rdflib'\nimport { marked } from 'marked'\nimport DOMPurify from 'dompurify';\n\nconst humanReadablePane = {\n icon: icons.originalIconBase + 'tango/22-text-x-generic.png',\n\n name: 'humanReadable',\n\n label: function (subject, context) {\n const kb = context.session.store\n\n // See also the source pane, which has lower precedence.\n\n const allowed = [\n 'text/plain',\n 'text/html',\n 'text/markdown',\n 'application/xhtml+xml',\n 'image/png',\n 'image/jpeg',\n 'application/pdf',\n 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\n const cts = kb.fetcher.getHeader(x, 'content-type')\n if (cts) {\n for (let j = 0; j < cts.length; j++) {\n for (let k = 0; k < displayables.length; k++) {\n if (cts[j].indexOf(displayables[k]) >= 0) {\n return true\n }\n }\n }\n }\n return false\n }\n\n // This data could come from a fetch OR from ldp container\n const hasContentTypeIn2 = function (kb, x, displayables) {\n const t = kb.findTypeURIs(x)\n for (let k = 0; k < displayables.length; k++) {\n if (Util.mediaTypeClass(displayables[k]).uri in t) {\n return true\n }\n }\n return false\n }\n\n if (!subject.uri) return null // no bnodes\n\n const t = kb.findTypeURIs(subject)\n if (t[ns.link('WebPage').uri]) return 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'View'\n }\n\n return null\n },\n\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null // remove content-type parameters\n if (ct) {\n // console.log('humanReadablePane: c-t:' + ct)\n } else {\n console.log('humanReadablePane: unknown content-type?')\n }\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.setAttribute('class', 'docView')\n const element = ct === 'text/markdown' ? 'DIV' : 'IFRAME'\n const frame = myDocument.createElement(element)\n\n const setIframeAttributes = (frame, blob, lines) => {\n frame.setAttribute('src', URL.createObjectURL(blob));\n frame.setAttribute('type', blob.type);\n frame.setAttribute('class', 'doc');\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 100%; max-width: 800px; resize: both; overflow: auto;`);\n\n // Apply sandbox attribute only for HTML files\n // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can't have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {\n frame.setAttribute('sandbox', 'allow-scripts allow-same-origin');\n }\n };\n\n const processMarkdown = (frame, markdownText) => {\n const lines = Math.min(30, markdownText.split(/\\n/).length + 5);\n const res = marked.parse(markdownText);\n const clean = DOMPurify.sanitize(res);\n frame.innerHTML = clean;\n frame.setAttribute('class', 'doc');\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 100%; max-width: 800px; resize: both; overflow: auto;`);\n };\n\n const fetchAndProcessBlob = (kb, subject, frame) => {\n kb.fetcher._fetch(subject.uri)\n .then(response => response.blob())\n .then(blob => {\n const lines = blob.type.startsWith('text') ? Math.min(30, blob.text().split(/\\n/).length + 5) : 5;\n setIframeAttributes(frame, blob, lines);\n return blob.type.startsWith('text') ? blob.text() : '';\n })\n .then(blobText => {\n if (blobText) {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5;\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines);\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 100%; max-width: 800px; resize: both; overflow: auto;`);\n }\n })\n .catch(error => {\n console.error('Error processing blob:', error);\n frame.setAttribute('style', 'border: 1px solid; padding: 1em; height: 5em; width: 100%; max-width: 800px; resize: both; overflow: auto;');\n frame.textContent = 'Error loading content';\n });\n };\n\n if (ct === 'text/markdown') {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const markdownText = response.responseText\n processMarkdown(frame, markdownText);\n }).catch(error => {\n console.error('Error fetching markdown content:', error)\n frame.innerHTML = '<p>Error loading content</p>'\n })\n } else {\n fetchAndProcessBlob(kb, subject, frame);\n }\n\n const tr = myDocument.createElement('TR')\n tr.appendChild(frame)\n div.appendChild(tr)\n return div\n }\n}\n\nexport default humanReadablePane\n// ends\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAkC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AARlC;AACA;AACA;AACA;AACA;;AAMA,IAAME,iBAAiB,GAAG;EACxBC,IAAI,EAAEC,cAAK,CAACC,gBAAgB,GAAG,6BAA6B;EAE5DC,IAAI,EAAE,eAAe;EAErBC,KAAK,EAAE,SAAPA,KAAKA,CAAYC,OAAO,EAAEC,OAAO,EAAE;IACjC,IAAMC,EAAE,GAAGD,OAAO,CAACE,OAAO,CAACC,KAAK;;IAEhC;;IAEA,IAAMC,OAAO,GAAG,CACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,WAAW,CACZ;IAED,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAaJ,EAAE,EAAEK,CAAC,EAAEC,YAAY,EAAE;MACtD,IAAMC,GAAG,GAAGP,EAAE,CAACQ,OAAO,CAACC,SAAS,CAACJ,CAAC,EAAE,cAAc,CAAC;MACnD,IAAIE,GAAG,EAAE;QACP,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,GAAG,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;UACnC,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,YAAY,CAACK,MAAM,EAAEC,CAAC,EAAE,EAAE;YAC5C,IAAIL,GAAG,CAAC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O1C,GAAG;EACZ;AACF,CAAC;AAAA,IAAA4C,QAAA,GAAAC,OAAA,cAEc9E,iBAAiB,EAChC","ignoreList":[]}
|
package/lib/versionInfo.d.ts
CHANGED
|
@@ -5,22 +5,29 @@ declare const _default: {
|
|
|
5
5
|
'solid-panes': string;
|
|
6
6
|
npm: string;
|
|
7
7
|
node: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
zlib: string;
|
|
11
|
-
brotli: string;
|
|
8
|
+
acorn: string;
|
|
9
|
+
ada: string;
|
|
12
10
|
ares: string;
|
|
11
|
+
base64: string;
|
|
12
|
+
brotli: string;
|
|
13
|
+
cjs_module_lexer: string;
|
|
14
|
+
cldr: string;
|
|
15
|
+
icu: string;
|
|
16
|
+
llhttp: string;
|
|
13
17
|
modules: string;
|
|
14
|
-
nghttp2: string;
|
|
15
18
|
napi: string;
|
|
16
|
-
|
|
19
|
+
nghttp2: string;
|
|
20
|
+
nghttp3: string;
|
|
21
|
+
ngtcp2: string;
|
|
17
22
|
openssl: string;
|
|
18
|
-
|
|
19
|
-
icu: string;
|
|
23
|
+
simdutf: string;
|
|
20
24
|
tz: string;
|
|
25
|
+
undici: string;
|
|
21
26
|
unicode: string;
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
uv: string;
|
|
28
|
+
uvwasi: string;
|
|
29
|
+
v8: string;
|
|
30
|
+
zlib: string;
|
|
24
31
|
};
|
|
25
32
|
};
|
|
26
33
|
export default _default;
|
package/lib/versionInfo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionInfo.d.ts","sourceRoot":"","sources":["../src/versionInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"versionInfo.d.ts","sourceRoot":"","sources":["../src/versionInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAgCE"}
|
package/lib/versionInfo.js
CHANGED
|
@@ -5,28 +5,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _default = exports["default"] = {
|
|
8
|
-
buildTime: "2025-02-
|
|
9
|
-
commit: "
|
|
8
|
+
buildTime: "2025-02-13T15:35:19Z",
|
|
9
|
+
commit: "b526cdb4aede7380df5d983d191589540522b757",
|
|
10
10
|
npmInfo: {
|
|
11
11
|
'solid-panes': '3.6.2',
|
|
12
12
|
npm: '8.19.4',
|
|
13
|
-
node: '
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
llhttp: '6.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
node: '18.20.6',
|
|
14
|
+
acorn: '8.13.0',
|
|
15
|
+
ada: '2.8.0',
|
|
16
|
+
ares: '1.29.0',
|
|
17
|
+
base64: '0.5.2',
|
|
18
|
+
brotli: '1.1.0',
|
|
19
|
+
cjs_module_lexer: '1.2.2',
|
|
20
|
+
cldr: '44.1',
|
|
21
|
+
icu: '74.2',
|
|
22
|
+
llhttp: '6.1.1',
|
|
23
|
+
modules: '108',
|
|
24
|
+
napi: '9',
|
|
25
|
+
nghttp2: '1.61.0',
|
|
26
|
+
nghttp3: '0.7.0',
|
|
27
|
+
ngtcp2: '1.3.0',
|
|
28
|
+
openssl: '3.0.15+quic',
|
|
29
|
+
simdutf: '5.6.0',
|
|
30
|
+
tz: '2024a',
|
|
31
|
+
undici: '5.28.5',
|
|
32
|
+
unicode: '15.1',
|
|
33
|
+
uv: '1.44.2',
|
|
34
|
+
uvwasi: '0.0.19',
|
|
35
|
+
v8: '10.2.154.26-node.37',
|
|
36
|
+
zlib: '1.3.0.1-motley'
|
|
30
37
|
}
|
|
31
38
|
};
|
|
32
39
|
//# sourceMappingURL=versionInfo.js.map
|
package/lib/versionInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionInfo.js","names":["buildTime","commit","npmInfo","npm","node","
|
|
1
|
+
{"version":3,"file":"versionInfo.js","names":["buildTime","commit","npmInfo","npm","node","acorn","ada","ares","base64","brotli","cjs_module_lexer","cldr","icu","llhttp","modules","napi","nghttp2","nghttp3","ngtcp2","openssl","simdutf","tz","undici","unicode","uv","uvwasi","v8","zlib"],"sources":["../src/versionInfo.ts"],"sourcesContent":["export default {\nbuildTime: \"2025-02-13T15:35:19Z\",\ncommit: \"b526cdb4aede7380df5d983d191589540522b757\",\nnpmInfo:\n{\n 'solid-panes': '3.6.2',\n npm: '8.19.4',\n node: '18.20.6',\n acorn: '8.13.0',\n ada: '2.8.0',\n ares: '1.29.0',\n base64: '0.5.2',\n brotli: '1.1.0',\n cjs_module_lexer: '1.2.2',\n cldr: '44.1',\n icu: '74.2',\n llhttp: '6.1.1',\n modules: '108',\n napi: '9',\n nghttp2: '1.61.0',\n nghttp3: '0.7.0',\n ngtcp2: '1.3.0',\n openssl: '3.0.15+quic',\n simdutf: '5.6.0',\n tz: '2024a',\n undici: '5.28.5',\n unicode: '15.1',\n uv: '1.44.2',\n uvwasi: '0.0.19',\n v8: '10.2.154.26-node.37',\n zlib: '1.3.0.1-motley'\n}\n};\n"],"mappings":";;;;;;oCAAe;EACfA,SAAS,EAAE,sBAAsB;EACjCC,MAAM,EAAE,0CAA0C;EAClDC,OAAO,EACP;IACE,aAAa,EAAE,OAAO;IACtBC,GAAG,EAAE,QAAQ;IACbC,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE,QAAQ;IACfC,GAAG,EAAE,OAAO;IACZC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE,OAAO;IACfC,MAAM,EAAE,OAAO;IACfC,gBAAgB,EAAE,OAAO;IACzBC,IAAI,EAAE,MAAM;IACZC,GAAG,EAAE,MAAM;IACXC,MAAM,EAAE,OAAO;IACfC,OAAO,EAAE,KAAK;IACdC,IAAI,EAAE,GAAG;IACTC,OAAO,EAAE,QAAQ;IACjBC,OAAO,EAAE,OAAO;IAChBC,MAAM,EAAE,OAAO;IACfC,OAAO,EAAE,aAAa;IACtBC,OAAO,EAAE,OAAO;IAChBC,EAAE,EAAE,OAAO;IACXC,MAAM,EAAE,QAAQ;IAChBC,OAAO,EAAE,MAAM;IACfC,EAAE,EAAE,QAAQ;IACZC,MAAM,EAAE,QAAQ;IAChBC,EAAE,EAAE,qBAAqB;IACzBC,IAAI,EAAE;EACR;AACA,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ export default {
|
|
|
47
47
|
|
|
48
48
|
// This data coul d come from a fetch OR from ldp comtaimner
|
|
49
49
|
const hasContentTypeIn2 = function (kb, x, displayables) {
|
|
50
|
-
const t = kb.findTypeURIs(
|
|
50
|
+
const t = kb.findTypeURIs(x)
|
|
51
51
|
for (let k = 0; k < displayables.length; k++) {
|
|
52
52
|
if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {
|
|
53
53
|
return true
|
|
@@ -138,41 +138,49 @@ export default {
|
|
|
138
138
|
div.setAttribute('class', 'docView')
|
|
139
139
|
const iframe = myDocument.createElement('IFRAME')
|
|
140
140
|
|
|
141
|
-
//
|
|
141
|
+
// Function to set iframe attributes
|
|
142
|
+
const setIframeAttributes = (iframe, blob, lines) => {
|
|
143
|
+
const objectURL = URL.createObjectURL(blob)
|
|
144
|
+
iframe.setAttribute('src', objectURL)
|
|
145
|
+
iframe.setAttribute('type', blob.type)
|
|
146
|
+
iframe.setAttribute('class', 'doc')
|
|
147
|
+
iframe.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)
|
|
148
|
+
|
|
149
|
+
// Apply sandbox attribute only for HTML files
|
|
150
|
+
// @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
151
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
152
|
+
// You can;'t have any sandbox and allow plugins.
|
|
153
|
+
// We could sandbox only HTML files I suppose.
|
|
154
|
+
// HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
|
|
155
|
+
if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
|
|
156
|
+
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin')
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Fetch and process the blob
|
|
142
161
|
kb.fetcher._fetch(subject.uri)
|
|
143
|
-
.then(
|
|
144
|
-
|
|
162
|
+
.then(response => response.blob())
|
|
163
|
+
.then(blob => {
|
|
164
|
+
const blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('')
|
|
165
|
+
return blobTextPromise.then(blobText => ({ blob, blobText }))
|
|
145
166
|
})
|
|
146
|
-
.then(
|
|
147
|
-
const objectURL = URL.createObjectURL(blob)
|
|
148
|
-
iframe.setAttribute('src', objectURL) // w640 h480 //
|
|
149
|
-
iframe.setAttribute('type', blob.type)
|
|
150
|
-
iframe.setAttribute('class', 'doc')
|
|
151
|
-
return blob.text()
|
|
152
|
-
})
|
|
153
|
-
.then(function(blobText) {
|
|
167
|
+
.then(({ blob, blobText }) => {
|
|
154
168
|
const newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5
|
|
155
169
|
const lines = Math.min(30, blobText.split(/\n/).length + newLines)
|
|
156
|
-
iframe
|
|
157
|
-
|
|
158
|
-
.catch(err => {
|
|
170
|
+
setIframeAttributes(iframe, blob, lines)
|
|
171
|
+
})
|
|
172
|
+
.catch(err => {
|
|
173
|
+
console.log('Error fetching or processing blob:', err)
|
|
174
|
+
})
|
|
159
175
|
|
|
160
176
|
const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')
|
|
161
|
-
const ct = cts ? cts[0] : null
|
|
177
|
+
const ct = cts ? cts[0].split(';', 1)[0].trim() : null
|
|
162
178
|
if (ct) {
|
|
163
179
|
console.log('dokieliPane: c-t:' + ct)
|
|
164
180
|
} else {
|
|
165
181
|
console.log('dokieliPane: unknown content-type?')
|
|
166
182
|
}
|
|
167
183
|
|
|
168
|
-
// @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
169
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
170
|
-
// You can;'t have any sandbox and allow plugins.
|
|
171
|
-
// We could sandbox only HTML files I suppose.
|
|
172
|
-
// HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
|
|
173
|
-
|
|
174
|
-
// iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
|
|
175
|
-
|
|
176
184
|
const tr = myDocument.createElement('tr')
|
|
177
185
|
tr.appendChild(iframe)
|
|
178
186
|
div.appendChild(tr)
|
package/src/humanReadablePane.js
CHANGED
|
@@ -45,7 +45,7 @@ const humanReadablePane = {
|
|
|
45
45
|
|
|
46
46
|
// This data could come from a fetch OR from ldp container
|
|
47
47
|
const hasContentTypeIn2 = function (kb, x, displayables) {
|
|
48
|
-
const t = kb.findTypeURIs(
|
|
48
|
+
const t = kb.findTypeURIs(x)
|
|
49
49
|
for (let k = 0; k < displayables.length; k++) {
|
|
50
50
|
if (Util.mediaTypeClass(displayables[k]).uri in t) {
|
|
51
51
|
return true
|
|
@@ -75,7 +75,7 @@ const humanReadablePane = {
|
|
|
75
75
|
const kb = context.session.store
|
|
76
76
|
|
|
77
77
|
const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')
|
|
78
|
-
const ct = cts ? cts[0] : null
|
|
78
|
+
const ct = cts ? cts[0].split(';', 1)[0].trim() : null // remove content-type parameters
|
|
79
79
|
if (ct) {
|
|
80
80
|
// console.log('humanReadablePane: c-t:' + ct)
|
|
81
81
|
} else {
|
|
@@ -87,49 +87,65 @@ const humanReadablePane = {
|
|
|
87
87
|
const element = ct === 'text/markdown' ? 'DIV' : 'IFRAME'
|
|
88
88
|
const frame = myDocument.createElement(element)
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const setIframeAttributes = (frame, blob, lines) => {
|
|
91
|
+
frame.setAttribute('src', URL.createObjectURL(blob));
|
|
92
|
+
frame.setAttribute('type', blob.type);
|
|
93
|
+
frame.setAttribute('class', 'doc');
|
|
94
|
+
frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 100%; max-width: 800px; resize: both; overflow: auto;`);
|
|
95
|
+
|
|
96
|
+
// Apply sandbox attribute only for HTML files
|
|
97
|
+
// @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
98
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
99
|
+
// You can't have any sandbox and allow plugins.
|
|
100
|
+
// We could sandbox only HTML files I suppose.
|
|
101
|
+
if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
|
|
102
|
+
frame.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const processMarkdown = (frame, markdownText) => {
|
|
107
|
+
const lines = Math.min(30, markdownText.split(/\n/).length + 5);
|
|
108
|
+
const res = marked.parse(markdownText);
|
|
109
|
+
const clean = DOMPurify.sanitize(res);
|
|
110
|
+
frame.innerHTML = clean;
|
|
111
|
+
frame.setAttribute('class', 'doc');
|
|
112
|
+
frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 100%; max-width: 800px; resize: both; overflow: auto;`);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const fetchAndProcessBlob = (kb, subject, frame) => {
|
|
116
|
+
kb.fetcher._fetch(subject.uri)
|
|
117
|
+
.then(response => response.blob())
|
|
118
|
+
.then(blob => {
|
|
119
|
+
const lines = blob.type.startsWith('text') ? Math.min(30, blob.text().split(/\n/).length + 5) : 5;
|
|
120
|
+
setIframeAttributes(frame, blob, lines);
|
|
121
|
+
return blob.type.startsWith('text') ? blob.text() : '';
|
|
122
|
+
})
|
|
123
|
+
.then(blobText => {
|
|
124
|
+
if (blobText) {
|
|
125
|
+
const newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5;
|
|
126
|
+
const lines = Math.min(30, blobText.split(/\n/).length + newLines);
|
|
127
|
+
frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 100%; max-width: 800px; resize: both; overflow: auto;`);
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
.catch(error => {
|
|
131
|
+
console.error('Error processing blob:', error);
|
|
132
|
+
frame.setAttribute('style', 'border: 1px solid; padding: 1em; height: 5em; width: 100%; max-width: 800px; resize: both; overflow: auto;');
|
|
133
|
+
frame.textContent = 'Error loading content';
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
if (ct === 'text/markdown') {
|
|
92
138
|
kb.fetcher.webOperation('GET', subject.uri).then(response => {
|
|
93
139
|
const markdownText = response.responseText
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
frame.innerHTML =
|
|
98
|
-
frame.setAttribute('class', 'doc')
|
|
99
|
-
frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`)
|
|
140
|
+
processMarkdown(frame, markdownText);
|
|
141
|
+
}).catch(error => {
|
|
142
|
+
console.error('Error fetching markdown content:', error)
|
|
143
|
+
frame.innerHTML = '<p>Error loading content</p>'
|
|
100
144
|
})
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (ct === 'text/markdown') {
|
|
104
|
-
markdownHtml()
|
|
105
145
|
} else {
|
|
106
|
-
|
|
107
|
-
kb.fetcher._fetch(subject.uri)
|
|
108
|
-
.then(function(response) {
|
|
109
|
-
return response.blob()
|
|
110
|
-
})
|
|
111
|
-
.then(function(blob) {
|
|
112
|
-
const objectURL = URL.createObjectURL(blob)
|
|
113
|
-
frame.setAttribute('src', objectURL)
|
|
114
|
-
frame.setAttribute('type', blob.type)
|
|
115
|
-
frame.setAttribute('class', 'doc')
|
|
116
|
-
return blob.type.startsWith('text') ? blob.text() : ''
|
|
117
|
-
})
|
|
118
|
-
.then(function(blobText) {
|
|
119
|
-
const newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5
|
|
120
|
-
const lines = Math.min(30, blobText.split(/\n/).length + newLines)
|
|
121
|
-
frame.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)
|
|
122
|
-
})
|
|
146
|
+
fetchAndProcessBlob(kb, subject, frame);
|
|
123
147
|
}
|
|
124
148
|
|
|
125
|
-
// @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
|
|
126
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
127
|
-
// You can't have any sandbox and allow plugins.
|
|
128
|
-
// We could sandbox only HTML files I suppose.
|
|
129
|
-
// HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
|
|
130
|
-
|
|
131
|
-
// iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
|
|
132
|
-
|
|
133
149
|
const tr = myDocument.createElement('TR')
|
|
134
150
|
tr.appendChild(frame)
|
|
135
151
|
div.appendChild(tr)
|
package/src/versionInfo.ts
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
buildTime: "2025-02-
|
|
3
|
-
commit: "
|
|
2
|
+
buildTime: "2025-02-13T15:35:19Z",
|
|
3
|
+
commit: "b526cdb4aede7380df5d983d191589540522b757",
|
|
4
4
|
npmInfo:
|
|
5
5
|
{
|
|
6
6
|
'solid-panes': '3.6.2',
|
|
7
7
|
npm: '8.19.4',
|
|
8
|
-
node: '
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
llhttp: '6.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
node: '18.20.6',
|
|
9
|
+
acorn: '8.13.0',
|
|
10
|
+
ada: '2.8.0',
|
|
11
|
+
ares: '1.29.0',
|
|
12
|
+
base64: '0.5.2',
|
|
13
|
+
brotli: '1.1.0',
|
|
14
|
+
cjs_module_lexer: '1.2.2',
|
|
15
|
+
cldr: '44.1',
|
|
16
|
+
icu: '74.2',
|
|
17
|
+
llhttp: '6.1.1',
|
|
18
|
+
modules: '108',
|
|
19
|
+
napi: '9',
|
|
20
|
+
nghttp2: '1.61.0',
|
|
21
|
+
nghttp3: '0.7.0',
|
|
22
|
+
ngtcp2: '1.3.0',
|
|
23
|
+
openssl: '3.0.15+quic',
|
|
24
|
+
simdutf: '5.6.0',
|
|
25
|
+
tz: '2024a',
|
|
26
|
+
undici: '5.28.5',
|
|
27
|
+
unicode: '15.1',
|
|
28
|
+
uv: '1.44.2',
|
|
29
|
+
uvwasi: '0.0.19',
|
|
30
|
+
v8: '10.2.154.26-node.37',
|
|
31
|
+
zlib: '1.3.0.1-motley'
|
|
25
32
|
}
|
|
26
33
|
};
|