@mirus/tiptap-editor 2.0.0

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.
@@ -0,0 +1 @@
1
+ .error-list .error-list__item.selected,.error-list .error-list__item:hover{background-color:#fff3}.tiptap-editor{border:1px solid #e5e7eb;border-radius:8px;padding:4px}.tiptap-editor p.is-empty:first-child:before{content:attr(data-placeholder);float:left;color:#aaa;pointer-events:none;height:0}.tiptap-editor .menubar{padding:4px;border-radius:4px;background-color:#f4f4f5}.tiptap-editor .menubar button{font-size:14px;background-color:transparent;border:none;cursor:pointer;height:30px;outline:50;width:35px;vertical-align:bottom;border-radius:4px;margin-right:3px}.tiptap-editor .menubar button:focus{outline:2px solid #3b82f6;transition:all .08s ease-in-out}.tiptap-editor .menubar button.is-active{background-color:#d3e3fd}.tiptap-editor .menubar button.is-active:focus{background-color:#bfd2f9}.tiptap-editor .menubar button:not(.is-active):hover{background-color:#e5e7eb}.tiptap-editor .menubar button:not(.is-active):focus{background-color:#e5e7eb}.tiptap-editor .menubar button svg{width:12px}.tiptap-editor .editor__content{font-size:16px;outline:0;overflow-y:auto;padding:10px}.tiptap-editor .editor__content .underline-red{border-bottom:3px red solid}.tiptap-editor .editor__content .underline-orange{border-bottom:3px orange solid}.tiptap-editor .editor__content .underline-green{border-bottom:3px lightgreen solid}.tiptap-editor .editor__content .underline-blue{border-bottom:3px #3b82f6 solid}.tiptap-editor .editor__content ul{padding:0 40px}.tiptap-editor .editor__content .ProseMirror{height:100%;padding:2px;border-radius:7px}.tiptap-editor .editor__content .ProseMirror:focus{outline:2px solid #3b82f6;transition:all .08s ease-in-out}.character-count{padding:4px 15px 4px 4px;border-radius:4px;background-color:#fafafa;text-align:right;display:flex;gap:8px;justify-content:flex-end;color:#71717a}.character-count__graph{color:#a8c2f7}.character-count__graph--warning{color:#fb7373}
@@ -0,0 +1,14 @@
1
+ <script type="module" crossorigin src="/assets/index-40717dd0.js"></script>
2
+ <link rel="stylesheet" href="/assets/index-7678a4fb.css">
3
+ <meta charset="utf-8">
4
+ <title>tiptap-editor demo</title>
5
+
6
+ <style>
7
+ body {
8
+ font-family: sans-serif;
9
+ }
10
+ </style>
11
+
12
+
13
+ <div id="app"></div>
14
+
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@mirus/tiptap-editor",
3
+ "version": "2.0.0",
4
+ "description": "custom setup for the tiptap editor",
5
+ "repository": "https://github.com/mirusresearch/tiptap-editor",
6
+ "bugs": {
7
+ "url": "https://github.com/mirusresearch/tiptap-editor"
8
+ },
9
+ "homepage": "https://github.com/mirusresearch/tiptap-editor",
10
+ "author": "alec@mirusresearch.com",
11
+ "license": "MIT",
12
+ "main": "dist/tiptap-editor.umd.min.js",
13
+ "browser": {
14
+ "./sfc": "src/tiptap-editor.vue"
15
+ },
16
+ "files": [
17
+ "dist/*",
18
+ "src/*",
19
+ "public/*",
20
+ "*.json",
21
+ "*.js"
22
+ ],
23
+ "scripts": {
24
+ "serve": "vite",
25
+ "build": "vite build",
26
+ "preview": "vite preview",
27
+ "format": "prettier --write \"src\" \"test\"",
28
+ "validate:format": "prettier --check \"src\" \"test\"",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "coverage": "vitest run --coverage"
32
+ },
33
+ "devDependencies": {
34
+ "@babel/core": "^7.4.4",
35
+ "@babel/helper-define-map": "^7.18.6",
36
+ "@babel/helper-regex": "^7.10.5",
37
+ "@babel/polyfill": "^7.4.4",
38
+ "@babel/preset-env": "^7.4.4",
39
+ "@tiptap/core": "^2.1.10",
40
+ "@tiptap/extension-bold": "^2.1.10",
41
+ "@tiptap/extension-bullet-list": "^2.1.10",
42
+ "@tiptap/extension-character-count": "^2.1.10",
43
+ "@tiptap/extension-document": "^2.1.10",
44
+ "@tiptap/extension-history": "^2.0.3",
45
+ "@tiptap/extension-italic": "^2.1.10",
46
+ "@tiptap/extension-list-item": "^2.1.10",
47
+ "@tiptap/extension-paragraph": "^2.1.10",
48
+ "@tiptap/extension-placeholder": "^2.1.10",
49
+ "@tiptap/extension-text": "^2.1.10",
50
+ "@tiptap/pm": "^2.0.3",
51
+ "@tiptap/vue-2": "^2.1.10",
52
+ "@vitejs/plugin-vue2": "^2.2.0",
53
+ "@vitest/coverage-v8": "^0.32.2",
54
+ "@vue/babel-preset-app": "^3.7.0",
55
+ "@vue/test-utils": "^1.3.6",
56
+ "babel-loader": "^8.0.5",
57
+ "babel-polyfill": "^6.26.0",
58
+ "current-script-polyfill": "^1.0.0",
59
+ "eslint": "^5.15.3",
60
+ "flush-promises": "^1.0.2",
61
+ "happy-dom": "^9.20.3",
62
+ "lodash.get": "^4.4.2",
63
+ "lodash.unescape": "^4.0.1",
64
+ "prettier": "2.8.8",
65
+ "sass": "1.60.0",
66
+ "tippy.js": "^4.3.1",
67
+ "vite": "^4.3.9",
68
+ "vitest": "^0.32.2",
69
+ "vue": "^2.6.10",
70
+ "webpack": "^4.31.0"
71
+ },
72
+ "browserslist": [
73
+ "> 1%",
74
+ "last 2 versions",
75
+ "ie >= 9"
76
+ ],
77
+ "dependencies": {
78
+ "vue-template-compiler": "^2.7.14"
79
+ }
80
+ }
package/src/App.vue ADDED
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <tiptapEditor
3
+ :value.sync="localtext"
4
+ :warnings="warnings"
5
+ :showMenu="showMenu"
6
+ :maxCharacterCount="maxCharacterCount"
7
+ :height="height"
8
+ v-on:new-character-count="localcount = $event"
9
+ id="unique_id"
10
+ placeholder="write something will-ya!"
11
+ />
12
+ </template>
13
+
14
+ <script>
15
+ import tiptapEditor from './tiptap-editor.vue';
16
+
17
+ export default {
18
+ name: 'app',
19
+ components: { tiptapEditor },
20
+ data() {
21
+ return {
22
+ maxCharacterCount: 200, //default null for infinity
23
+ height: '200px', // default it 300px
24
+ showMenu: true, // false to hide
25
+ warnings: [
26
+ {
27
+ value: 'red',
28
+ message: 'did you mean...',
29
+ options: ['read', 'reed'], // optional
30
+ // default class is red
31
+ },
32
+ {
33
+ value: 'prob|emati(', // avoid regexs that go bump in the night
34
+ isWord: false,
35
+ message: 'What even is this?',
36
+ },
37
+ {
38
+ value: '<script&gt;', // can use the real thing, or escape it
39
+ isWord: false,
40
+ message: 'you sure you wanted a tag?',
41
+ overrideClass: 'underline-blue', // optional
42
+ },
43
+ {
44
+ value: 'green',
45
+ message: 'I really like this!',
46
+ overrideClass: 'underline-green', // optional
47
+ },
48
+ {
49
+ value: 'orange',
50
+ message: 'this is a bad idea!',
51
+ overrideClass: 'underline-orange', // optional
52
+ },
53
+ ],
54
+ localtext:
55
+ 'Hi! 👋🏻 &lt;script&gt; welcome to tiptap editor, here is a red mark blue with suggestions. Even prob|emati( strings. You can highlight with other colors, e.g blue, orange, and green!!',
56
+ localcount: null,
57
+ };
58
+ },
59
+ };
60
+ </script>
package/src/App.vue~ ADDED
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <div>
3
+ testx
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ /* import tiptapEditor from './tiptap-editor.vue';*/
9
+
10
+ export default {
11
+ name: 'dev',
12
+ /* components: { tiptapEditor },*/
13
+ data() {
14
+ return {
15
+ warnings: [
16
+ {
17
+ value: 'red',
18
+ message: 'did you mean...',
19
+ options: ['read', 'reed'], // optional
20
+ // default class is red
21
+ },
22
+ {
23
+ value: '<script&gt;', // can use the real thing, or escape it
24
+ isWord: false,
25
+ message: 'you sure you wanted a tag?',
26
+ overrideClass: 'underline-blue', // optional
27
+ },
28
+ {
29
+ value: 'green',
30
+ message: 'I really like this!',
31
+ overrideClass: 'underline-green', // optional
32
+ },
33
+ {
34
+ value: 'orange',
35
+ message: 'this is a bad idea!',
36
+ overrideClass: 'underline-orange', // optional
37
+ },
38
+ ],
39
+ localtext:
40
+ '&lt;script&gt; welcome to tiptap editor, here is a red mark blue with suggestions. You can also to blue, orange, and green!!',
41
+ };
42
+ },
43
+ };
44
+ </script>
45
+
46
+ <style></style>
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import '@babel/polyfill';
2
+ import TiptapEditor from './tiptap-editor.vue';
3
+ export default TiptapEditor;
package/src/main.js ADDED
@@ -0,0 +1,8 @@
1
+ // import '@babel/polyfill';
2
+ import Vue from 'vue';
3
+ import App from './App.vue';
4
+
5
+ Vue.config.productionTip = false;
6
+ new Vue({
7
+ render: (h) => h(App),
8
+ }).$mount('#app');
package/src/main.js~ ADDED
@@ -0,0 +1,9 @@
1
+ import Vue from 'vue';
2
+ import Dev from 'dev.vue';
3
+ Vue.config.productionTip = false;
4
+
5
+ new Vue({
6
+ render: function(h) {
7
+ h(Dev);
8
+ },
9
+ }).$mount('#app');
@@ -0,0 +1,48 @@
1
+ import { Extension, Plugin, PluginKey } from 'tiptap';
2
+
3
+ // For some reason the empty edit area has a size of 2
4
+ function realSize(size) {
5
+ return size - 2;
6
+ }
7
+
8
+ export default class MaxCharacterCount extends Extension {
9
+ get name() {
10
+ return 'maxCharacterCount';
11
+ }
12
+
13
+ get defaultOptions() {
14
+ return {
15
+ maxCharacterCount: 100,
16
+ onChange: () => {},
17
+ };
18
+ }
19
+
20
+ get plugins() {
21
+ const self = this;
22
+
23
+ return [
24
+ new Plugin({
25
+ key: new PluginKey('maxCharacterCount'),
26
+ filterTransaction: (transaction, state) => {
27
+ if (self.options.maxCharacterCount !== null && transaction.docChanged) {
28
+ const step = transaction.steps[0].toJSON();
29
+
30
+ return (
31
+ realSize(state.doc.content.size) < self.options.maxCharacterCount ||
32
+ step.from < step.to || // let deletes through
33
+ step.stepType !== 'replace' // let none adds through
34
+ );
35
+ }
36
+ return true;
37
+ },
38
+ view() {
39
+ return {
40
+ update: (view, prevState) => {
41
+ self.options.onChange(realSize(view.state.doc.content.size));
42
+ },
43
+ };
44
+ },
45
+ }),
46
+ ];
47
+ }
48
+ }
@@ -0,0 +1,33 @@
1
+ import { Extension, Plugin, PluginKey } from 'tiptap';
2
+
3
+ export default class MaxCharacterCount extends Extension {
4
+ get name() {
5
+ return 'max Character Count';
6
+ }
7
+
8
+ get defaultOptions() {
9
+ return {
10
+ maxCharacterCount: 100,
11
+ onChange: () => {},
12
+ };
13
+ }
14
+
15
+ get plugins() {
16
+ const self = this;
17
+
18
+ return [
19
+ new Plugin({
20
+ key: new PluginKey('maxCharacterCount'),
21
+ filterTransaction: (transaction, state) => {
22
+ if (self.options.maxCharacterCount !== null) {
23
+ return state.doc.content.size < self.options.maxCharacterCount;
24
+ }
25
+ return true;
26
+ },
27
+ appendTransaction: (transactions, oldState, newState) => {
28
+ self.options.onChange(newState.doc.content.size);
29
+ },
30
+ }),
31
+ ];
32
+ }
33
+ }