-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<template> | ||
<q-btn-dropdown icon="mdi-format-font" menu-anchor="bottom left" menu-self="top left" class="o-font-family" content-class="o-menu o-align-dropdown-menu" dense flat> | ||
<q-list> | ||
<template v-for="(item, index) of fontFamilies"> | ||
<q-separator :key="index" v-if="item.separator" /> | ||
<q-item :key="index" clickable v-close-popup | ||
@click.native="commands.fontFamily({fontFamily: item.value})" v-else> | ||
<q-item-section :style="`font-family: ${item.label}`">{{item.label}}</q-item-section> | ||
</q-item> | ||
</template> | ||
</q-list> | ||
</q-btn-dropdown> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'o-font-family', | ||
data () { | ||
return { | ||
fontFamilies: [ | ||
{ label: 'Default', value: 'Roboto' }, | ||
{ label: 'Arial', value: 'Arial', separator: true }, | ||
{ label: 'Arial Black', value: 'Arial Black' }, | ||
{ label: 'Georgia', value: 'Georgia' }, | ||
{ label: 'Impact', value: 'Impact' }, | ||
{ label: 'Helvetica', value: 'Helvetica' }, | ||
{ label: 'Roboto', value: 'Roboto' }, | ||
{ label: 'Tahoma', value: 'Tahoma' }, | ||
{ label: 'Times New Roman', value: 'Times New Roman' }, | ||
{ label: 'Verdana', value: 'Verdana' }, | ||
{ label: 'Courier New', value: 'Courier New', separator: true }, | ||
{ label: 'Monaco', value: 'Monaco' }, | ||
{ label: 'Monospace', value: 'monospace' }, | ||
] | ||
} | ||
}, | ||
props: { | ||
commands: { | ||
type: Object | ||
} | ||
}, | ||
methods: { | ||
}, | ||
computed: { | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="stylus"> | ||
.o-font-family { | ||
padding 4px | ||
.q-btn-dropdown__arrow { | ||
margin-left 0 | ||
} | ||
} | ||
.o-align-dropdown-menu { | ||
.q-list { | ||
.q-icon { | ||
font-size 1rem | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { markInputRule } from 'tiptap-commands' | ||
import { Mark } from 'tiptap' | ||
import { applyMark } from '../utils/mark' | ||
|
||
export default class FontFamily extends Mark { | ||
get name () { | ||
return 'fontFamily' | ||
} | ||
|
||
get schema () { | ||
return { | ||
attrs: { | ||
fontFamily: { | ||
default: '#000000' | ||
} | ||
}, | ||
parseDOM: [ | ||
{ | ||
style: 'font-family', | ||
getAttrs: value => ({ fontFamily: value }) | ||
}, | ||
], | ||
toDOM: mark => ['span', { style: `font-family: ${mark.attrs.fontFamily}` }, 0] | ||
} | ||
} | ||
|
||
commands ({ type }) { | ||
return attrs => (state, dispatch) => { | ||
let { tr } = state | ||
tr = applyMark(state.tr.setSelection(state.selection), type, attrs) | ||
if (tr.docChanged || tr.storedMarksSet) { | ||
dispatch && dispatch(tr) | ||
return true | ||
} | ||
} | ||
} | ||
|
||
inputRules ({ type }) { | ||
return [ | ||
markInputRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/, type) | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters