Browse Source

poc v0

master
Jérôme Chauveau 4 years ago
parent
commit
e0c56f050a
11 changed files with 14205 additions and 195 deletions
  1. +11913
    -0
      package-lock.json
  2. +4
    -0
      package.json
  3. +8
    -6
      src/App.vue
  4. +66
    -0
      src/assets/dedediteur.css
  5. +95
    -0
      src/assets/menubar.scss
  6. +438
    -0
      src/components/Dedediteur.vue
  7. +0
    -58
      src/components/HelloWorld.vue
  8. +63
    -0
      src/components/extensions/CustomStyle.js
  9. +31
    -0
      src/components/extensions/SubscriptStyle.js
  10. +27
    -0
      src/components/extensions/SuperscriptStyle.js
  11. +1560
    -131
      yarn.lock

+ 11913
- 0
package-lock.json
File diff suppressed because it is too large
View File


+ 4
- 0
package.json View File

@@ -9,6 +9,8 @@
},
"dependencies": {
"core-js": "^3.6.4",
"tiptap": "^1.27.0",
"tiptap-extensions": "^1.29.0",
"vue": "^2.6.11"
},
"devDependencies": {
@@ -18,6 +20,8 @@
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {


+ 8
- 6
src/App.vue View File

@@ -1,28 +1,30 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<Dedediteur/>
</div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'
import Dedediteur from './components/Dedediteur.vue'

export default {
name: 'App',
components: {
HelloWorld
Dedediteur
}
}
</script>

<style>
body, html{
margin : 0;
padding: 0;
}
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}

</style>

+ 66
- 0
src/assets/dedediteur.css View File

@@ -0,0 +1,66 @@
.editor{
position: relative;
}
.editor-main {
width: 75%;
margin: auto;
}
.editor__content {
margin: auto;
}

/* MOTS */
/*// — Mot - Accronyme*/
.acronym{
color: pink;
}
/*// — Mot - Etranger*/
.foreign{
color: red;
}

/* NOMS */
/*// — Nom - Auteur - Citation*/
.author-quotation{
color : yellow;

}
/*// — Nom - Auteur - Œuvre*/
.author-work{
color: orange;
}
/*// — Nom - Marque*/
.brand{
color: coral;
}
/*// — Nom - Propre*/

.proper-noun{
color: darkorange;
}

/* NOMBRES */
/*// — Numeral - Chapitre*/
.chapter{
color: blue;
}
/*// — Numeral - Date*/
.date{
color: aqua;
}
/*// — Numeral - Siecle*/
.century{
color: cornflowerblue;
}

/*TYPO */
/*// — Typo - Exposant*/
.superscript{
color: green;
}
/*// — Typo - Indice*/
.subscript{
color:chartreuse;

}
/*// — Typo - Particulier*/

+ 95
- 0
src/assets/menubar.scss View File

@@ -0,0 +1,95 @@
$button-width : 42px;
$button-border : 2px solid black;
.menubar{


&.paragraph-menubar {

position: fixed;
display:flex;
flex-direction: column;

top: 100px;
right: 25px;

button {
cursor: pointer;
width: $button-width;
height: $button-width;
background-color: white;
border-left: $button-border ;
border-right: $button-border ;
border-bottom: $button-border ;
border-top :none;
&:nth-child(1){
border-top : $button-border ;
}

&:hover{
color: white;
background-color: black;
}
}
}

&.char-menubar{

top: 10px;
display: block;
width : 75%;
margin : 50px 0px 100px 0px;
ul, li {
padding:0;
margin: 0;
}



& > ul {
display: flex;
justify-content:flex-start;
position: relative;
li, button{
cursor: pointer;
}
ul {
display:none;
position: absolute;
}
& > li {
width: 150px;
list-style-type: none;
border-top: $button-border ;
border-right: $button-border ;
border-bottom: $button-border ;
&:nth-child(1){
border-left: $button-border ;
}
}
li:hover{
ul {
display: flex;
flex-direction: column;
position: absolute;
width: 152px;
li{
border-left: $button-border ;
border-right: $button-border ;
border-bottom: $button-border ;
list-style-type: none;
margin-left: -2px;

button {
border :none;
background-color: white;
width: 100%;
}
}
}
}


}
}

}

+ 438
- 0
src/components/Dedediteur.vue View File

@@ -0,0 +1,438 @@
<template>
<div class="editor">
<div id="file_actions">
<button id="input_button" onclick="document.getElementById('input').click()"></button>
<button id="output_button" v-on:click="saveFile"></button>
<input type="file" style="display:none;" id="input" v-on:change="loadFile()">
</div>


<div class="editor-main">

<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">

<div>

<div class="menubar char-menubar">
<ul>

<li>
Mot
<ul>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'acronym' }) }"
@click="commands.customstyle({ type: 'acronym' })">
Acronyme
</button>
</li>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'foreign' }) }"
@click="commands.customstyle({ type: 'foreign' })">
Étranger
</button>
</li>
</ul>
</li>


