solid-ui 2.4.15 → 2.4.16-9d83fb17
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/lib/chat/bookmarks.js +14 -13
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +340 -0
- package/lib/chat/chatLogic.js.map +1 -0
- package/lib/chat/dateFolder.js +12 -12
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +285 -665
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +445 -71
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +165 -103
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +162 -32
- package/lib/chat/thread.js.map +1 -1
- package/lib/versionInfo.js +3 -3
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +1401 -986
- package/lib/webpack-bundle.js.map +1 -1
- package/lib/widgets/buttons.d.ts.map +1 -1
- package/lib/widgets/buttons.js +8 -1
- package/lib/widgets/buttons.js.map +1 -1
- package/package.json +1 -1
package/lib/chat/message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/chat/message.js"],"names":["UI","authn","icons","ns","media","pad","rdf","store","style","utils","widgets","dom","window","document","messageBodyStyle","label","elementForImageURI","imageUri","options","img","createElement","height","inlineImageHeightEms","trim","setAttribute","anchor","appendChild","makeDraggable","$rdf","sym","text","term","a","uri","addEventListener","openHrefInOutlineMode","textContent","nick","person","s","any","foaf","value","creatorAndDate","td1","creator","date","message","nickAnchor","fetcher","nowOrWhenFetched","doc","undefined","_ok","_body","creatorAndDateHorizontal","dateBit","fontSize","marginLeft","renderMessage","messageTable","bindings","fresh","userContext","colorizeByAuthor","content","dateString","messageRow","AJAR_date","AJAR_subject","selectedMessage","sameTerm","backgroundColor","selectedElement","done","ele","firstChild","nextSibling","newestFirst","newestfirst","insertBefore","authorAboveContent","setImage","shortDate","td2","isURI","test","para","isImage","expandImagesInline","anc","href","bgcolor","lightColorHash","getBgColor","strip","children","length","td3","toolsButton","button","iconBase","_event","toolTR","parentNode","removeChild","toolsTR","tools","parentElement","toolsTD"],"mappings":";;;;;;;;;;;;AASA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AApBA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAU8B;AAK9B,IAAMA,EAAE,GAAG;AAAEC,EAAAA,KAAK,EAALA,YAAF;AAASC,EAAAA,KAAK,EAALA,eAAT;AAAgBC,EAAAA,EAAE,EAAFA,EAAhB;AAAoBC,EAAAA,KAAK,EAALA,aAApB;AAA2BC,EAAAA,GAAG,EAAHA,GAA3B;AAAgCC,EAAAA,GAAG,EAAHA,GAAhC;AAAqCC,EAAAA,KAAK,EAALA,YAArC;AAA4CC,EAAAA,KAAK,EAALA,KAA5C;AAAmDC,EAAAA,KAAK,EAALA,KAAnD;AAA0DC,EAAAA,OAAO,EAAPA;AAA1D,CAAX;AAEA,IAAMC,GAAG,GAAGX,EAAE,CAACW,GAAH,IAAUC,MAAM,CAACC,QAA7B,C,CACA;;AAEA,IAAMC,gBAAgB,GAAGd,EAAE,CAACQ,KAAH,CAASM,gBAAlC;AAEA,IAAMC,KAAK,GAAGf,EAAE,CAACS,KAAH,CAASM,KAAvB;AAEA;AACA;AACA;;AACO,SAASC,kBAAT,CAA6BC,QAA7B,EAAuCC,OAAvC,EAAgD;AACrD,MAAMC,GAAG,GAAGR,GAAG,CAACS,aAAJ,CAAkB,KAAlB,CAAZ;AACA,MAAIC,MAAM,GAAG,IAAb;;AACA,MAAIH,OAAO,CAACI,oBAAZ,EAAkC;AAChCD,IAAAA,MAAM,GAAG,CAAC,KAAKH,OAAO,CAACI,oBAAd,EAAoCC,IAApC,EAAT;AACD;;AACDJ,EAAAA,GAAG,CAACK,YAAJ,CACE,OADF,EAEE,iBAAiBH,MAAjB,GAA0B,wCAF5B,EANqD,CAUr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,CAACoC,MAAlB;AACA;AACD;;AACD,QAAMG,OAAO,GAAG/F,GAAG,CAACS,aAAJ,CAAkB,IAAlB,CAAhB;AACA,QAAMuF,KAAK,GAAG,kCAAe5D,OAAf,EAAwBoB,UAAxB,EAAoCJ,WAApC,CAAd;AACA4C,IAAAA,KAAK,CAACnG,KAAN,GACE,kHADF,CATsD,CAU+D;;AACrH,QAAI2D,UAAU,CAACU,WAAf,EAA4B;AAC1BV,MAAAA,UAAU,CAACyC,aAAX,CAAyB5B,YAAzB,CAAsC0B,OAAtC,EAA+CvC,UAAU,CAACU,WAA1D;AACD,KAFD,MAEO;AACLV,MAAAA,UAAU,CAACyC,aAAX,CAAyBlF,WAAzB,CAAqCgF,OAArC;AACD;;AACDvC,IAAAA,UAAU,CAACoC,MAAX,GAAoBG,OAApB;AACAA,IAAAA,OAAO,CAAChF,WAAR,CAAoBf,GAAG,CAACS,aAAJ,CAAkB,IAAlB,CAApB,EAjBsD,CAiBT;;AAC7C,QAAMyF,OAAO,GAAGH,OAAO,CAAChF,WAAR,CAAoBf,GAAG,CAACS,aAAJ,CAAkB,IAAlB,CAApB,CAAhB;AACAsF,IAAAA,OAAO,CAAChF,WAAR,CAAoBf,GAAG,CAACS,aAAJ,CAAkB,IAAlB,CAApB,EAnBsD,CAmBT;;AAC7CyF,IAAAA,OAAO,CAACnF,WAAR,CAAoBiF,KAApB;AACD,GArBD;AAsBA,SAAOxC,UAAP;AACD","sourcesContent":["/**\n * Contains the [[renderMessage]] function,\n * along with [[elementForImageURI]],\n * [[creatorAndDate]], and [[creatorAndDateHorizontal]]\n * @packageDocumentation\n */\n\n/* global $rdf */\n\nimport { messageToolbar, sentimentStripLinked } from './messageTools'\n\nimport { authn } from '../authn/index'\nimport { icons } from '../iconBase'\nimport { store } from '../logic'\nimport { media } from '../media/index'\nimport * as ns from '../ns'\nimport * as pad from '../pad'\nimport * as rdf from 'rdflib' // pull in first avoid cross-refs\nimport * as style from '../style'\nimport * as utils from '../utils'\nimport * as widgets from '../widgets'\n\nconst UI = { authn, icons, ns, media, pad, rdf, store, style, utils, widgets }\n\nconst dom = UI.dom || window.document\n// const kb = UI.store\n\nconst messageBodyStyle = UI.style.messageBodyStyle\n\nconst label = UI.utils.label\n\n/**\n * HTML component for an image\n */\nexport function elementForImageURI (imageUri, options) {\n const img = dom.createElement('img')\n let height = '10'\n if (options.inlineImageHeightEms) {\n height = ('' + options.inlineImageHeightEms).trim()\n }\n img.setAttribute(\n 'style',\n 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'\n )\n // UI.widgets.makeDropTarget(img, handleURIsDroppedOnMugshot, droppedFileHandler)\n if (imageUri) img.setAttribute('src', imageUri)\n const anchor = dom.createElement('a')\n anchor.setAttribute('href', imageUri)\n anchor.setAttribute('target', 'images')\n anchor.appendChild(img)\n UI.widgets.makeDraggable(img, $rdf.sym(imageUri))\n return anchor\n}\n\nconst anchor = function (text, term) {\n // If there is no link return an element anyway\n const a = dom.createElement('a')\n if (term && term.uri) {\n a.setAttribute('href', term.uri)\n a.addEventListener('click', UI.widgets.openHrefInOutlineMode, true)\n a.setAttribute('style', 'color: #3B5998; text-decoration: none; ') // font-weight: bold\n }\n a.textContent = text\n return a\n}\n\nfunction nick (person) {\n const s = UI.store.any(person, UI.ns.foaf('nick'))\n if (s) return '' + s.value\n return '' + label(person)\n}\n\n/**\n * Displays creator and date for a chat message\n * inside the `td1` element\n */\nexport function creatorAndDate (td1, creator, date, message) {\n const nickAnchor = td1.appendChild(anchor(nick(creator), creator))\n if (creator.uri) {\n UI.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (\n _ok,\n _body\n ) {\n nickAnchor.textContent = nick(creator)\n })\n }\n td1.appendChild(dom.createElement('br'))\n td1.appendChild(anchor(date, message))\n}\n\n/**\n * Horizontally displays creator and date for a chat message\n * inside the `td1` element\n */\nexport function creatorAndDateHorizontal (td1, creator, date, message) {\n const nickAnchor = td1.appendChild(anchor(label(creator), creator))\n if (creator.uri) {\n UI.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (\n _ok,\n _body\n ) {\n nickAnchor.textContent = nick(creator)\n })\n }\n const dateBit = td1.appendChild(anchor(date, message))\n dateBit.style.fontSize = '80%'\n dateBit.style.marginLeft = '1em'\n td1.appendChild(dom.createElement('br'))\n}\n\n/**\n * Renders a chat message inside a `messageTable`\n */\nexport function renderMessage (\n messageTable,\n bindings,\n fresh,\n options,\n userContext\n) {\n const colorizeByAuthor =\n options.colorizeByAuthor === '1' || options.colorizeByAuthor === true\n\n const creator = bindings['?creator']\n const message = bindings['?msg']\n const date = bindings['?date']\n const content = bindings['?content']\n\n const dateString = date.value\n const messageRow = dom.createElement('tr')\n messageRow.AJAR_date = dateString\n messageRow.AJAR_subject = message\n\n if (options.selectedMessage && options.selectedMessage.sameTerm(message)) {\n messageRow.style.backgroundColor = 'yellow'\n options.selectedElement = messageRow\n messageTable.selectedElement = messageRow\n }\n\n let done = false\n for (let ele = messageTable.firstChild; ; ele = ele.nextSibling) {\n if (!ele) {\n // empty\n break\n }\n const newestFirst = options.newestfirst === true\n if (\n (dateString > ele.AJAR_date && newestFirst) ||\n (dateString < ele.AJAR_date && !newestFirst)\n ) {\n messageTable.insertBefore(messageRow, ele)\n done = true\n break\n }\n }\n if (!done) {\n messageTable.appendChild(messageRow)\n }\n\n const td1 = dom.createElement('td')\n messageRow.appendChild(td1)\n if (options.authorAboveContent) {\n const img = dom.createElement('img')\n img.setAttribute(\n 'style',\n 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;'\n )\n UI.widgets.setImage(img, creator)\n td1.appendChild(img)\n } else {\n creatorAndDate(td1, creator, UI.widgets.shortDate(dateString), message)\n }\n\n // Render the content ot the message itself\n const td2 = messageRow.appendChild(dom.createElement('td'))\n\n if (options.authorAboveContent) {\n creatorAndDateHorizontal(\n td2,\n creator,\n UI.widgets.shortDate(dateString),\n message\n )\n }\n const text = content.value.trim()\n const isURI = /^https?:\\/[^ <>]*$/i.test(text)\n let para = null\n if (isURI) {\n const isImage = /\\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text) // @@ Should use content-type not URI\n if (isImage && options.expandImagesInline) {\n const img = elementForImageURI(text, options)\n td2.appendChild(img)\n } else {\n // Link but not Image\n const anc = td2.appendChild(dom.createElement('a'))\n para = anc.appendChild(dom.createElement('p'))\n anc.href = text\n para.textContent = text\n td2.appendChild(anc)\n }\n } else {\n // text\n para = dom.createElement('p')\n td2.appendChild(para)\n para.textContent = text\n }\n if (para) {\n const bgcolor = colorizeByAuthor\n ? UI.pad.lightColorHash(creator)\n : getBgColor(fresh)\n para.setAttribute(\n 'style',\n messageBodyStyle + 'background-color: ' + bgcolor + ';'\n )\n }\n\n function getBgColor (fresh) {\n return fresh ? '#e8ffe8' : 'white'\n }\n\n // Sentiment strip\n const strip = sentimentStripLinked(message, message.doc())\n if (strip.children.length) {\n td2.appendChild(dom.createElement('br'))\n td2.appendChild(strip)\n }\n\n // Message tool bar button\n const td3 = dom.createElement('td')\n messageRow.appendChild(td3)\n const toolsButton = UI.widgets.button(\n dom,\n UI.icons.iconBase + 'noun_243787.svg',\n '...'\n )\n td3.appendChild(toolsButton)\n toolsButton.addEventListener('click', function (_event) {\n if (messageRow.toolTR) {\n // already got a toolbar? Toogle\n messageRow.parentNode.removeChild(messageRow.toolTR)\n delete messageRow.toolTR\n return\n }\n const toolsTR = dom.createElement('tr')\n const tools = messageToolbar(message, messageRow, userContext)\n tools.style =\n 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;' // @@ fix\n if (messageRow.nextSibling) {\n messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling)\n } else {\n messageRow.parentElement.appendChild(toolsTR)\n }\n messageRow.toolTR = toolsTR\n toolsTR.appendChild(dom.createElement('td')) // left\n const toolsTD = toolsTR.appendChild(dom.createElement('td'))\n toolsTR.appendChild(dom.createElement('td')) // right\n toolsTD.appendChild(tools)\n })\n return messageRow\n}\n"],"file":"message.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/chat/message.js"],"names":["dom","window","document","messageBodyStyle","style","label","utils","elementForImageURI","imageUri","options","img","createElement","height","inlineImageHeightEms","trim","setAttribute","anchor","appendChild","widgets","makeDraggable","$rdf","sym","text","term","a","uri","addEventListener","openHrefInOutlineMode","textContent","nick","person","s","store","any","ns","foaf","value","creatorAndDate","td1","creator","date","message","nickAnchor","fetcher","nowOrWhenFetched","doc","undefined","_ok","_body","creatorAndDateHorizontal","dateBit","fontSize","marginLeft","renderMessageRow","channelObject","fresh","userContext","colorizeByAuthor","dct","latestVersion","content","sioc","originalMessage","edited","sameTerm","sortDate","the","messageRow","AJAR_date","AJAR_subject","authorDateOnLeft","setImage","shortDate","bothDates","td2","isURI","test","para","isImage","expandImagesInline","anc","href","bgcolor","pad","lightColorHash","getBgColor","strip","children","length","td3","toolsButton","button","icons","iconBase","_event","toolTR","parentNode","removeChild","toolsTR","tools","nextSibling","parentElement","insertBefore","toolsTD","switchToEditor","messageTable","editRow","renderMessageEditor","originalRow","visibility","revertEditing","messageEditor","handleFieldInput","sendMessage","field","fromMainField","sendComplete","_text2","oldRow","debug","warn","backgroundColor","disabled","scrollIntoView","newestFirst","focus","select","updateMessage","statusArea","errorMessageBlock","droppedFileHandler","files","base","chatDocument","dir","uploadFiles","theFile","destURI","droppedURIHandler","uris","turnOnInput","getImageDoc","imageDoc","Date","now","tookPicture","menuButton","menuHandler","buttonStyle","rhs","me","authn","currentUser","menuOptions","div","newBase","event","chatChannel","lhs","middle","innerHTML","rows","anyValue","e","code","shiftKey","shiftEnterSendsMessage","makeDropTarget","sendButton","sendIcon","cancelButton","dateFolder","leafDocumentFromDate","media","cameraButton","recordParticipation","channel","context","logIn","then","Object","assign","_context"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;AAE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EA;AAApB,GAAhB;;AAEAuJ,eAAM2B,KAAN,CAAYD,OAAZ,EAAqBE,IAArB,CAA0B,UAAAF,OAAO,EAAI;AACnC;AACArC,IAAAA,WAAW;AACXwC,IAAAA,MAAM,CAACC,MAAP,CAAcJ,OAAd,EAAuBzH,WAAvB;AACA,yCAAqByH,OAArB,EAA8BE,IAA9B,CAAmC,UAAAG,QAAQ,EAAI,CAC7C;AACD,KAFD;AAGD,GAPD;;AASA,SAAOvE,aAAP;AACD,C,CAAC","sourcesContent":["/** UI code for individual messages: display them, edit them\n *\n * @packageDocumentation\n */\n\n/* global $rdf */\nimport { insertMessageIntoTable } from './infinite'\n\nimport { messageToolbar, sentimentStripLinked } from './messageTools'\nimport { findBookmarkDocument } from './bookmarks'\nimport { mostRecentVersion, originalVersion } from './chatLogic'\n\nimport * as debug from '../debug'\nimport { authn } from '../authn/index'\nimport { icons } from '../iconBase'\nimport { store } from '../logic'\nimport { media } from '../media/index'\nimport * as ns from '../ns'\nimport * as pad from '../pad'\n// import * as rdf from 'rdflib' // pull in first avoid cross-refs\nimport * as style from '../style'\nimport * as utils from '../utils'\nimport * as widgets from '../widgets'\n\n// const UI = { authn, icons, ns, media, pad, rdf, store, style, utils, widgets }\n\nconst dom = window.document\n\n// const store = store\n\nconst messageBodyStyle = style.messageBodyStyle\n\nconst label = utils.label\n\n/**\n * HTML component for an image\n */\nexport function elementForImageURI (imageUri, options) {\n const img = dom.createElement('img')\n let height = '10'\n if (options.inlineImageHeightEms) {\n height = ('' + options.inlineImageHeightEms).trim()\n }\n img.setAttribute(\n 'style',\n 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'\n )\n // widgets.makeDropTarget(img, handleURIsDroppedOnMugshot, droppedFileHandler)\n if (imageUri) img.setAttribute('src', imageUri)\n const anchor = dom.createElement('a')\n anchor.setAttribute('href', imageUri)\n anchor.setAttribute('target', 'images')\n anchor.appendChild(img)\n widgets.makeDraggable(img, $rdf.sym(imageUri))\n return anchor\n}\n\nconst anchor = function (text, term) {\n // If there is no link return an element anyway\n const a = dom.createElement('a')\n if (term && term.uri) {\n a.setAttribute('href', term.uri)\n a.addEventListener('click', widgets.openHrefInOutlineMode, true)\n a.setAttribute('style', 'color: #3B5998; text-decoration: none; ') // font-weight: bold\n }\n a.textContent = text\n return a\n}\n\nfunction nick (person) {\n const s = store.any(person, ns.foaf('nick'))\n if (s) return '' + s.value\n return '' + label(person)\n}\n\n/**\n * Displays creator and date for a chat message\n * inside the `td1` element\n */\nexport function creatorAndDate (td1, creator, date, message) {\n const nickAnchor = td1.appendChild(anchor(nick(creator), creator))\n if (creator.uri) {\n store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (\n _ok,\n _body\n ) {\n nickAnchor.textContent = nick(creator)\n })\n }\n td1.appendChild(dom.createElement('br'))\n td1.appendChild(anchor(date, message))\n}\n\n/**\n * Horizontally displays creator and date for a chat message\n * inside the `td1` element\n */\nexport function creatorAndDateHorizontal (td1, creator, date, message) {\n const nickAnchor = td1.appendChild(anchor(label(creator), creator))\n if (creator.uri) {\n store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (\n _ok,\n _body\n ) {\n nickAnchor.textContent = nick(creator)\n })\n }\n const dateBit = td1.appendChild(anchor(date, message))\n dateBit.style.fontSize = '80%'\n dateBit.style.marginLeft = '1em'\n td1.appendChild(dom.createElement('br'))\n}\n\n/**\n * Renders a chat message, read-only mode\n */\nexport function renderMessageRow (channelObject, message, fresh, options, userContext) {\n const colorizeByAuthor =\n options.colorizeByAuthor === '1' || options.colorizeByAuthor === true\n\n const creator = store.any(message, ns.foaf('maker'))\n const date = store.any(message, ns.dct('created'))\n const latestVersion = mostRecentVersion(message)\n const content = store.any(latestVersion, ns.sioc('content'))\n\n const originalMessage = originalVersion(message)\n const edited = !message.sameTerm(originalMessage)\n\n const sortDate = store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) // In message\n\n const messageRow = dom.createElement('tr')\n messageRow.AJAR_date = sortDate.value\n messageRow.AJAR_subject = message\n\n const td1 = dom.createElement('td')\n messageRow.appendChild(td1)\n if (!options.authorDateOnLeft) {\n const img = dom.createElement('img')\n img.setAttribute(\n 'style',\n 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;'\n )\n widgets.setImage(img, creator)\n td1.appendChild(img)\n } else {\n creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message)\n }\n let bothDates = widgets.shortDate(sortDate.value)\n if (edited) {\n bothDates += ' ... ' + widgets.shortDate(date.value)\n }\n\n // Render the content ot the message itself\n const td2 = messageRow.appendChild(dom.createElement('td'))\n\n if (!options.authorDateOnLeft) {\n creatorAndDateHorizontal(\n td2,\n creator,\n bothDates, // widgets.shortDate(dateString)\n message\n )\n }\n const text = content.value.trim()\n const isURI = /^https?:\\/[^ <>]*$/i.test(text)\n let para = null\n if (isURI) {\n const isImage = /\\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text) // @@ Should use content-type not URI\n if (isImage && options.expandImagesInline) {\n const img = elementForImageURI(text, options)\n td2.appendChild(img)\n } else {\n // Link but not Image\n const anc = td2.appendChild(dom.createElement('a'))\n para = anc.appendChild(dom.createElement('p'))\n anc.href = text\n para.textContent = text\n td2.appendChild(anc)\n }\n } else {\n // text\n para = dom.createElement('p')\n td2.appendChild(para)\n para.textContent = text\n }\n if (para) {\n const bgcolor = colorizeByAuthor\n ? pad.lightColorHash(creator)\n : getBgColor(fresh)\n para.setAttribute(\n 'style',\n messageBodyStyle + 'background-color: ' + bgcolor + ';'\n )\n }\n\n function getBgColor (fresh) {\n return fresh ? '#e8ffe8' : 'white'\n }\n\n // Sentiment strip\n const strip = sentimentStripLinked(message, message.doc())\n if (strip.children.length) {\n td2.appendChild(dom.createElement('br'))\n td2.appendChild(strip)\n }\n\n // Message tool bar button\n const td3 = dom.createElement('td')\n messageRow.appendChild(td3)\n const toolsButton = widgets.button(\n dom,\n icons.iconBase + 'noun_243787.svg',\n '...'\n )\n td3.appendChild(toolsButton)\n toolsButton.addEventListener('click', function (_event) {\n if (messageRow.toolTR) {\n // already got a toolbar? Toogle\n messageRow.parentNode.removeChild(messageRow.toolTR)\n delete messageRow.toolTR\n return\n }\n const toolsTR = dom.createElement('tr')\n const tools = messageToolbar(message, messageRow, userContext, channelObject)\n tools.style =\n 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;' // @@ fix\n if (messageRow.nextSibling) {\n messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling)\n } else {\n messageRow.parentElement.appendChild(toolsTR)\n }\n messageRow.toolTR = toolsTR\n toolsTR.appendChild(dom.createElement('td')) // left\n const toolsTD = toolsTR.appendChild(dom.createElement('td'))\n toolsTR.appendChild(dom.createElement('td')) // right\n toolsTD.appendChild(tools)\n })\n return messageRow\n}\n\nexport function switchToEditor (messageRow, message, channelObject, userContext) {\n const messageTable = messageRow.parentNode\n const editRow = renderMessageEditor(channelObject, messageTable, userContext,\n channelObject.options, mostRecentVersion(message))\n messageTable.insertBefore(editRow, messageRow)\n editRow.originalRow = messageRow\n messageRow.style.visibility = 'hidden' // Hide the original message. unhide if user cancels edit\n}\n/* Control for a new message -- or editing an old message ***************\n *\n */\nexport function renderMessageEditor (channelObject, messageTable, userContext, options, originalMessage) {\n function revertEditing (messageEditor) {\n messageEditor.originalRow.style.visibility = 'visible' // restore read-only version\n messageEditor.parentNode.removeChild(messageEditor)\n }\n\n async function handleFieldInput (_event) {\n await sendMessage(field.value, true)\n }\n\n async function sendMessage (text, fromMainField) {\n function sendComplete (message, _text2) {\n // const dateStamp = store.any(message, ns.dct('created'), null, message.doc())\n // const content = $rdf.literal(text2)\n insertMessageIntoTable(channelObject, messageTable, message, false, options, userContext) // not green\n\n if (originalMessage) { // editing another message\n const oldRow = messageEditor.originalRow\n // oldRow.style.display = '' // restore read-only version, re-attack\n if (oldRow.parentNode) {\n oldRow.parentNode.removeChild(oldRow) // No longer needed old version\n } else {\n debug.warn('No parentNode on old message ' + oldRow.textContent)\n oldRow.style.backgroundColor = '#fee'\n oldRow.style.visibility = 'hidden' // @@ FIX THIS AND REMOVE FROM DOM INSTEAD\n }\n messageEditor.parentNode.removeChild(messageEditor) // no longer need editor\n } else {\n if (fromMainField) {\n field.value = '' // clear from out for reuse\n field.setAttribute('style', messageBodyStyle)\n field.disabled = false\n field.scrollIntoView(options.newestFirst) // allign bottom (top)\n field.focus() // Start typing next line immediately\n field.select()\n }\n }\n // await channelObject.div.refresh() // Add new day if nec @@ add back\n }\n\n // const me = authn.currentUser() // Must be logged on or wuld have got login button\n if (fromMainField) {\n field.setAttribute('style', messageBodyStyle + 'color: #bbb;') // pendingedit\n field.disabled = true\n }\n\n let message\n try {\n message = await channelObject.updateMessage(text, originalMessage)\n } catch (err) {\n const statusArea = userContext.statusArea || messageEditor\n statusArea.appendChild(\n widgets.errorMessageBlock(dom, 'Error writing message: ' + err)\n )\n return\n }\n sendComplete(message, text)\n } // sendMessage\n\n // DRAG AND DROP\n function droppedFileHandler (files) {\n const base = messageTable.chatDocument.dir().uri\n widgets.uploadFiles(\n store.fetcher,\n files,\n base + 'Files',\n base + 'Pictures',\n async function (theFile, destURI) {\n // @@@@@@ Wait for each if several\n await sendMessage(destURI)\n }\n )\n }\n\n // When a set of URIs are dropped on the field\n const droppedURIHandler = async function (uris) {\n for (const uri of uris) {\n await sendMessage(uri)\n }\n }\n\n // When we are actually logged on\n function turnOnInput () {\n function getImageDoc () {\n imageDoc = $rdf.sym(\n chatDocument.dir().uri + 'Image_' + Date.now() + '.png'\n )\n return imageDoc\n }\n\n async function tookPicture (imageDoc) {\n if (imageDoc) {\n await sendMessage(imageDoc.uri)\n }\n }\n\n // Body of turnOnInput\n\n let menuButton\n if (options.menuHandler) {\n const menuButton = widgets.button(\n dom, icons.iconBase + 'noun_243787.svg', 'More')\n menuButton.setAttribute('style', style.buttonStyle + 'float: right;')\n // menuButton.addEventListener('click', _event => sendMessage(), false) (done in turnoninput)\n rhs.appendChild(menuButton)\n }\n\n if (options.menuHandler && menuButton) {\n const me = authn.currentUser()\n const menuOptions = {\n me,\n dom,\n div: null, // @@ was: div\n newBase: messageTable.chatDocument.dir().uri\n }\n menuButton.addEventListener(\n 'click',\n event => {\n options.menuHandler(event, channelObject.chatChannel, menuOptions)\n },\n false\n )\n }\n\n const me = authn.currentUser() // If already logged on\n creatorAndDate(lhs, me, '', null)\n\n field = dom.createElement('textarea')\n middle.innerHTML = ''\n middle.appendChild(field)\n field.rows = 3\n if (originalMessage) {\n field.value = store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc())\n }\n // field.cols = 40\n field.setAttribute('style', messageBodyStyle + 'background-color: #eef;')\n\n // Trap the Enter BEFORE it is used ti make a newline\n\n field.addEventListener(\n 'keydown',\n async function (e) {\n // User preference?\n if (e.code === 'Enter') {\n // if (e.keyCode === 13) { // deprocated https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode\n if ((!e.shiftKey && !options.shiftEnterSendsMessage) || (e.shiftKey && options.shiftEnterSendsMessage)) {\n // Shift-Enter just adds a new line\n // (note alt-enter doesn't add newline anyway on my setup - so have to use shift.\n await handleFieldInput(e)\n }\n }\n },\n false\n )\n\n widgets.makeDropTarget(field, droppedURIHandler, droppedFileHandler)\n\n rhs.innerHTML = ''\n\n sendButton = widgets.button(dom, sendIcon, 'Send')\n sendButton.style.float = 'right'\n sendButton.addEventListener('click', _event => handleFieldInput(), false)\n rhs.appendChild(sendButton)\n\n if (originalMessage) { // Are we editing another message?\n const cancelButton = rhs.appendChild(widgets.cancelButton(dom))\n cancelButton.style.float = 'left'\n // cancelButton.firstChild.style.opacity = '0.3' // moved to buttons\n cancelButton.addEventListener('click', _event => revertEditing(messageEditor), false)\n rhs.appendChild(cancelButton)\n }\n\n const chatDocument = channelObject.dateFolder.leafDocumentFromDate(new Date())\n let imageDoc\n\n middle.appendChild(\n media.cameraButton(dom, store, getImageDoc, tookPicture)\n )\n\n pad.recordParticipation(channelObject.channel, channelObject.channel.doc()) // participation =\n } // turn on inpuut\n\n // Body of renderMessageEditor\n\n let sortDate, sendIcon\n if (originalMessage) {\n sortDate = store.anyValue(originalMessage, ns.dct('created'), null, originalMessage.doc())\n // text = store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc())\n sendIcon = icons.iconBase + 'noun_1180158.svg' // Green check\n // cancelIcon = icons.iconBase + 'noun_1180156.svg' // Black cross\n } else {\n sendIcon = icons.iconBase + 'noun_383448.svg'\n sortDate = '9999-01-01T00:00:00Z' // ISO format for field sort\n // text = ''\n }\n const messageEditor = dom.createElement('tr')\n const lhs = dom.createElement('td')\n const middle = dom.createElement('td')\n const rhs = dom.createElement('td')\n messageEditor.appendChild(lhs)\n messageEditor.appendChild(middle)\n messageEditor.appendChild(rhs)\n messageEditor.AJAR_date = sortDate\n // messageEditor.appendChild(dom.createElement('br'))\n\n let field, sendButton\n const context = { div: middle, dom: dom }\n\n authn.logIn(context).then(context => {\n // me = context.me\n turnOnInput()\n Object.assign(context, userContext)\n findBookmarkDocument(context).then(_context => {\n // console.log('Bookmark file: ' + context.bookmarkDocument)\n })\n })\n\n return messageEditor\n} // renderMessageEditor\n"],"file":"message.js"}
|
package/lib/chat/messageTools.js
CHANGED
|
@@ -17,28 +17,28 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
17
17
|
|
|
18
18
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
19
|
|
|
20
|
+
var debug = _interopRequireWildcard(require("../debug"));
|
|
21
|
+
|
|
20
22
|
var _index = require("../authn/index");
|
|
21
23
|
|
|
22
24
|
var _iconBase = require("../iconBase");
|
|
23
25
|
|
|
24
26
|
var _logic = require("../logic");
|
|
25
27
|
|
|
26
|
-
var _index2 = require("../media/index");
|
|
27
|
-
|
|
28
28
|
var ns = _interopRequireWildcard(require("../ns"));
|
|
29
29
|
|
|
30
|
-
var pad = _interopRequireWildcard(require("../pad"));
|
|
31
|
-
|
|
32
30
|
var rdf = _interopRequireWildcard(require("rdflib"));
|
|
33
31
|
|
|
34
|
-
var style = _interopRequireWildcard(require("../style"));
|
|
35
|
-
|
|
36
32
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
37
33
|
|
|
38
34
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
39
35
|
|
|
40
36
|
var _bookmarks = require("./bookmarks");
|
|
41
37
|
|
|
38
|
+
var _chatLogic = require("./chatLogic");
|
|
39
|
+
|
|
40
|
+
var _message = require("./message");
|
|
41
|
+
|
|
42
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
43
|
|
|
44
44
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -52,52 +52,29 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
52
52
|
* If you made it originally: edit, delete, attach
|
|
53
53
|
* @packageDocumentation
|
|
54
54
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
// import { media } from '../media/index'
|
|
56
|
+
// import * as pad from '../pad'
|
|
57
57
|
// pull in first avoid cross-refs
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
pad: pad,
|
|
64
|
-
rdf: rdf,
|
|
65
|
-
store: _logic.store,
|
|
66
|
-
style: style,
|
|
67
|
-
utils: utils,
|
|
68
|
-
widgets: widgets
|
|
69
|
-
};
|
|
70
|
-
var dom = window.document;
|
|
71
|
-
var kb = _logic.store; // const label = UI.utils.label
|
|
72
|
-
// THE UNUSED ICONS are here as reminders for possible future functionality
|
|
58
|
+
// import * as style from '../style'
|
|
59
|
+
// import { infiniteMessageArea } from './infinite.js'
|
|
60
|
+
// import { renderMessage, creatorAndDate } from './message'
|
|
61
|
+
// import * as debug from '../debug'
|
|
62
|
+
var dom = window.document; // THE UNUSED ICONS are here as reminders for possible future functionality
|
|
73
63
|
// const BOOKMARK_ICON = 'noun_45961.svg'
|
|
74
64
|
// const HEART_ICON = 'noun_130259.svg' -> Add this to my (private) favorites
|
|
75
65
|
// const MENU_ICON = 'noun_897914.svg'
|
|
76
66
|
// const PAPERCLIP_ICON = 'noun_25830.svg' -> add attachments to this message
|
|
77
67
|
// const PIN_ICON = 'noun_562340.svg' -> pin this message permanently in the chat UI
|
|
78
|
-
|
|
68
|
+
|
|
69
|
+
var PENCIL_ICON = 'noun_253504.svg'; // edit a message
|
|
79
70
|
// const SPANNER_ICON = 'noun_344563.svg' -> settings
|
|
80
71
|
|
|
81
72
|
var THUMBS_UP_ICON = 'noun_1384132.svg';
|
|
82
|
-
var THUMBS_DOWN_ICON = 'noun_1384135.svg';
|
|
83
|
-
// @@@@ use the one in rdflib.js when it is avaiable and delete this
|
|
84
|
-
|
|
85
|
-
function updatePromise(del, ins) {
|
|
86
|
-
return new Promise(function (resolve, reject) {
|
|
87
|
-
kb.updater.update(del, ins, function (uri, ok, errorBody) {
|
|
88
|
-
if (!ok) {
|
|
89
|
-
reject(new Error(errorBody));
|
|
90
|
-
} else {
|
|
91
|
-
resolve();
|
|
92
|
-
}
|
|
93
|
-
}); // callback
|
|
94
|
-
}); // promise
|
|
95
|
-
}
|
|
73
|
+
var THUMBS_DOWN_ICON = 'noun_1384135.svg';
|
|
96
74
|
/**
|
|
97
75
|
* Emoji in Unicode
|
|
98
76
|
*/
|
|
99
77
|
|
|
100
|
-
|
|
101
78
|
var emoji = {};
|
|
102
79
|
emoji[ns.schema('AgreeAction')] = '👍';
|
|
103
80
|
emoji[ns.schema('DisagreeAction')] = '👎';
|
|
@@ -108,9 +85,11 @@ emoji[ns.schema('LikeAction')] = '❤️';
|
|
|
108
85
|
*/
|
|
109
86
|
|
|
110
87
|
function sentimentStrip(target, doc) {
|
|
111
|
-
|
|
88
|
+
// alain seems not used
|
|
89
|
+
var latest = (0, _chatLogic.mostRecentVersion)(target);
|
|
90
|
+
var actions = _logic.store.holds(latest, ns.schema('dateDeleted').value, null, latest.doc()) ? _logic.store.each(null, ns.schema('target'), target, doc) : [];
|
|
112
91
|
var sentiments = actions.map(function (a) {
|
|
113
|
-
return
|
|
92
|
+
return _logic.store.any(a, ns.rdf('type'), null, doc);
|
|
114
93
|
});
|
|
115
94
|
sentiments.sort();
|
|
116
95
|
var strings = sentiments.map(function (x) {
|
|
@@ -131,9 +110,9 @@ function sentimentStripLinked(target, doc) {
|
|
|
131
110
|
|
|
132
111
|
function refresh() {
|
|
133
112
|
strip.innerHTML = '';
|
|
134
|
-
var actions =
|
|
113
|
+
var actions = (0, _chatLogic.mostRecentVersion)(target).uri !== ns.schema('dateDeleted').uri ? _logic.store.each(null, ns.schema('target'), target, doc) : [];
|
|
135
114
|
var sentiments = actions.map(function (a) {
|
|
136
|
-
return [
|
|
115
|
+
return [_logic.store.any(a, ns.rdf('type'), null, doc), _logic.store.any(a, ns.schema('agent'), null, doc)];
|
|
137
116
|
});
|
|
138
117
|
sentiments.sort();
|
|
139
118
|
sentiments.forEach(function (ss) {
|
|
@@ -164,60 +143,142 @@ function sentimentStripLinked(target, doc) {
|
|
|
164
143
|
*/
|
|
165
144
|
|
|
166
145
|
|
|
167
|
-
function messageToolbar(message, messageRow, userContext) {
|
|
168
|
-
|
|
146
|
+
function messageToolbar(message, messageRow, userContext, channelObject) {
|
|
147
|
+
function deleteMessage() {
|
|
148
|
+
return _deleteMessage.apply(this, arguments);
|
|
149
|
+
}
|
|
169
150
|
|
|
170
|
-
function
|
|
171
|
-
|
|
151
|
+
function _deleteMessage() {
|
|
152
|
+
_deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
153
|
+
var author, msg, area;
|
|
154
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
155
|
+
while (1) {
|
|
156
|
+
switch (_context2.prev = _context2.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
author = _logic.store.any(message, ns.foaf('maker'));
|
|
159
|
+
|
|
160
|
+
if (me) {
|
|
161
|
+
_context2.next = 5;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
alert('You can\'t delete the message, you are not logged in.');
|
|
166
|
+
_context2.next = 22;
|
|
167
|
+
break;
|
|
168
|
+
|
|
169
|
+
case 5:
|
|
170
|
+
if (!me.sameTerm(author)) {
|
|
171
|
+
_context2.next = 21;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
_context2.prev = 6;
|
|
176
|
+
_context2.next = 9;
|
|
177
|
+
return channelObject.deleteMessage(message);
|
|
178
|
+
|
|
179
|
+
case 9:
|
|
180
|
+
_context2.next = 18;
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case 11:
|
|
184
|
+
_context2.prev = 11;
|
|
185
|
+
_context2.t0 = _context2["catch"](6);
|
|
186
|
+
msg = 'Error deleting messaage ' + _context2.t0;
|
|
187
|
+
debug.warn(msg);
|
|
188
|
+
alert(msg);
|
|
189
|
+
area = userContext.statusArea || messageRow.parentNode;
|
|
190
|
+
area.appendChild(widgets.errorMessageBlock(dom, msg));
|
|
191
|
+
|
|
192
|
+
case 18:
|
|
193
|
+
messageRow.parentNode.removeChild(messageRow);
|
|
194
|
+
_context2.next = 22;
|
|
195
|
+
break;
|
|
196
|
+
|
|
197
|
+
case 21:
|
|
198
|
+
alert('You can\'t delete the message, you are not logged in as the author, ' + author);
|
|
199
|
+
|
|
200
|
+
case 22:
|
|
201
|
+
closeToolbar();
|
|
202
|
+
|
|
203
|
+
case 23:
|
|
204
|
+
case "end":
|
|
205
|
+
return _context2.stop();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}, _callee2, null, [[6, 11]]);
|
|
209
|
+
}));
|
|
210
|
+
return _deleteMessage.apply(this, arguments);
|
|
172
211
|
}
|
|
173
212
|
|
|
174
|
-
function
|
|
175
|
-
return
|
|
176
|
-
} //
|
|
213
|
+
function editMessage(_x) {
|
|
214
|
+
return _editMessage.apply(this, arguments);
|
|
215
|
+
} // alain TODO allow chat owner to fully delete message + sentiments and replacing messages
|
|
177
216
|
|
|
178
217
|
|
|
179
|
-
function
|
|
180
|
-
|
|
218
|
+
function _editMessage() {
|
|
219
|
+
_editMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(messageRow) {
|
|
181
220
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
182
221
|
while (1) {
|
|
183
222
|
switch (_context3.prev = _context3.next) {
|
|
184
223
|
case 0:
|
|
185
|
-
|
|
186
|
-
|
|
224
|
+
if (me.value === _logic.store.any(message, ns.foaf('maker')).value) {
|
|
225
|
+
closeToolbar(); // edit is a one-off action
|
|
187
226
|
|
|
188
|
-
|
|
227
|
+
(0, _message.switchToEditor)(messageRow, message, channelObject, userContext);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
case 1:
|
|
189
231
|
case "end":
|
|
190
232
|
return _context3.stop();
|
|
191
233
|
}
|
|
192
234
|
}
|
|
193
235
|
}, _callee3);
|
|
194
236
|
}));
|
|
195
|
-
return
|
|
237
|
+
return _editMessage.apply(this, arguments);
|
|
196
238
|
}
|
|
197
239
|
|
|
198
|
-
var
|
|
240
|
+
var div = dom.createElement('div'); // is message deleted ?
|
|
199
241
|
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
242
|
+
if ((0, _chatLogic.mostRecentVersion)(message).value === ns.schema('dateDeleted').value) return div;
|
|
243
|
+
|
|
244
|
+
function closeToolbar() {
|
|
245
|
+
div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function deleteThingThen(_x2) {
|
|
249
|
+
return _deleteThingThen.apply(this, arguments);
|
|
250
|
+
} // Things only the original author can do
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
function _deleteThingThen() {
|
|
254
|
+
_deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(x) {
|
|
255
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
204
256
|
while (1) {
|
|
205
|
-
switch (
|
|
257
|
+
switch (_context4.prev = _context4.next) {
|
|
206
258
|
case 0:
|
|
207
|
-
|
|
208
|
-
return
|
|
259
|
+
_context4.next = 2;
|
|
260
|
+
return _logic.store.updater.update(_logic.store.connectedStatements(x), []);
|
|
209
261
|
|
|
210
262
|
case 2:
|
|
211
|
-
closeToolbar();
|
|
212
|
-
|
|
213
|
-
case 3:
|
|
214
263
|
case "end":
|
|
215
|
-
return
|
|
264
|
+
return _context4.stop();
|
|
216
265
|
}
|
|
217
266
|
}
|
|
218
|
-
},
|
|
219
|
-
}))
|
|
220
|
-
|
|
267
|
+
}, _callee4);
|
|
268
|
+
}));
|
|
269
|
+
return _deleteThingThen.apply(this, arguments);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
var me = _index.authn.currentUser(); // If already logged on
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
if (me && _logic.store.holds(message, ns.foaf('maker'), me)) {
|
|
276
|
+
// button to delete the message
|
|
277
|
+
div.appendChild(widgets.deleteButtonWithCheck(dom, div, 'message', deleteMessage)); // button to edit the message
|
|
278
|
+
|
|
279
|
+
div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + PENCIL_ICON, 'edit', function () {
|
|
280
|
+
return editMessage(messageRow);
|
|
281
|
+
}));
|
|
221
282
|
} // if mine
|
|
222
283
|
// Things anyone can do if they have a bookmark list async
|
|
223
284
|
|
|
@@ -248,39 +309,39 @@ function messageToolbar(message, messageRow, userContext) {
|
|
|
248
309
|
button.style.backgroundColor = action ? 'yellow' : 'white';
|
|
249
310
|
}
|
|
250
311
|
|
|
251
|
-
var button =
|
|
252
|
-
var
|
|
312
|
+
var button = widgets.button(dom, icon, utils.label(actionClass), /*#__PURE__*/function () {
|
|
313
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_event) {
|
|
253
314
|
var insertMe, dirty, i, a;
|
|
254
|
-
return _regenerator["default"].wrap(function
|
|
315
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
255
316
|
while (1) {
|
|
256
|
-
switch (
|
|
317
|
+
switch (_context.prev = _context.next) {
|
|
257
318
|
case 0:
|
|
258
319
|
if (!action) {
|
|
259
|
-
|
|
320
|
+
_context.next = 7;
|
|
260
321
|
break;
|
|
261
322
|
}
|
|
262
323
|
|
|
263
|
-
|
|
324
|
+
_context.next = 3;
|
|
264
325
|
return deleteThingThen(action);
|
|
265
326
|
|
|
266
327
|
case 3:
|
|
267
328
|
action = null;
|
|
268
329
|
setColor();
|
|
269
|
-
|
|
330
|
+
_context.next = 25;
|
|
270
331
|
break;
|
|
271
332
|
|
|
272
333
|
case 7:
|
|
273
334
|
// no action
|
|
274
|
-
action =
|
|
275
|
-
insertMe = [
|
|
276
|
-
|
|
277
|
-
return
|
|
335
|
+
action = widgets.newThing(doc);
|
|
336
|
+
insertMe = [rdf.st(action, ns.schema('agent'), context.me, doc), rdf.st(action, ns.rdf('type'), actionClass, doc), rdf.st(action, ns.schema('target'), target, doc)];
|
|
337
|
+
_context.next = 11;
|
|
338
|
+
return _logic.store.updater.update([], insertMe);
|
|
278
339
|
|
|
279
340
|
case 11:
|
|
280
341
|
setColor();
|
|
281
342
|
|
|
282
343
|
if (!mutuallyExclusive) {
|
|
283
|
-
|
|
344
|
+
_context.next = 25;
|
|
284
345
|
break;
|
|
285
346
|
}
|
|
286
347
|
|
|
@@ -290,18 +351,18 @@ function messageToolbar(message, messageRow, userContext) {
|
|
|
290
351
|
|
|
291
352
|
case 15:
|
|
292
353
|
if (!(i < mutuallyExclusive.length)) {
|
|
293
|
-
|
|
354
|
+
_context.next = 24;
|
|
294
355
|
break;
|
|
295
356
|
}
|
|
296
357
|
|
|
297
358
|
a = existingAction(mutuallyExclusive[i]);
|
|
298
359
|
|
|
299
360
|
if (!a) {
|
|
300
|
-
|
|
361
|
+
_context.next = 21;
|
|
301
362
|
break;
|
|
302
363
|
}
|
|
303
364
|
|
|
304
|
-
|
|
365
|
+
_context.next = 20;
|
|
305
366
|
return deleteThingThen(a);
|
|
306
367
|
|
|
307
368
|
case 20:
|
|
@@ -310,34 +371,35 @@ function messageToolbar(message, messageRow, userContext) {
|
|
|
310
371
|
|
|
311
372
|
case 21:
|
|
312
373
|
i++;
|
|
313
|
-
|
|
374
|
+
_context.next = 15;
|
|
314
375
|
break;
|
|
315
376
|
|
|
316
377
|
case 24:
|
|
317
378
|
if (dirty) {
|
|
318
|
-
//
|
|
319
|
-
|
|
379
|
+
// widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
|
|
380
|
+
widgets.refreshTree(messageRow); // requires them all to be immediate siblings
|
|
320
381
|
}
|
|
321
382
|
|
|
322
383
|
case 25:
|
|
323
384
|
case "end":
|
|
324
|
-
return
|
|
385
|
+
return _context.stop();
|
|
325
386
|
}
|
|
326
387
|
}
|
|
327
|
-
},
|
|
388
|
+
}, _callee);
|
|
328
389
|
}));
|
|
329
390
|
|
|
330
|
-
return function (
|
|
331
|
-
return
|
|
391
|
+
return function (_x3) {
|
|
392
|
+
return _ref.apply(this, arguments);
|
|
332
393
|
};
|
|
333
394
|
}());
|
|
334
395
|
|
|
335
396
|
function existingAction(actionClass) {
|
|
336
|
-
var actions =
|
|
337
|
-
return
|
|
397
|
+
var actions = _logic.store.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
|
|
398
|
+
return _logic.store.holds(x, ns.rdf('type'), actionClass, doc);
|
|
338
399
|
}).filter(function (x) {
|
|
339
|
-
return
|
|
400
|
+
return _logic.store.holds(x, ns.schema('target'), target, doc);
|
|
340
401
|
});
|
|
402
|
+
|
|
341
403
|
return actions.length ? actions[0] : null;
|
|
342
404
|
}
|
|
343
405
|
|
|
@@ -355,23 +417,23 @@ function messageToolbar(message, messageRow, userContext) {
|
|
|
355
417
|
// https://schema.org/AgreeAction
|
|
356
418
|
|
|
357
419
|
|
|
358
|
-
me =
|
|
420
|
+
me = _index.authn.currentUser(); // If already logged on
|
|
421
|
+
// debug.log('Actions 3' + mostRecentVersion(message).value + ' ' + ns.schema('dateDeleted').value + ' ' + (mostRecentVersion(message).value !== ns.schema('dateDeleted').value))
|
|
359
422
|
|
|
360
|
-
if (me) {
|
|
361
|
-
// Things you mnust be logged in for
|
|
423
|
+
if (me && (0, _chatLogic.mostRecentVersion)(message).value !== ns.schema('dateDeleted').value) {
|
|
362
424
|
var context1 = {
|
|
363
425
|
me: me,
|
|
364
426
|
dom: dom,
|
|
365
427
|
div: div
|
|
366
428
|
};
|
|
367
|
-
div.appendChild(sentimentButton(context1, message, // @@ TODO use
|
|
368
|
-
|
|
429
|
+
div.appendChild(sentimentButton(context1, message, // @@ TODO use widgets.sentimentButton
|
|
430
|
+
_iconBase.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')])); // Thumbs down
|
|
369
431
|
|
|
370
|
-
div.appendChild(sentimentButton(context1, message,
|
|
432
|
+
div.appendChild(sentimentButton(context1, message, _iconBase.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
|
|
371
433
|
} // X button to remove the tool UI itself
|
|
372
434
|
|
|
373
435
|
|
|
374
|
-
var cancelButton = div.appendChild(
|
|
436
|
+
var cancelButton = div.appendChild(widgets.cancelButton(dom));
|
|
375
437
|
cancelButton.style["float"] = 'right';
|
|
376
438
|
cancelButton.firstChild.style.opacity = '0.3';
|
|
377
439
|
cancelButton.addEventListener('click', closeToolbar);
|