-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ModulePaneSource.svelte
124 lines (100 loc) · 3.23 KB
/
ModulePaneSource.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<script>
import { OLSKLocalized } from 'OLSKInternational';
import EditorMarkdown from './ModuleEditorMarkdown.svelte'
import EditorHTML from './ModuleEditorHTML.svelte'
import EditorRTF from './ModuleEditorRTF.svelte'
const RCSIdomaticLogic = window.RCSIdomaticLogic;
let sourceData = window.OLSKPublicConstants('RCSIdiomaticConvertSourceSampleData')
export let outputData
let sourceFormats = RCSIdomaticLogic.RCSIdiomaticLogicFormatsArray()
let selectedFormat = sourceFormats[0]
let convertFunctionMap = RCSIdomaticLogic.RCSIdiomaticLogicFormatsArray().reduce(function (coll, sourceFormat) {
return (coll[sourceFormat] = RCSIdomaticLogic.RCSIdiomaticLogicFormatsArray().reduce(function (coll, destinationFormat) {
return (coll[destinationFormat] = (function () {
if (destinationFormat === RCSIdomaticLogic.RCSIdiomaticLogicFormatMarkdown()) {
return RCSIdomaticLogic.RCSIdiomaticLogicMarkdownForHTML
}
if (sourceFormat === RCSIdomaticLogic.RCSIdiomaticLogicFormatMarkdown()) {
return RCSIdomaticLogic.RCSIdiomaticLogicHTMLForMarkdown
}
return function (e) {
return e
}
})()) && coll;
}, {})) && coll;
}, {})
let _selectedFormat
let selectedFormatDidChange = function (inputData) {
if (_selectedFormat && _selectedFormat !== inputData) {
sourceData = convertFunctionMap[_selectedFormat][inputData](sourceData)
}
_selectedFormat = inputData
}
$: selectedFormatDidChange(selectedFormat)
let sourceDataDidChange = function (inputData) {
outputData = convertFunctionMap[selectedFormat][RCSIdomaticLogic.RCSIdiomaticLogicFormatHTML()](inputData)
}
$: sourceDataDidChange(sourceData)
</script>
<div class="Container ConvertPane">
<div class="PaneToolbar">
{#each sourceFormats as e, i}
<input type="radio" bind:group="{ selectedFormat }" value="{ e }" accesskey="{ i + 1 }" id="SourceFormat{ e }">
<label for="SourceFormat{ e }">
{#if e === RCSIdomaticLogic.RCSIdiomaticLogicFormatMarkdown()}
{ OLSKLocalized('RCSIdiomaticConvertToolbarButtonOptionMarkdownText') }
{/if}
{#if e === RCSIdomaticLogic.RCSIdiomaticLogicFormatHTML()}
{ OLSKLocalized('RCSIdiomaticConvertToolbarButtonOptionHTMLText') }
{/if}
{#if e === RCSIdomaticLogic.RCSIdiomaticLogicFormatRTF()}
{ OLSKLocalized('RCSIdiomaticConvertToolbarButtonOptionRTFText') }
{/if}
</label>
{/each}
</div>
{#if selectedFormat === RCSIdomaticLogic.RCSIdiomaticLogicFormatMarkdown()}
<EditorMarkdown bind:editorValue="{sourceData}" />
{/if}
{#if selectedFormat === RCSIdomaticLogic.RCSIdiomaticLogicFormatHTML()}
<EditorHTML bind:editorValue="{sourceData}" />
{/if}
{#if selectedFormat === RCSIdomaticLogic.RCSIdiomaticLogicFormatRTF()}
<EditorRTF bind:editorValue="{sourceData}" />
{/if}
</div>
<style>
.Container {
/* ContainerFlexbox:Parent */
display: flex;
flex-direction: column;
}
.PaneToolbar {
background: #d9d9d9;
}
.PaneToolbar input {
display: none;
}
.PaneToolbar input:checked + label {
background: #cccccc;
}
.PaneToolbar label {
cursor: pointer;
}
:global(.EditorContainer) {
/* ContainerFlexbox:Child */
flex-grow: 1;
}
:global(.CodeMirror) {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
/* override defaults */
height: 100%;
}
:global(.CodeMirror) pre {
word-break: break-all;
}
</style>