<li>
Nom
<ul>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'author-quotation' }) }"
@click="commands.customstyle({ type: 'author-quotation' })">
Auteur - Citation
</button>
</li>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'author-work' }) }"
@click="commands.customstyle({ type: 'author-work' })">
Auteur - Œuvre
</button>
</li>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'brand' }) }"
@click="commands.customstyle({ type: 'brand' })">
Marque
</button>
</li>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'proper-noun' }) }"
@click="commands.customstyle({ type: 'proper-noun' })">
Nom propre
</button>
</li>
</ul>
</li>


<li>
Numéral
<ul>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'century' }) }"
@click="commands.customstyle({ type: 'century' })">
Siècle
</button>
</li>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'date' }) }"
@click="commands.customstyle({ type: 'date' })">
Date
</button>
</li>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'chapter' }) }"
@click="commands.customstyle({ type: 'chapter' })">
Chapitre
</button>
</li>
</ul>
</li>

<li>
Typo
<ul>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.subscriptstyle() }"
@click="commands.subscriptstyle()">
Indice
</button>
</li>
<li>
<button
class="menubar__button"
:class="{ 'is-active': isActive.superscriptstyle() }"
@click="commands.superscriptstyle()">
Exposant
</button>
</li>
</ul>
</li>


</ul>
</div>


<div class="menubar paragraph-menubar">

<button
class="menubar__button"
:class="{ 'is-active': isActive.paragraph() }"
@click="commands.paragraph">
</button>


<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 1 }) }"
@click="commands.heading({ level: 1 })">
T1
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 2 }) }"
@click="commands.heading({ level: 2 })">
T2
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 3 }) }"
@click="commands.heading({ level: 3 })">
T3
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 3 }) }"
@click="commands.heading({ level: 3 })">
T4
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.blockquote() }"
@click="commands.blockquote">
« »
</button>

</div>
</div>
</editor-menu-bar>

<!--
<editor-menu-bubble class="menububble" :editor="editor" @hide="hideLinkMenu" v-slot="{ commands, isActive, getMarkAttrs, menu }">
<div
class="menububble"
:class="{ 'is-active': menu.isActive }"
:style="`left: ${menu.left}px; bottom: ${menu.bottom}px;`"
>

<form class="menububble__form" v-if="linkMenuIsActive" @submit.prevent="setLinkUrl(commands.link, linkUrl)">
<input class="menububble__input" type="text" v-model="linkUrl" placeholder="https://" ref="linkInput" @keydown.esc="hideLinkMenu"/>
<button class="menububble__button" @click="setLinkUrl(commands.link, null)" type="button">
DEL
</button>
</form>

<template v-else>
<button
class="menububble__button"
@click="showLinkMenu(getMarkAttrs('link'))"
:class="{ 'is-active': isActive.link() }"
>
<span>{{ isActive.link() ? 'Update Link' : 'Add Link'}}</span>
LINK
</button>
</template>

<button
class="menubar__button"
:class="{ 'is-active': isActive.paragraph() }"
@click="commands.paragraph"
>
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 1 }) }"
@click="commands.heading({ level: 1 })"
>
H1
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 2 }) }"
@click="commands.heading({ level: 2 })"
>
H2
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.heading({ level: 3 }) }"
@click="commands.heading({ level: 3 })"
>
H3
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.bullet_list() }"
@click="commands.bullet_list"
>
ul
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.ordered_list() }"
@click="commands.ordered_list"
>
ol
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.blockquote() }"
@click="commands.blockquote"
>
""
</button>

<button
class="menubar__button"
:class="{ 'is-active': isActive.customstyle({ type: 'dede' }) }"
@click="commands.customstyle({ type: 'dede' })">DeDe</button>

</div>
</editor-menu-bubble>

-->

<!--
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">

<div class="menubar">



</div>
</editor-menu-bar>-->

<editor-content class="editor__content" :editor="editor" />
</div>
</div>
</template>

<script>
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import {
Blockquote,
Heading,
OrderedList,
BulletList,
ListItem,
Link
} from 'tiptap-extensions'

