wip
This commit is contained in:
parent
0bf4c5cb29
commit
a02bd7061a
|
@ -1,4 +1,4 @@
|
||||||
import Vue from 'vue';
|
import { App } from 'vue';
|
||||||
|
|
||||||
import mfm from './misskey-flavored-markdown.vue';
|
import mfm from './misskey-flavored-markdown.vue';
|
||||||
import acct from './acct.vue';
|
import acct from './acct.vue';
|
||||||
|
@ -12,14 +12,16 @@ import loading from './loading.vue';
|
||||||
import error from './error.vue';
|
import error from './error.vue';
|
||||||
import streamIndicator from './stream-indicator.vue';
|
import streamIndicator from './stream-indicator.vue';
|
||||||
|
|
||||||
Vue.component('mfm', mfm);
|
export default function(app: App) {
|
||||||
Vue.component('mk-acct', acct);
|
app.component('mfm', mfm);
|
||||||
Vue.component('mk-avatar', avatar);
|
app.component('mk-acct', acct);
|
||||||
Vue.component('mk-emoji', emoji);
|
app.component('mk-avatar', avatar);
|
||||||
Vue.component('mk-user-name', userName);
|
app.component('mk-emoji', emoji);
|
||||||
Vue.component('mk-ellipsis', ellipsis);
|
app.component('mk-user-name', userName);
|
||||||
Vue.component('mk-time', time);
|
app.component('mk-ellipsis', ellipsis);
|
||||||
Vue.component('mk-url', url);
|
app.component('mk-time', time);
|
||||||
Vue.component('mk-loading', loading);
|
app.component('mk-url', url);
|
||||||
Vue.component('mk-error', error);
|
app.component('mk-loading', loading);
|
||||||
Vue.component('stream-indicator', streamIndicator);
|
app.component('mk-error', error);
|
||||||
|
app.component('stream-indicator', streamIndicator);
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Vue, { VNode } from 'vue';
|
import { VNode, defineComponent, h } from 'vue';
|
||||||
import { MfmForest } from '../../mfm/prelude';
|
import { MfmForest } from '../../mfm/prelude';
|
||||||
import { parse, parsePlain } from '../../mfm/parse';
|
import { parse, parsePlain } from '../../mfm/parse';
|
||||||
import MkUrl from './url.vue';
|
import MkUrl from './url.vue';
|
||||||
|
@ -10,7 +10,7 @@ import MkCode from './code.vue';
|
||||||
import MkGoogle from './google.vue';
|
import MkGoogle from './google.vue';
|
||||||
import { host } from '../config';
|
import { host } from '../config';
|
||||||
|
|
||||||
export default Vue.component('misskey-flavored-markdown', {
|
export default defineComponent({
|
||||||
props: {
|
props: {
|
||||||
text: {
|
text: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -41,7 +41,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
render(createElement) {
|
render() {
|
||||||
if (this.text == null || this.text == '') return;
|
if (this.text == null || this.text == '') return;
|
||||||
|
|
||||||
const ast = (this.plain ? parsePlain : parse)(this.text);
|
const ast = (this.plain ? parsePlain : parse)(this.text);
|
||||||
|
@ -53,7 +53,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
|
|
||||||
if (!this.plain) {
|
if (!this.plain) {
|
||||||
const x = text.split('\n')
|
const x = text.split('\n')
|
||||||
.map(t => t == '' ? [createElement('br')] : [this._v(t), createElement('br')]); // NOTE: this._vはHACK SEE: https://github.com/syuilo/misskey/pull/6399#issuecomment-632820283
|
.map(t => t == '' ? [h('br')] : [this._v(t), h('br')]); // NOTE: this._vはHACK SEE: https://github.com/syuilo/misskey/pull/6399#issuecomment-632820283
|
||||||
x[x.length - 1].pop();
|
x[x.length - 1].pop();
|
||||||
return x;
|
return x;
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,15 +62,15 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'bold': {
|
case 'bold': {
|
||||||
return [createElement('b', genEl(token.children))];
|
return [h('b', genEl(token.children))];
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'strike': {
|
case 'strike': {
|
||||||
return [createElement('del', genEl(token.children))];
|
return [h('del', genEl(token.children))];
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'italic': {
|
case 'italic': {
|
||||||
return (createElement as any)('i', {
|
return h('i', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: 'font-style: oblique;'
|
style: 'font-style: oblique;'
|
||||||
},
|
},
|
||||||
|
@ -78,7 +78,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'big': {
|
case 'big': {
|
||||||
return (createElement as any)('strong', {
|
return h('strong', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: `display: inline-block; font-size: 150%;`
|
style: `display: inline-block; font-size: 150%;`
|
||||||
},
|
},
|
||||||
|
@ -90,7 +90,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'small': {
|
case 'small': {
|
||||||
return [createElement('small', {
|
return [h('small', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: 'opacity: 0.7;'
|
style: 'opacity: 0.7;'
|
||||||
},
|
},
|
||||||
|
@ -98,7 +98,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'center': {
|
case 'center': {
|
||||||
return [createElement('div', {
|
return [h('div', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: 'text-align:center;'
|
style: 'text-align:center;'
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'motion': {
|
case 'motion': {
|
||||||
return (createElement as any)('span', {
|
return h('span', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: 'display: inline-block;'
|
style: 'display: inline-block;'
|
||||||
},
|
},
|
||||||
|
@ -124,7 +124,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
'normal';
|
'normal';
|
||||||
const style = this.$store.state.device.animatedMfm
|
const style = this.$store.state.device.animatedMfm
|
||||||
? `animation: spin 1.5s linear infinite; animation-direction: ${direction};` : '';
|
? `animation: spin 1.5s linear infinite; animation-direction: ${direction};` : '';
|
||||||
return (createElement as any)('span', {
|
return h('span', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: 'display: inline-block;' + style
|
style: 'display: inline-block;' + style
|
||||||
},
|
},
|
||||||
|
@ -132,7 +132,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'jump': {
|
case 'jump': {
|
||||||
return (createElement as any)('span', {
|
return h('span', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: this.$store.state.device.animatedMfm ? 'display: inline-block; animation: jump 0.75s linear infinite;' : 'display: inline-block;'
|
style: this.$store.state.device.animatedMfm ? 'display: inline-block; animation: jump 0.75s linear infinite;' : 'display: inline-block;'
|
||||||
},
|
},
|
||||||
|
@ -140,7 +140,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'flip': {
|
case 'flip': {
|
||||||
return (createElement as any)('span', {
|
return h('span', {
|
||||||
attrs: {
|
attrs: {
|
||||||
style: 'display: inline-block; transform: scaleX(-1);'
|
style: 'display: inline-block; transform: scaleX(-1);'
|
||||||
},
|
},
|
||||||
|
@ -148,7 +148,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'url': {
|
case 'url': {
|
||||||
return [createElement(MkUrl, {
|
return [h(MkUrl, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
url: token.node.props.url,
|
url: token.node.props.url,
|
||||||
|
@ -158,7 +158,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'link': {
|
case 'link': {
|
||||||
return [createElement(MkLink, {
|
return [h(MkLink, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
url: token.node.props.url,
|
url: token.node.props.url,
|
||||||
|
@ -168,7 +168,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'mention': {
|
case 'mention': {
|
||||||
return [createElement(MkMention, {
|
return [h(MkMention, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
host: (token.node.props.host == null && this.author && this.author.host != null ? this.author.host : token.node.props.host) || host,
|
host: (token.node.props.host == null && this.author && this.author.host != null ? this.author.host : token.node.props.host) || host,
|
||||||
|
@ -178,7 +178,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'hashtag': {
|
case 'hashtag': {
|
||||||
return [createElement('router-link', {
|
return [h('router-link', {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
attrs: {
|
attrs: {
|
||||||
to: this.isNote ? `/tags/${encodeURIComponent(token.node.props.hashtag)}` : `/explore/tags/${encodeURIComponent(token.node.props.hashtag)}`,
|
to: this.isNote ? `/tags/${encodeURIComponent(token.node.props.hashtag)}` : `/explore/tags/${encodeURIComponent(token.node.props.hashtag)}`,
|
||||||
|
@ -188,7 +188,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'blockCode': {
|
case 'blockCode': {
|
||||||
return [createElement(MkCode, {
|
return [h(MkCode, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
code: token.node.props.code,
|
code: token.node.props.code,
|
||||||
|
@ -198,7 +198,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'inlineCode': {
|
case 'inlineCode': {
|
||||||
return [createElement(MkCode, {
|
return [h(MkCode, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
code: token.node.props.code,
|
code: token.node.props.code,
|
||||||
|
@ -210,13 +210,13 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
|
|
||||||
case 'quote': {
|
case 'quote': {
|
||||||
if (this.shouldBreak) {
|
if (this.shouldBreak) {
|
||||||
return [createElement('div', {
|
return [h('div', {
|
||||||
attrs: {
|
attrs: {
|
||||||
class: 'quote'
|
class: 'quote'
|
||||||
}
|
}
|
||||||
}, genEl(token.children))];
|
}, genEl(token.children))];
|
||||||
} else {
|
} else {
|
||||||
return [createElement('span', {
|
return [h('span', {
|
||||||
attrs: {
|
attrs: {
|
||||||
class: 'quote'
|
class: 'quote'
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'title': {
|
case 'title': {
|
||||||
return [createElement('div', {
|
return [h('div', {
|
||||||
attrs: {
|
attrs: {
|
||||||
class: 'title'
|
class: 'title'
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'emoji': {
|
case 'emoji': {
|
||||||
return [createElement('mk-emoji', {
|
return [h('mk-emoji', {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
attrs: {
|
attrs: {
|
||||||
emoji: token.node.props.emoji,
|
emoji: token.node.props.emoji,
|
||||||
|
@ -247,7 +247,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'mathInline': {
|
case 'mathInline': {
|
||||||
return [createElement(MkFormula, {
|
return [h(MkFormula, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
formula: token.node.props.formula,
|
formula: token.node.props.formula,
|
||||||
|
@ -257,7 +257,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'mathBlock': {
|
case 'mathBlock': {
|
||||||
return [createElement(MkFormula, {
|
return [h(MkFormula, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
formula: token.node.props.formula,
|
formula: token.node.props.formula,
|
||||||
|
@ -267,7 +267,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'search': {
|
case 'search': {
|
||||||
return [createElement(MkGoogle, {
|
return [h(MkGoogle, {
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
props: {
|
props: {
|
||||||
q: token.node.props.query
|
q: token.node.props.query
|
||||||
|
@ -284,6 +284,6 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Parse ast to DOM
|
// Parse ast to DOM
|
||||||
return createElement('span', genEl(ast));
|
return h('span', genEl(ast));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,11 +46,6 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.$once('hook:beforeDestroy', () => {
|
|
||||||
this.connection.dispose();
|
|
||||||
if (this.connection2) this.connection2.dispose();
|
|
||||||
});
|
|
||||||
|
|
||||||
const prepend = note => {
|
const prepend = note => {
|
||||||
const _note = JSON.parse(JSON.stringify(note)); // deepcopy
|
const _note = JSON.parse(JSON.stringify(note)); // deepcopy
|
||||||
(this.$refs.tl as any).prepend(_note);
|
(this.$refs.tl as any).prepend(_note);
|
||||||
|
@ -130,6 +125,11 @@ export default defineComponent({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beforeUnmount() {
|
||||||
|
this.connection.dispose();
|
||||||
|
if (this.connection2) this.connection2.dispose();
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
focus() {
|
focus() {
|
||||||
this.$refs.tl.focus();
|
this.$refs.tl.focus();
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
|
import { Directive } from 'vue';
|
||||||
import * as getCaretCoordinates from 'textarea-caret';
|
import * as getCaretCoordinates from 'textarea-caret';
|
||||||
import { toASCII } from 'punycode';
|
import { toASCII } from 'punycode';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
bind(el, binding, vn) {
|
mounted(el, binding, vn) {
|
||||||
const self = el._autoCompleteDirective_ = {} as any;
|
const self = el._autoCompleteDirective_ = {} as any;
|
||||||
self.x = new Autocomplete(el, vn.context, binding.value);
|
self.x = new Autocomplete(el, vn.context, binding.value);
|
||||||
self.x.attach();
|
self.x.attach();
|
||||||
},
|
},
|
||||||
|
|
||||||
unbind(el, binding, vn) {
|
unmounted(el, binding, vn) {
|
||||||
const self = el._autoCompleteDirective_;
|
const self = el._autoCompleteDirective_;
|
||||||
self.x.detach();
|
self.x.detach();
|
||||||
}
|
}
|
||||||
};
|
} as Directive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* オートコンプリートを管理するクラス。
|
* オートコンプリートを管理するクラス。
|
||||||
|
|
|
@ -7,9 +7,9 @@ import particle from './particle';
|
||||||
import tooltip from './tooltip';
|
import tooltip from './tooltip';
|
||||||
|
|
||||||
export default function(app: App) {
|
export default function(app: App) {
|
||||||
//app.directive('autocomplete', autocomplete);
|
app.directive('autocomplete', autocomplete);
|
||||||
//app.directive('userPreview', userPreview);
|
app.directive('userPreview', userPreview);
|
||||||
//app.directive('user-preview', userPreview);
|
app.directive('user-preview', userPreview);
|
||||||
app.directive('size', size);
|
app.directive('size', size);
|
||||||
//app.directive('particle', particle);
|
//app.directive('particle', particle);
|
||||||
//app.directive('tooltip', tooltip);
|
//app.directive('tooltip', tooltip);
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
import { Directive } from 'vue';
|
||||||
import MkUserPreview from '../components/user-preview.vue';
|
import MkUserPreview from '../components/user-preview.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
bind(el: HTMLElement, binding, vn) {
|
mounted(el: HTMLElement, binding, vn) {
|
||||||
|
// TODO: 新たにプロパティを作るのをやめMapを使う
|
||||||
|
// ただメモリ的には↓の方が省メモリかもしれないので検討中
|
||||||
const self = (el as any)._userPreviewDirective_ = {} as any;
|
const self = (el as any)._userPreviewDirective_ = {} as any;
|
||||||
|
|
||||||
self.user = binding.value;
|
self.user = binding.value;
|
||||||
|
@ -68,8 +71,8 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
unbind(el, binding, vn) {
|
unmounted(el, binding, vn) {
|
||||||
const self = el._userPreviewDirective_;
|
const self = el._userPreviewDirective_;
|
||||||
clearInterval(self.checkTimer);
|
clearInterval(self.checkTimer);
|
||||||
}
|
}
|
||||||
};
|
} as Directive;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import FontAwesomeIcon from './components/fa.vue';
|
||||||
import Stream from './scripts/stream';
|
import Stream from './scripts/stream';
|
||||||
import widgets from './widgets';
|
import widgets from './widgets';
|
||||||
import directives from './directives';
|
import directives from './directives';
|
||||||
|
import components from './components';
|
||||||
import { version, langs, getLocale, apiUrl } from './config';
|
import { version, langs, getLocale, apiUrl } from './config';
|
||||||
import { store } from './store';
|
import { store } from './store';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
|
@ -172,8 +173,7 @@ app.component('fa', FontAwesomeIcon);
|
||||||
|
|
||||||
widgets(app);
|
widgets(app);
|
||||||
directives(app);
|
directives(app);
|
||||||
|
components(app);
|
||||||
//require('./components');
|
|
||||||
|
|
||||||
document.body.innerHTML = '<div id="app"></div>';
|
document.body.innerHTML = '<div id="app"></div>';
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,10 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
api(endpoint: string, data: { [x: string]: any } = {}, token?) {
|
||||||
|
return this.$store.dispatch('api', { endpoint, data, token });
|
||||||
|
},
|
||||||
|
|
||||||
dialog(opts) {
|
dialog(opts) {
|
||||||
this.$store.commit('showDialog', opts);
|
this.$store.commit('showDialog', opts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import Vue from 'vue';
|
|
||||||
import { getScrollPosition, onScrollTop } from './scroll';
|
import { getScrollPosition, onScrollTop } from './scroll';
|
||||||
|
|
||||||
const SECOND_FETCH_LIMIT = 30;
|
const SECOND_FETCH_LIMIT = 30;
|
||||||
|
@ -48,14 +47,14 @@ export default (opts) => ({
|
||||||
created() {
|
created() {
|
||||||
opts.displayLimit = opts.displayLimit || 30;
|
opts.displayLimit = opts.displayLimit || 30;
|
||||||
this.init();
|
this.init();
|
||||||
|
},
|
||||||
|
|
||||||
this.$on('hook:activated', () => {
|
activated() {
|
||||||
this.isBackTop = false;
|
this.isBackTop = false;
|
||||||
});
|
},
|
||||||
|
|
||||||
this.$on('hook:deactivated', () => {
|
deactivated() {
|
||||||
this.isBackTop = window.scrollY === 0;
|
this.isBackTop = window.scrollY === 0;
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -75,7 +74,7 @@ export default (opts) => ({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
updateItem(i, item) {
|
updateItem(i, item) {
|
||||||
Vue.set((this as any).items, i, item);
|
(this as any).items[i] = item;
|
||||||
},
|
},
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
|
|
Loading…
Reference in New Issue