fix: issue 34 and bugs from last commit

This commit is contained in:
monica 2022-08-11 15:43:21 -05:00
parent 6fcddc76c5
commit acecce96b8
6 changed files with 8993 additions and 8648 deletions

7512
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@
"vue-i18n": "^9.2.0-beta.40", "vue-i18n": "^9.2.0-beta.40",
"vue-router": "^4.0.0", "vue-router": "^4.0.0",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"vuex": "^4.0.1" "vuex": "^4.0.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/eslint-parser": "^7.13.14", "@babel/eslint-parser": "^7.13.14",

View File

@ -97,7 +97,7 @@ module.exports = configure(function (ctx) {
type: 'http', type: 'http',
}, },
port: 8080, port: 8080,
open: true, // opens browser window automatically open: false, // opens browser window automatically
// proxy: { // proxy: {
// '/api': { // '/api': {
// target: 'https://astral.ninja', // target: 'https://astral.ninja',

View File

@ -229,9 +229,9 @@
> >
<!-- <q-item-label v-if='!replyMode'>relay&nbsp;</q-item-label> --> <!-- <q-item-label v-if='!replyMode'>relay&nbsp;</q-item-label> -->
<q-icon name="send" :style='"transform: translateX(" + sendIconTranslation + "px);"'/> <q-icon name="send" :style='"transform: translateX(" + sendIconTranslation + "px);"'/>
<q-tooltip> <!-- <q-tooltip>
send send
</q-tooltip> </q-tooltip> -->
</q-btn> </q-btn>
</q-btn-group> </q-btn-group>
</div> </div>
@ -359,13 +359,15 @@ export default {
}, },
textValid() { textValid() {
if (this.replyMode === 'repost') return true if (this.replyMode === 'repost') return true
if (this.links.length) return true
if (!this.text.length) return false if (!this.text.length) return false
if (this.messageMode) return true if (this.messageMode) return true
if (this.overCharLimit) return false if (this.overCharLimit) return false
return true return true
}, },
inputWidth() { postEntryWidth() {
return this.$refs.input?.$el?.clientWidth // return this.$refs.input?.$el?.clientWidth
return this.$refs.postEntry?.$el?.clientWidth
}, },
toolboxWidth() { toolboxWidth() {
if (this.toolSelected) return this.$refs.toolbox?.$el?.clientWidth if (this.toolSelected) return this.$refs.toolbox?.$el?.clientWidth
@ -403,7 +405,6 @@ export default {
let matches = this.text.matchAll(hashtagRegex) let matches = this.text.matchAll(hashtagRegex)
let hashtags = [] let hashtags = []
for (let match of matches) { for (let match of matches) {
console.log('match', match)
hashtags.push(match.groups.i.toLowerCase()) hashtags.push(match.groups.i.toLowerCase())
} }
return hashtags return hashtags
@ -437,7 +438,8 @@ export default {
methods: { methods: {
updateText(e) { updateText(e) {
this.text = e.target.textContent if (e) this.text = e.target.textContent
else this.text = this.textarea.textContent
this.updateReadonlyInput() this.updateReadonlyInput()
this.updateReadonlyHightlightInput() this.updateReadonlyHightlightInput()
}, },
@ -487,12 +489,11 @@ export default {
async sendReply() { async sendReply() {
// build tags // build tags
// let tags = [] // let tags = []
if (this.replyMode === 'repost' && this.text) this.text = '' if (this.replyMode === 'repost' && this.text) this.textarea.innerHTML = ''
// save copy of mentions and remove for now // save copy of mentions and remove for now
// let mentions = Object.assign({}, this.mentions()) // let mentions = Object.assign({}, this.mentions())
let tags = [] let tags = []
let text = this.text
let textarea = this.textarea.cloneNode(true) let textarea = this.textarea.cloneNode(true)
// remove invalid tags and/or not p/e // remove invalid tags and/or not p/e
@ -518,7 +519,7 @@ export default {
// if quote or repost, only tag this event and add mention to text // if quote or repost, only tag this event and add mention to text
let last = getEventTagWithRelay(this.event) let last = getEventTagWithRelay(this.event)
tags.push(last) tags.push(last)
text += ` #[${tags.length - 1}]` // text += ` #[${tags.length - 1}]`
textarea.append(` #[${tags.length - 1}]`) textarea.append(` #[${tags.length - 1}]`)
} else { } else {
// add the first and the last events being replied to // add the first and the last events being replied to
@ -528,7 +529,8 @@ export default {
tags.push(last) tags.push(last)
} }
text = this.formatMentionsForPublishing(tags, textarea) // let text = this.textarea.innerText
let text = this.formatMentionsForPublishing(tags, textarea)
this.appendHashtags(tags) this.appendHashtags(tags)
text = this.appendLinks(text) text = this.appendLinks(text)
return await this.$store.dispatch('sendPost', { return await this.$store.dispatch('sendPost', {
@ -667,7 +669,8 @@ export default {
// this.text = await this.extractMentions(this.text, this.tags) // this.text = await this.extractMentions(this.text, this.tags)
await this.extractMentions(this.textarea, this.tags) await this.extractMentions(this.textarea, this.tags)
// this.textarea.innerHTML = this.text // this.textarea.innerHTML = this.text
this.text = this.textarea.innerHTML // this.text = this.textarea.innerHTML
this.updateText()
if (start.el.nodeName === '#text' && start.pos > start.el.length) if (start.el.nodeName === '#text' && start.pos > start.el.length)
this.setCaret(start.el, start.el.length) this.setCaret(start.el, start.el.length)
else this.setCaret(start.el, start.pos) else this.setCaret(start.el, start.pos)
@ -707,6 +710,7 @@ export default {
start.el.insertBefore(textNode, start.el.firstChild) start.el.insertBefore(textNode, start.el.firstChild)
this.setCaret(textNode, insertedText.length) this.setCaret(textNode, insertedText.length)
} }
this.updateText()
this.updateReadonlyInput() this.updateReadonlyInput()
this.updateReadonlyHightlightInput() this.updateReadonlyHightlightInput()
}, },
@ -724,7 +728,7 @@ export default {
return return
} }
this.sendIconTranslation += 3 this.sendIconTranslation += 3
if (this.sendIconTranslation > 50) this.sendIconTranslation -= (this.inputWidth + 40) if (this.sendIconTranslation > 50) this.sendIconTranslation -= (this.postEntryWidth + 40)
}, 50) }, 50)
}, },
@ -740,6 +744,7 @@ export default {
reset() { reset() {
this.closeTools() this.closeTools()
this.text = '' this.text = ''
this.textarea.innerHTML = ''
this.tags = [] this.tags = []
this.links = [] this.links = []
this.focusInput() this.focusInput()
@ -754,7 +759,7 @@ export default {
}, },
appendLinks(text) { appendLinks(text) {
for (let link in this.links) { for (let link of this.links) {
if (link.name) text = text + `\n[${link.name}](${link.url})` if (link.name) text = text + `\n[${link.name}](${link.url})`
else text = text + `\n${link.url}` else text = text + `\n${link.url}`
} }
@ -845,7 +850,6 @@ export default {
child.innerHTML = span.outerHTML child.innerHTML = span.outerHTML
return child.outerHTML return child.outerHTML
}).join('') }).join('')
console.log('contents', highlightFragment.childNodes, htmlContent)
let span = document.createElement('span') let span = document.createElement('span')
span.innerHTML = htmlContent span.innerHTML = htmlContent
@ -861,10 +865,8 @@ export default {
charPos(char, el = this.textarea) { charPos(char, el = this.textarea) {
// Loop through all child nodes // Loop through all child nodes
for (var node of el.childNodes) { for (var node of el.childNodes) {
console.log('node', node, 'char', char)
if (node.nodeType === 3) { // we have a text node if (node.nodeType === 3) { // we have a text node
if (node.length >= char) { if (node.length >= char) {
console.log('return', { el: node, pos: char, char: -1 })
return { el: node, pos: char, char: -1 } return { el: node, pos: char, char: -1 }
} else { } else {
char -= node.length char -= node.length
@ -899,7 +901,6 @@ export default {
text = text.replace( text = text.replace(
urlRegex, urlRegex,
(url) => { (url) => {
console.log('match values', url)
this.addLink({ url }) this.addLink({ url })
return '' return ''
} }

View File

@ -1,6 +1,6 @@
<template> <template>
<q-item <q-item
clickable :clickable='clickable'
unelevated unelevated
outlined outlined
class='no-padding flex row justify-start items-center cursor-pointer' class='no-padding flex row justify-start items-center cursor-pointer'
@ -67,6 +67,11 @@ export default defineComponent({
required: false, required: false,
default: false default: false
}, },
clickable: {
type: Boolean,
required: false,
default: true
},
// largeMode: { // largeMode: {
// type: String, // type: String,
// required: false, // required: false,

10081
yarn.lock

File diff suppressed because it is too large Load Diff