@onereach/ui-components 10.3.0 → 10.3.1-beta.4291.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.
- package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
- package/dist/bundled/v2/components/OrRichTextEditorV3/utils/markdown.d.ts +2 -3
- package/dist/bundled/v2/components/OrRichTextEditorV3/utils/markdown.js +1 -1
- package/dist/bundled/v2/{markdown-fe3bfb01.js → markdown-4af315b8.js} +2825 -552
- package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/index.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/props.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/styles.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.d.ts +2 -3
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.js +1 -1
- package/dist/bundled/v3/components/{OrRichTextEditorV3-358d7df2.js → OrRichTextEditorV3-82b6efa2.js} +2798 -525
- package/dist/bundled/v3/components/index.js +1 -1
- package/dist/bundled/v3/index.js +1 -1
- package/dist/esm/v2/{OrRichTextEditor-734b8b27.js → OrRichTextEditor-4af25de8.js} +12 -54
- package/dist/esm/v2/components/index.js +2 -1
- package/dist/esm/v2/components/or-rich-text-editor-v3/index.js +2 -1
- package/dist/esm/v2/components/or-rich-text-editor-v3/utils/markdown.d.ts +2 -3
- package/dist/esm/v2/index.js +2 -1
- package/dist/esm/v3/{OrRichTextEditor-b5684aab.js → OrRichTextEditor-117119ca.js} +12 -54
- package/dist/esm/v3/components/index.js +2 -1
- package/dist/esm/v3/components/or-rich-text-editor-v3/index.js +2 -1
- package/dist/esm/v3/components/or-rich-text-editor-v3/utils/markdown.d.ts +2 -3
- package/dist/esm/v3/index.js +2 -1
- package/package.json +3 -3
- package/src/components/or-rich-text-editor-v3/utils/markdown.ts +15 -72
|
@@ -81,7 +81,7 @@ export { s as OrRadioV3 } from './OrRadioV3-5a26c6bb.js';
|
|
|
81
81
|
export { s as OrRangeSliderV3 } from './OrRangeSliderV3-5bd9e6d4.js';
|
|
82
82
|
export { s as OrRatingV3 } from './OrRatingV3-82a538ca.js';
|
|
83
83
|
export { s as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement } from './OrResizeablePanelV3-2c3a5c8b.js';
|
|
84
|
-
export { F as Formats, s as OrRichTextEditorV3 } from './OrRichTextEditorV3-
|
|
84
|
+
export { F as Formats, s as OrRichTextEditorV3 } from './OrRichTextEditorV3-82b6efa2.js';
|
|
85
85
|
export { default as OrSearch } from './OrSearch/OrSearch.js';
|
|
86
86
|
export { default as OrSearchV3 } from './OrSearchV3/OrSearch.js';
|
|
87
87
|
export { s as OrSegmentedControlV3, S as SegmentedControlSize } from './OrSegmentedControlV3-de9f3667.js';
|
package/dist/bundled/v3/index.js
CHANGED
|
@@ -44,7 +44,7 @@ export { default as OrRadioGroup } from './components/OrRadioGroup/OrRadioGroup.
|
|
|
44
44
|
export { default as OrRadioGroupV3 } from './components/OrRadioGroupV3/OrRadioGroup.js';
|
|
45
45
|
export { s as OrRangeSliderV3 } from './components/OrRangeSliderV3-5bd9e6d4.js';
|
|
46
46
|
export { s as OrRatingV3 } from './components/OrRatingV3-82a538ca.js';
|
|
47
|
-
export { F as Formats, s as OrRichTextEditorV3 } from './components/OrRichTextEditorV3-
|
|
47
|
+
export { F as Formats, s as OrRichTextEditorV3 } from './components/OrRichTextEditorV3-82b6efa2.js';
|
|
48
48
|
export { s as OrSegmentedControlV3, S as SegmentedControlSize } from './components/OrSegmentedControlV3-de9f3667.js';
|
|
49
49
|
export { s as OrSelect } from './components/OrSelect-c7bcf79e.js';
|
|
50
50
|
export { s as OrSelectV3 } from './components/OrSelectV3-0451208d.js';
|
|
@@ -3,6 +3,7 @@ import { useFocusTrap } from '@vueuse/integrations/useFocusTrap';
|
|
|
3
3
|
import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue-demi';
|
|
4
4
|
import { defaultMarkdownSerializer, MarkdownSerializer } from 'prosemirror-markdown';
|
|
5
5
|
import { DOMParser as DOMParser$1 } from 'prosemirror-model';
|
|
6
|
+
import { marked } from 'marked';
|
|
6
7
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
7
8
|
import BulletList from '@tiptap/extension-bullet-list';
|
|
8
9
|
import ListItem from '@tiptap/extension-list-item';
|
|
@@ -38,7 +39,7 @@ import { javascript } from '@codemirror/lang-javascript';
|
|
|
38
39
|
import { s as styleInject } from './style-inject.es-4c6f2515.js';
|
|
39
40
|
import { n as normalizeComponent } from './normalize-component-6e8e3d80.js';
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
+
const mdSerializerNodes = {
|
|
42
43
|
...defaultMarkdownSerializer.nodes,
|
|
43
44
|
[Paragraph.name]: defaultMarkdownSerializer.nodes.paragraph,
|
|
44
45
|
[BulletList.name]: defaultMarkdownSerializer.nodes.bullet_list,
|
|
@@ -48,7 +49,7 @@ const serializerNodes = {
|
|
|
48
49
|
[CodeBlock.name]: defaultMarkdownSerializer.nodes.code_block,
|
|
49
50
|
[Blockquote.name]: defaultMarkdownSerializer.nodes.blockquote
|
|
50
51
|
};
|
|
51
|
-
const
|
|
52
|
+
const mdSerializerMarks = {
|
|
52
53
|
...defaultMarkdownSerializer.marks,
|
|
53
54
|
[Bold.name]: defaultMarkdownSerializer.marks.strong,
|
|
54
55
|
[Strike.name]: {
|
|
@@ -85,67 +86,24 @@ const serializerMarks = {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
};
|
|
88
|
-
|
|
89
|
+
function isPlainURL(link, parent, index, side) {
|
|
89
90
|
if (link.attrs.title || !/^\w+:/.test(link.attrs.href)) return false;
|
|
90
91
|
const content = parent.child(index + (side < 0 ? -1 : 0));
|
|
91
92
|
if (!content.isText || content.text !== link.attrs.href || content.marks[content.marks.length - 1] !== link) return false;
|
|
92
93
|
if (index === (side < 0 ? 1 : parent.childCount - 1)) return true;
|
|
93
94
|
const next = parent.child(index + (side < 0 ? -2 : 1));
|
|
94
95
|
return !link.isInSet(next.marks);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
md = md.replace(/^\s*\n\*/gm, '<ul>\n*');
|
|
99
|
-
md = md.replace(/^(\*.+)\s*\n([^*])/gm, '$1\n</ul>\n\n$2');
|
|
100
|
-
md = md.replace(/^\*(.+)/gm, '<li>$1</li>');
|
|
101
|
-
//ol
|
|
102
|
-
md = md.replace(/^\s*\n\d\./gm, '<ol>\n1.');
|
|
103
|
-
md = md.replace(/^(\d\..+)\s*\n([^\d.])/gm, '$1\n</ol>\n\n$2');
|
|
104
|
-
md = md.replace(/^\d\.(.+)/gm, '<li>$1</li>');
|
|
105
|
-
//blockquote
|
|
106
|
-
md = md.replace(/^>(.+)/gm, '<blockquote>$1</blockquote>');
|
|
107
|
-
//h
|
|
108
|
-
md = md.replace(/[#]{6}(.+)/g, '<h6>$1</h6>');
|
|
109
|
-
md = md.replace(/[#]{5}(.+)/g, '<h5>$1</h5>');
|
|
110
|
-
md = md.replace(/[#]{4}(.+)/g, '<h4>$1</h4>');
|
|
111
|
-
md = md.replace(/[#]{3}(.+)/g, '<h3>$1</h3>');
|
|
112
|
-
md = md.replace(/[#]{2}(.+)/g, '<h2>$1</h2>');
|
|
113
|
-
md = md.replace(/[#]{1}(.+)/g, '<h1>$1</h1>');
|
|
114
|
-
//alt h
|
|
115
|
-
md = md.replace(/^(.+)\n=+/gm, '<h1>$1</h1>');
|
|
116
|
-
md = md.replace(/^(.+)\n-+/gm, '<h2>$1</h2>');
|
|
117
|
-
//images
|
|
118
|
-
md = md.replace(/!\[([^\]]+)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" />');
|
|
119
|
-
//links
|
|
120
|
-
md = md.replace(/[[]{1}([^\]]+)[\]]{1}[(]{1}([^)"]+)("(.+)")?[)]{1}/g, '<a href="$2" title="$4">$1</a>');
|
|
121
|
-
//font styles
|
|
122
|
-
md = md.replace(/[*_]{2}([^*_]+)[*_]{2}/g, '<b>$1</b>');
|
|
123
|
-
md = md.replace(/[*_]{1}([^*_]+)[*_]{1}/g, '<i>$1</i>');
|
|
124
|
-
md = md.replace(/[=]{2}([^=]+)[=]{2}/g, '<mark>$1</mark>');
|
|
125
|
-
md = md.replace(/[~]{2}([^~]+)[~]{2}/g, '<del>$1</del>');
|
|
126
|
-
//pre
|
|
127
|
-
md = md.replace(/^\s*\n```(([^\s]+))?/gm, '<pre class="$2">');
|
|
128
|
-
md = md.replace(/^```\s*\n/gm, '</pre>\n\n');
|
|
129
|
-
//code
|
|
130
|
-
md = md.replace(/[`]{1}([^`]+)[`]{1}/g, '<code>$1</code>');
|
|
131
|
-
//p
|
|
132
|
-
md = md.replace(/^\s*(\n)?(.+)/gm, function (m) {
|
|
133
|
-
return /<(\/)?(h\d|ul|ol|li|blockquote|pre|img)/.test(m) ? m : '<p>' + m + '</p>';
|
|
134
|
-
});
|
|
135
|
-
//strip p from pre
|
|
136
|
-
md = md.replace(/(<pre.+>)\s*\n<p>(.+)<\/p>/gm, '$1$2');
|
|
137
|
-
return md;
|
|
138
|
-
};
|
|
139
|
-
const serialize = (schema, content) => {
|
|
96
|
+
}
|
|
97
|
+
function serialize(schema, content) {
|
|
98
|
+
const mdSerializer = new MarkdownSerializer(mdSerializerNodes, mdSerializerMarks);
|
|
140
99
|
const proseMirrorDocument = schema.nodeFromJSON(content);
|
|
141
|
-
|
|
142
|
-
return serializer.serialize(proseMirrorDocument, {
|
|
100
|
+
return mdSerializer.serialize(proseMirrorDocument, {
|
|
143
101
|
tightLists: true
|
|
144
102
|
});
|
|
145
|
-
}
|
|
146
|
-
|
|
103
|
+
}
|
|
104
|
+
function deserialize(schema, content) {
|
|
147
105
|
if (!content) return null;
|
|
148
|
-
const html =
|
|
106
|
+
const html = marked.parse(content);
|
|
149
107
|
if (!html) return null;
|
|
150
108
|
const parser = new DOMParser();
|
|
151
109
|
const {
|
|
@@ -155,7 +113,7 @@ const deserialize = (schema, content) => {
|
|
|
155
113
|
body.append(document.createComment(content));
|
|
156
114
|
const state = DOMParser$1.fromSchema(schema).parse(body);
|
|
157
115
|
return state.toJSON();
|
|
158
|
-
}
|
|
116
|
+
}
|
|
159
117
|
|
|
160
118
|
const OrRichTextEditor = [
|
|
161
119
|
// Layout
|
|
@@ -99,7 +99,7 @@ export { _ as OrRadioV3 } from '../OrRadio-3629ad83.js';
|
|
|
99
99
|
export { _ as OrRangeSliderV3 } from '../OrRangeSlider-da9576ff.js';
|
|
100
100
|
export { _ as OrRatingV3 } from '../OrRating-aa2365e9.js';
|
|
101
101
|
export { _ as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement } from '../OrResizeablePanel-4a10f91c.js';
|
|
102
|
-
export { F as Formats, _ as OrRichTextEditorV3 } from '../OrRichTextEditor-
|
|
102
|
+
export { F as Formats, _ as OrRichTextEditorV3 } from '../OrRichTextEditor-4af25de8.js';
|
|
103
103
|
export { _ as OrSearch } from '../OrSearch-a340d5ff.js';
|
|
104
104
|
export { _ as OrSearchV3 } from '../OrSearch-a57eb24f.js';
|
|
105
105
|
export { _ as OrSegmentedControlV3, S as SegmentedControlSize } from '../OrSegmentedControl-cd16856e.js';
|
|
@@ -198,6 +198,7 @@ import '../isAncestor-9e33bd15.js';
|
|
|
198
198
|
import 'lodash/round';
|
|
199
199
|
import 'prosemirror-markdown';
|
|
200
200
|
import 'prosemirror-model';
|
|
201
|
+
import 'marked';
|
|
201
202
|
import '@tiptap/extension-paragraph';
|
|
202
203
|
import '@tiptap/extension-bullet-list';
|
|
203
204
|
import '@tiptap/extension-list-item';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { F as Formats, _ as OrRichTextEditorV3 } from '../../OrRichTextEditor-
|
|
1
|
+
export { F as Formats, _ as OrRichTextEditorV3 } from '../../OrRichTextEditor-4af25de8.js';
|
|
2
2
|
import '@vueuse/core';
|
|
3
3
|
import '@vueuse/integrations/useFocusTrap';
|
|
4
4
|
import 'vue-demi';
|
|
5
5
|
import 'prosemirror-markdown';
|
|
6
6
|
import 'prosemirror-model';
|
|
7
|
+
import 'marked';
|
|
7
8
|
import '@tiptap/extension-paragraph';
|
|
8
9
|
import '@tiptap/extension-bullet-list';
|
|
9
10
|
import '@tiptap/extension-list-item';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare
|
|
2
|
-
declare
|
|
3
|
-
export { serialize, deserialize };
|
|
1
|
+
export declare function serialize(schema: any, content: any): string;
|
|
2
|
+
export declare function deserialize(schema: any, content?: string): any;
|
package/dist/esm/v2/index.js
CHANGED
|
@@ -99,7 +99,7 @@ export { _ as OrRadioV3 } from './OrRadio-3629ad83.js';
|
|
|
99
99
|
export { _ as OrRangeSliderV3 } from './OrRangeSlider-da9576ff.js';
|
|
100
100
|
export { _ as OrRatingV3 } from './OrRating-aa2365e9.js';
|
|
101
101
|
export { _ as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement } from './OrResizeablePanel-4a10f91c.js';
|
|
102
|
-
export { F as Formats, _ as OrRichTextEditorV3 } from './OrRichTextEditor-
|
|
102
|
+
export { F as Formats, _ as OrRichTextEditorV3 } from './OrRichTextEditor-4af25de8.js';
|
|
103
103
|
export { _ as OrSearch } from './OrSearch-a340d5ff.js';
|
|
104
104
|
export { _ as OrSearchV3 } from './OrSearch-a57eb24f.js';
|
|
105
105
|
export { _ as OrSegmentedControlV3, S as SegmentedControlSize } from './OrSegmentedControl-cd16856e.js';
|
|
@@ -200,6 +200,7 @@ import 'lodash/round';
|
|
|
200
200
|
import 'lodash/get';
|
|
201
201
|
import 'prosemirror-markdown';
|
|
202
202
|
import 'prosemirror-model';
|
|
203
|
+
import 'marked';
|
|
203
204
|
import '@tiptap/extension-paragraph';
|
|
204
205
|
import '@tiptap/extension-bullet-list';
|
|
205
206
|
import '@tiptap/extension-list-item';
|
|
@@ -3,6 +3,7 @@ import { useFocusTrap } from '@vueuse/integrations/useFocusTrap';
|
|
|
3
3
|
import { defineComponent, ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue-demi';
|
|
4
4
|
import { defaultMarkdownSerializer, MarkdownSerializer } from 'prosemirror-markdown';
|
|
5
5
|
import { DOMParser as DOMParser$1 } from 'prosemirror-model';
|
|
6
|
+
import { marked } from 'marked';
|
|
6
7
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
7
8
|
import BulletList from '@tiptap/extension-bullet-list';
|
|
8
9
|
import ListItem from '@tiptap/extension-list-item';
|
|
@@ -37,7 +38,7 @@ import { javascript } from '@codemirror/lang-javascript';
|
|
|
37
38
|
import { resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode, Fragment, renderList, withDirectives, vShow, vModelText, createVNode } from 'vue';
|
|
38
39
|
import { s as styleInject } from './style-inject.es-4c6f2515.js';
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
+
const mdSerializerNodes = {
|
|
41
42
|
...defaultMarkdownSerializer.nodes,
|
|
42
43
|
[Paragraph.name]: defaultMarkdownSerializer.nodes.paragraph,
|
|
43
44
|
[BulletList.name]: defaultMarkdownSerializer.nodes.bullet_list,
|
|
@@ -47,7 +48,7 @@ const serializerNodes = {
|
|
|
47
48
|
[CodeBlock.name]: defaultMarkdownSerializer.nodes.code_block,
|
|
48
49
|
[Blockquote.name]: defaultMarkdownSerializer.nodes.blockquote
|
|
49
50
|
};
|
|
50
|
-
const
|
|
51
|
+
const mdSerializerMarks = {
|
|
51
52
|
...defaultMarkdownSerializer.marks,
|
|
52
53
|
[Bold.name]: defaultMarkdownSerializer.marks.strong,
|
|
53
54
|
[Strike.name]: {
|
|
@@ -84,67 +85,24 @@ const serializerMarks = {
|
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
|
-
|
|
88
|
+
function isPlainURL(link, parent, index, side) {
|
|
88
89
|
if (link.attrs.title || !/^\w+:/.test(link.attrs.href)) return false;
|
|
89
90
|
const content = parent.child(index + (side < 0 ? -1 : 0));
|
|
90
91
|
if (!content.isText || content.text !== link.attrs.href || content.marks[content.marks.length - 1] !== link) return false;
|
|
91
92
|
if (index === (side < 0 ? 1 : parent.childCount - 1)) return true;
|
|
92
93
|
const next = parent.child(index + (side < 0 ? -2 : 1));
|
|
93
94
|
return !link.isInSet(next.marks);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
md = md.replace(/^\s*\n\*/gm, '<ul>\n*');
|
|
98
|
-
md = md.replace(/^(\*.+)\s*\n([^*])/gm, '$1\n</ul>\n\n$2');
|
|
99
|
-
md = md.replace(/^\*(.+)/gm, '<li>$1</li>');
|
|
100
|
-
//ol
|
|
101
|
-
md = md.replace(/^\s*\n\d\./gm, '<ol>\n1.');
|
|
102
|
-
md = md.replace(/^(\d\..+)\s*\n([^\d.])/gm, '$1\n</ol>\n\n$2');
|
|
103
|
-
md = md.replace(/^\d\.(.+)/gm, '<li>$1</li>');
|
|
104
|
-
//blockquote
|
|
105
|
-
md = md.replace(/^>(.+)/gm, '<blockquote>$1</blockquote>');
|
|
106
|
-
//h
|
|
107
|
-
md = md.replace(/[#]{6}(.+)/g, '<h6>$1</h6>');
|
|
108
|
-
md = md.replace(/[#]{5}(.+)/g, '<h5>$1</h5>');
|
|
109
|
-
md = md.replace(/[#]{4}(.+)/g, '<h4>$1</h4>');
|
|
110
|
-
md = md.replace(/[#]{3}(.+)/g, '<h3>$1</h3>');
|
|
111
|
-
md = md.replace(/[#]{2}(.+)/g, '<h2>$1</h2>');
|
|
112
|
-
md = md.replace(/[#]{1}(.+)/g, '<h1>$1</h1>');
|
|
113
|
-
//alt h
|
|
114
|
-
md = md.replace(/^(.+)\n=+/gm, '<h1>$1</h1>');
|
|
115
|
-
md = md.replace(/^(.+)\n-+/gm, '<h2>$1</h2>');
|
|
116
|
-
//images
|
|
117
|
-
md = md.replace(/!\[([^\]]+)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" />');
|
|
118
|
-
//links
|
|
119
|
-
md = md.replace(/[[]{1}([^\]]+)[\]]{1}[(]{1}([^)"]+)("(.+)")?[)]{1}/g, '<a href="$2" title="$4">$1</a>');
|
|
120
|
-
//font styles
|
|
121
|
-
md = md.replace(/[*_]{2}([^*_]+)[*_]{2}/g, '<b>$1</b>');
|
|
122
|
-
md = md.replace(/[*_]{1}([^*_]+)[*_]{1}/g, '<i>$1</i>');
|
|
123
|
-
md = md.replace(/[=]{2}([^=]+)[=]{2}/g, '<mark>$1</mark>');
|
|
124
|
-
md = md.replace(/[~]{2}([^~]+)[~]{2}/g, '<del>$1</del>');
|
|
125
|
-
//pre
|
|
126
|
-
md = md.replace(/^\s*\n```(([^\s]+))?/gm, '<pre class="$2">');
|
|
127
|
-
md = md.replace(/^```\s*\n/gm, '</pre>\n\n');
|
|
128
|
-
//code
|
|
129
|
-
md = md.replace(/[`]{1}([^`]+)[`]{1}/g, '<code>$1</code>');
|
|
130
|
-
//p
|
|
131
|
-
md = md.replace(/^\s*(\n)?(.+)/gm, function (m) {
|
|
132
|
-
return /<(\/)?(h\d|ul|ol|li|blockquote|pre|img)/.test(m) ? m : '<p>' + m + '</p>';
|
|
133
|
-
});
|
|
134
|
-
//strip p from pre
|
|
135
|
-
md = md.replace(/(<pre.+>)\s*\n<p>(.+)<\/p>/gm, '$1$2');
|
|
136
|
-
return md;
|
|
137
|
-
};
|
|
138
|
-
const serialize = (schema, content) => {
|
|
95
|
+
}
|
|
96
|
+
function serialize(schema, content) {
|
|
97
|
+
const mdSerializer = new MarkdownSerializer(mdSerializerNodes, mdSerializerMarks);
|
|
139
98
|
const proseMirrorDocument = schema.nodeFromJSON(content);
|
|
140
|
-
|
|
141
|
-
return serializer.serialize(proseMirrorDocument, {
|
|
99
|
+
return mdSerializer.serialize(proseMirrorDocument, {
|
|
142
100
|
tightLists: true
|
|
143
101
|
});
|
|
144
|
-
}
|
|
145
|
-
|
|
102
|
+
}
|
|
103
|
+
function deserialize(schema, content) {
|
|
146
104
|
if (!content) return null;
|
|
147
|
-
const html =
|
|
105
|
+
const html = marked.parse(content);
|
|
148
106
|
if (!html) return null;
|
|
149
107
|
const parser = new DOMParser();
|
|
150
108
|
const {
|
|
@@ -154,7 +112,7 @@ const deserialize = (schema, content) => {
|
|
|
154
112
|
body.append(document.createComment(content));
|
|
155
113
|
const state = DOMParser$1.fromSchema(schema).parse(body);
|
|
156
114
|
return state.toJSON();
|
|
157
|
-
}
|
|
115
|
+
}
|
|
158
116
|
|
|
159
117
|
const OrRichTextEditor = [
|
|
160
118
|
// Layout
|
|
@@ -96,7 +96,7 @@ export { s as OrRadioV3 } from '../OrRadio-370438a9.js';
|
|
|
96
96
|
export { s as OrRangeSliderV3 } from '../OrRangeSlider-a1776b3c.js';
|
|
97
97
|
export { s as OrRatingV3 } from '../OrRating-2abf71bd.js';
|
|
98
98
|
export { s as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement } from '../OrResizeablePanel-6f6b3f58.js';
|
|
99
|
-
export { F as Formats, s as OrRichTextEditorV3 } from '../OrRichTextEditor-
|
|
99
|
+
export { F as Formats, s as OrRichTextEditorV3 } from '../OrRichTextEditor-117119ca.js';
|
|
100
100
|
export { s as OrSearch } from '../OrSearch-948c7f78.js';
|
|
101
101
|
export { s as OrSearchV3 } from '../OrSearch-073955fc.js';
|
|
102
102
|
export { s as OrSegmentedControlV3, S as SegmentedControlSize } from '../OrSegmentedControl-1370c626.js';
|
|
@@ -189,6 +189,7 @@ import '../isAncestor-9e33bd15.js';
|
|
|
189
189
|
import 'lodash/round';
|
|
190
190
|
import 'prosemirror-markdown';
|
|
191
191
|
import 'prosemirror-model';
|
|
192
|
+
import 'marked';
|
|
192
193
|
import '@tiptap/extension-paragraph';
|
|
193
194
|
import '@tiptap/extension-bullet-list';
|
|
194
195
|
import '@tiptap/extension-list-item';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { F as Formats, s as OrRichTextEditorV3 } from '../../OrRichTextEditor-
|
|
1
|
+
export { F as Formats, s as OrRichTextEditorV3 } from '../../OrRichTextEditor-117119ca.js';
|
|
2
2
|
import '@vueuse/core';
|
|
3
3
|
import '@vueuse/integrations/useFocusTrap';
|
|
4
4
|
import 'vue-demi';
|
|
5
5
|
import 'prosemirror-markdown';
|
|
6
6
|
import 'prosemirror-model';
|
|
7
|
+
import 'marked';
|
|
7
8
|
import '@tiptap/extension-paragraph';
|
|
8
9
|
import '@tiptap/extension-bullet-list';
|
|
9
10
|
import '@tiptap/extension-list-item';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare
|
|
2
|
-
declare
|
|
3
|
-
export { serialize, deserialize };
|
|
1
|
+
export declare function serialize(schema: any, content: any): string;
|
|
2
|
+
export declare function deserialize(schema: any, content?: string): any;
|
package/dist/esm/v3/index.js
CHANGED
|
@@ -96,7 +96,7 @@ export { s as OrRadioV3 } from './OrRadio-370438a9.js';
|
|
|
96
96
|
export { s as OrRangeSliderV3 } from './OrRangeSlider-a1776b3c.js';
|
|
97
97
|
export { s as OrRatingV3 } from './OrRating-2abf71bd.js';
|
|
98
98
|
export { s as OrResizeablePanelV3, R as ResizeablePanelPadding, a as ResizeablePanelPlacement } from './OrResizeablePanel-6f6b3f58.js';
|
|
99
|
-
export { F as Formats, s as OrRichTextEditorV3 } from './OrRichTextEditor-
|
|
99
|
+
export { F as Formats, s as OrRichTextEditorV3 } from './OrRichTextEditor-117119ca.js';
|
|
100
100
|
export { s as OrSearch } from './OrSearch-948c7f78.js';
|
|
101
101
|
export { s as OrSearchV3 } from './OrSearch-073955fc.js';
|
|
102
102
|
export { s as OrSegmentedControlV3, S as SegmentedControlSize } from './OrSegmentedControl-1370c626.js';
|
|
@@ -191,6 +191,7 @@ import 'lodash/round';
|
|
|
191
191
|
import 'lodash/get';
|
|
192
192
|
import 'prosemirror-markdown';
|
|
193
193
|
import 'prosemirror-model';
|
|
194
|
+
import 'marked';
|
|
194
195
|
import '@tiptap/extension-paragraph';
|
|
195
196
|
import '@tiptap/extension-bullet-list';
|
|
196
197
|
import '@tiptap/extension-list-item';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onereach/ui-components",
|
|
3
|
-
"version": "10.3.0",
|
|
3
|
+
"version": "10.3.1-beta.4291.0",
|
|
4
4
|
"npmUnpacked": "4.15.2",
|
|
5
5
|
"description": "Vue components library for v2/3",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"@vueuse/math": "9.13.0",
|
|
68
68
|
"codemirror": "6.0.1",
|
|
69
69
|
"focus-trap": "7.5.2",
|
|
70
|
+
"marked": "9.1.2",
|
|
70
71
|
"prosemirror-markdown": "1.10.1",
|
|
71
72
|
"sortablejs": "1.14.0",
|
|
72
73
|
"tailwindcss": "3.3.3",
|
|
@@ -177,6 +178,5 @@
|
|
|
177
178
|
"default": "./dist/bundled/v3/components/*/index.js"
|
|
178
179
|
},
|
|
179
180
|
"./package.json": "./package.json"
|
|
180
|
-
}
|
|
181
|
-
"gitHead": "afd291038c4b8640bfea8b2b5822e3393b751697"
|
|
181
|
+
}
|
|
182
182
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
defaultMarkdownSerializer,
|
|
4
4
|
} from 'prosemirror-markdown';
|
|
5
5
|
import { DOMParser as ProseMirrorDOMParser, Node, Mark } from 'prosemirror-model';
|
|
6
|
-
|
|
6
|
+
import { marked } from 'marked';
|
|
7
7
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
8
8
|
import BulletList from '@tiptap/extension-bullet-list';
|
|
9
9
|
import ListItem from '@tiptap/extension-list-item';
|
|
@@ -18,7 +18,7 @@ import Link from '@tiptap/extension-link';
|
|
|
18
18
|
import Highlight from '@tiptap/extension-highlight';
|
|
19
19
|
import Underline from '@tiptap/extension-underline';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const mdSerializerNodes = {
|
|
22
22
|
...defaultMarkdownSerializer.nodes,
|
|
23
23
|
[Paragraph.name]: defaultMarkdownSerializer.nodes.paragraph,
|
|
24
24
|
[BulletList.name]: defaultMarkdownSerializer.nodes.bullet_list,
|
|
@@ -29,7 +29,7 @@ const serializerNodes = {
|
|
|
29
29
|
[Blockquote.name]: defaultMarkdownSerializer.nodes.blockquote,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const mdSerializerMarks = {
|
|
33
33
|
...defaultMarkdownSerializer.marks,
|
|
34
34
|
[Bold.name]: defaultMarkdownSerializer.marks.strong,
|
|
35
35
|
[Strike.name]: {
|
|
@@ -72,7 +72,7 @@ const serializerMarks = {
|
|
|
72
72
|
},
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
function isPlainURL(link: Mark, parent: Node, index: number, side: number) {
|
|
76
76
|
if (link.attrs.title || !/^\w+:/.test(link.attrs.href)) return false;
|
|
77
77
|
const content = parent.child(index + (side < 0 ? -1 : 0));
|
|
78
78
|
if (
|
|
@@ -84,78 +84,22 @@ const isPlainURL = (link: Mark, parent: Node, index: number, side: number) => {
|
|
|
84
84
|
if (index === (side < 0 ? 1 : parent.childCount - 1)) return true;
|
|
85
85
|
const next = parent.child(index + (side < 0 ? -2 : 1));
|
|
86
86
|
return !link.isInSet(next.marks);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const parseMd = (md: string) => {
|
|
90
|
-
//ul
|
|
91
|
-
md = md.replace(/^\s*\n\*/gm, '<ul>\n*');
|
|
92
|
-
md = md.replace(/^(\*.+)\s*\n([^*])/gm, '$1\n</ul>\n\n$2');
|
|
93
|
-
md = md.replace(/^\*(.+)/gm, '<li>$1</li>');
|
|
94
|
-
|
|
95
|
-
//ol
|
|
96
|
-
md = md.replace(/^\s*\n\d\./gm, '<ol>\n1.');
|
|
97
|
-
md = md.replace(/^(\d\..+)\s*\n([^\d.])/gm, '$1\n</ol>\n\n$2');
|
|
98
|
-
md = md.replace(/^\d\.(.+)/gm, '<li>$1</li>');
|
|
99
|
-
|
|
100
|
-
//blockquote
|
|
101
|
-
md = md.replace(/^>(.+)/gm, '<blockquote>$1</blockquote>');
|
|
102
|
-
|
|
103
|
-
//h
|
|
104
|
-
md = md.replace(/[#]{6}(.+)/g, '<h6>$1</h6>');
|
|
105
|
-
md = md.replace(/[#]{5}(.+)/g, '<h5>$1</h5>');
|
|
106
|
-
md = md.replace(/[#]{4}(.+)/g, '<h4>$1</h4>');
|
|
107
|
-
md = md.replace(/[#]{3}(.+)/g, '<h3>$1</h3>');
|
|
108
|
-
md = md.replace(/[#]{2}(.+)/g, '<h2>$1</h2>');
|
|
109
|
-
md = md.replace(/[#]{1}(.+)/g, '<h1>$1</h1>');
|
|
110
|
-
|
|
111
|
-
//alt h
|
|
112
|
-
md = md.replace(/^(.+)\n=+/gm, '<h1>$1</h1>');
|
|
113
|
-
md = md.replace(/^(.+)\n-+/gm, '<h2>$1</h2>');
|
|
114
|
-
|
|
115
|
-
//images
|
|
116
|
-
md = md.replace(/!\[([^\]]+)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" />');
|
|
117
|
-
|
|
118
|
-
//links
|
|
119
|
-
md = md.replace(/[[]{1}([^\]]+)[\]]{1}[(]{1}([^)"]+)("(.+)")?[)]{1}/g, '<a href="$2" title="$4">$1</a>');
|
|
120
|
-
|
|
121
|
-
//font styles
|
|
122
|
-
md = md.replace(/[*_]{2}([^*_]+)[*_]{2}/g, '<b>$1</b>');
|
|
123
|
-
md = md.replace(/[*_]{1}([^*_]+)[*_]{1}/g, '<i>$1</i>');
|
|
124
|
-
md = md.replace(/[=]{2}([^=]+)[=]{2}/g, '<mark>$1</mark>');
|
|
125
|
-
md = md.replace(/[~]{2}([^~]+)[~]{2}/g, '<del>$1</del>');
|
|
87
|
+
}
|
|
126
88
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
md = md.replace(/[`]{1}([^`]+)[`]{1}/g, '<code>$1</code>');
|
|
133
|
-
|
|
134
|
-
//p
|
|
135
|
-
md = md.replace(/^\s*(\n)?(.+)/gm, function (m: string) {
|
|
136
|
-
return /<(\/)?(h\d|ul|ol|li|blockquote|pre|img)/.test(m) ? m : '<p>' + m + '</p>';
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
//strip p from pre
|
|
140
|
-
md = md.replace(/(<pre.+>)\s*\n<p>(.+)<\/p>/gm, '$1$2');
|
|
141
|
-
|
|
142
|
-
return md;
|
|
143
|
-
|
|
144
|
-
};
|
|
89
|
+
export function serialize(schema: any, content: any) {
|
|
90
|
+
const mdSerializer = new ProseMirrorMarkdownSerializer(
|
|
91
|
+
mdSerializerNodes,
|
|
92
|
+
mdSerializerMarks,
|
|
93
|
+
);
|
|
145
94
|
|
|
146
|
-
const serialize = (schema: any, content: any) => {
|
|
147
95
|
const proseMirrorDocument = schema.nodeFromJSON(content);
|
|
148
|
-
const serializer = new ProseMirrorMarkdownSerializer(
|
|
149
|
-
serializerNodes,
|
|
150
|
-
serializerMarks,
|
|
151
|
-
);
|
|
152
96
|
|
|
153
|
-
return
|
|
154
|
-
}
|
|
97
|
+
return mdSerializer.serialize(proseMirrorDocument, { tightLists: true });
|
|
98
|
+
}
|
|
155
99
|
|
|
156
|
-
|
|
100
|
+
export function deserialize(schema: any, content?: string) {
|
|
157
101
|
if (!content) return null;
|
|
158
|
-
const html =
|
|
102
|
+
const html = marked.parse(content);
|
|
159
103
|
|
|
160
104
|
if (!html) return null;
|
|
161
105
|
|
|
@@ -167,6 +111,5 @@ const deserialize = (schema: any, content: any) => {
|
|
|
167
111
|
|
|
168
112
|
const state = ProseMirrorDOMParser.fromSchema(schema).parse(body);
|
|
169
113
|
return state.toJSON();
|
|
170
|
-
}
|
|
114
|
+
}
|
|
171
115
|
|
|
172
|
-
export { serialize, deserialize };
|