import CustomStyle from "./extensions/CustomStyle";
import SubscriptStyle from "./extensions/SubscriptStyle";
import SuperscriptStyle from "./extensions/SuperscriptStyle";
export default {
components: {
EditorContent,
EditorMenuBar
},
data() {
return {
keepInBounds: true,
editor: new Editor({
extensions: [
new Blockquote(),
new BulletList(),
new Heading({ levels: [1, 2, 3] }),
new ListItem(),
new OrderedList(),
new Link(),
new CustomStyle(),
new SuperscriptStyle(),
new SubscriptStyle()
],
content: `
Soit un <a href="https://fr.wiktionary.org/wiki/moment">moment</a> de <a href="https://fr.wikipedia.org/wiki/Perception">perception</a> &amp; son ouverture <a href="https://fr.wikipedia.org/wiki/Philosophie_de_la_perception">philosophique</a>. Pour cela, avoir accès à une connexion <a href="https://fr.wikipedia.org/wiki/Internet">internet</a> &amp; installer, sur l’ordinateur exploité pour s’y connecter, un <a href="https://fr.wikipedia.org/wiki/Navigateur_web">navigateur</a> pour consulter le [web](<a href="https://fr.wikipedia.org/wiki/World_Wide_Web">World Wide Web — Wikipédia</a>). Cette consultation se concrétise par la surface d’un écran où nous sont perceptibles des pages d’informations de diverses natures (iconographique, vidéo ou <a href="https://fr.wiktionary.org/wiki/textuel">textuelle</a>) dédiées à notre <a href="https://fr.wiktionary.org/wiki/aspectus#la"><em>aspectus</em></a>. Ces informations nous sont disponibles dans l’espace de l’écran sous différents <a href="https://fr.wiktionary.org/wiki/aspect">aspects</a>, résultats de la <a href="https://fr.wiktionary.org/wiki/mani%C3%A8re">manière</a> dont elles ont été <a href="https://fr.wiktionary.org/wiki/former">formées</a>.
`,

}),
linkUrl: null,
linkMenuIsActive: false,
}
},
beforeDestroy() {
this.editor.destroy()
},

methods: {
loadFile: function () {
let ed = this.editor;
let fr = new FileReader();
fr.onload = function() {
console.log(fr.result);
ed.setContent(fr.result)
};
fr.readAsText(document.getElementById('input').files[0]);

},

saveFile: function(){
console.log(this.editor.getHTML())
},
showLinkMenu(attrs) {
this.linkUrl = attrs.href
this.linkMenuIsActive = true
this.$nextTick(() => {
this.$refs.linkInput.focus()
})
},
hideLinkMenu() {
this.linkUrl = null
this.linkMenuIsActive = false
},
setLinkUrl(command, url) {
command({ href: url })
this.hideLinkMenu()
}
}
}
</script>

<style lang="scss">
@import '../assets/menubar.scss';
@import '../assets/dedediteur.css';
.menubar{
text-align: center;
margin-top: 12px;
}

#file_actions{
/*border-bottom : 1px solid #2c3e50;*/
padding : 12px;
position: fixed;
top: 10px;
left: 10px;
}
#output_button, #input_button{
border : 1px solid black;
width: 24px;
height: 24px;
}
#input_button{
background-color: white;
}
#output_button{
background-color: black;
margin-left: 12px;
}

/* editor*/
.editor{
position: relative;
}


.ProseMirror:read-write:focus {
outline: none;
}


/*menububble */
.menububble{
/*visibility: hidden;*/
background-color: black;
border-radius: 5px;
z-index: 100;
padding: 5px;
position: absolute;
bottom: 25px;
}

.menububble.is-active{
visibility: visible;
}

.menububble button{
background-color: black;
border: none;
color : white;
border-radius: 5px;
}



</style>

+ 0
- 58
src/components/HelloWorld.vue View File

@@ -1,58 +0,0 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>

<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

+ 63
- 0
src/components/extensions/CustomStyle.js View File

@@ -0,0 +1,63 @@
import {Mark} from "tiptap";
import {toggleMark} from "tiptap-commands";


// — Mot - Accronyme
// — Mot - Etranger

// — Nom - Auteur - Citation
// — Nom - Auteur - Œuvre
// — Nom - Marque
// — Nom - Propre

// — Numeral - Chapitre
// — Numeral - Date
// — Numeral - Siecle


// — Typo - Particulier
export default class CustomStyle extends Mark {
get name() {
return "customstyle";
}

get defaultOptions() {
return {
types: [
"acronym",
"foreign",
"author-quotation",
"author-work",
"brand",
"proper-noun",
"century",
"date",
"chapter"]
};
}

get schema() {
return {
attrs: {
type: {
default: "acronym"
}
},
parseDOM: [
{
tag: "span.dede-style",
getAttrs(dom) {
return {type: dom.classList[1]};
}
}
],
toDOM: mark => {
return ["span", {class: `dede-style ${mark.attrs.type}`}, 0];
}
};
}

commands({type}) {
return attrs => toggleMark(type, attrs);
}
}

+ 31
- 0
src/components/extensions/SubscriptStyle.js View File

@@ -0,0 +1,31 @@
import { Mark } from 'tiptap'
import { toggleMark } from 'tiptap-commands'

export default class SubscriptStyle extends Mark {

get name() {
return 'subscriptstyle'
}

get schema() {
return {
parseDOM: [
{
tag: 'sub',
},
//{
// style: 'text-decoration',
// getAttrs: value => value === 'underline',
// },
],
toDOM: () => ['sub', 0],
}


}

commands({ type }) {
return () => toggleMark(type)
}

}

+ 27
- 0
src/components/extensions/SuperscriptStyle.js View File

@@ -0,0 +1,27 @@
import { Mark } from 'tiptap'
import { toggleMark } from 'tiptap-commands'

export default class SuperscriptStyle extends Mark {

get name() {
return 'superscriptstyle'
}

get schema() {
return {
parseDOM: [
{
tag: 'sup',
},
],
toDOM: () => ['sup', 0],
}


}

commands({ type }) {
return () => toggleMark(type)
}

}

+ 1560
- 131
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save