-
Notifications
You must be signed in to change notification settings - Fork 115
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
1 parent
e243564
commit a657cf8
Showing
133 changed files
with
7,367 additions
and
47 deletions.
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
90 changes: 90 additions & 0 deletions
90
apps/dashboard/src/lib/components/TextEditor/TinymceSvelte/Utils.ts
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,90 @@ | ||
const validEvents = [ | ||
'Activate', | ||
'AddUndo', | ||
'BeforeAddUndo', | ||
'BeforeExecCommand', | ||
'BeforeGetContent', | ||
'BeforeRenderUI', | ||
'BeforeSetContent', | ||
'BeforePaste', | ||
'Blur', | ||
'Change', | ||
'ClearUndos', | ||
'Click', | ||
'ContextMenu', | ||
'Copy', | ||
'Cut', | ||
'Dblclick', | ||
'Deactivate', | ||
'Dirty', | ||
'Drag', | ||
'DragDrop', | ||
'DragEnd', | ||
'DragGesture', | ||
'DragOver', | ||
'Drop', | ||
'ExecCommand', | ||
'Focus', | ||
'FocusIn', | ||
'FocusOut', | ||
'GetContent', | ||
'Hide', | ||
'Init', | ||
'KeyDown', | ||
'KeyPress', | ||
'KeyUp', | ||
'LoadContent', | ||
'MouseDown', | ||
'MouseEnter', | ||
'MouseLeave', | ||
'MouseMove', | ||
'MouseOut', | ||
'MouseOver', | ||
'MouseUp', | ||
'NodeChange', | ||
'ObjectResizeStart', | ||
'ObjectResized', | ||
'ObjectSelected', | ||
'Paste', | ||
'PostProcess', | ||
'PostRender', | ||
'PreProcess', | ||
'ProgressState', | ||
'Redo', | ||
'Remove', | ||
'Reset', | ||
'ResizeEditor', | ||
'SaveContent', | ||
'SelectionChange', | ||
'SetAttrib', | ||
'SetContent', | ||
'Show', | ||
'Submit', | ||
'Undo', | ||
'VisualAid' | ||
]; | ||
|
||
const bindHandlers = (editor, dispatch) => { | ||
validEvents.forEach((eventName) => { | ||
editor.on(eventName, (e) => { | ||
dispatch(eventName.toLowerCase(), { | ||
eventName, | ||
event: e, | ||
editor | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
const injectTiny = (doc, url, cb) => { | ||
const script = doc.createElement('script'); | ||
script.referrerPolicy = 'origin'; | ||
script.type = 'application/javascript'; | ||
script.src = url; | ||
script.onload = cb; | ||
if (doc.head) { | ||
doc.head.appendChild(script); | ||
} | ||
}; | ||
|
||
export { bindHandlers, injectTiny }; |
160 changes: 160 additions & 0 deletions
160
apps/dashboard/src/lib/components/TextEditor/TinymceSvelte/index.svelte
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,160 @@ | ||
<script lang="ts" context="module"> | ||
const uuid = (prefix: string): string => { | ||
return prefix + '_' + Math.floor(Math.random() * 1000000000) + String(Date.now()); | ||
}; | ||
const createScriptLoader = () => { | ||
let state: { | ||
listeners: { (): void }[]; | ||
scriptId: string; | ||
scriptLoaded: boolean; | ||
injected: boolean; | ||
} = { | ||
listeners: [], | ||
scriptId: uuid('tiny-script'), | ||
scriptLoaded: false, | ||
injected: false | ||
}; | ||
const injectScript = (scriptId: string, doc: Document, url: string, cb: () => void) => { | ||
state.injected = true; | ||
const script = doc.createElement('script'); | ||
script.referrerPolicy = 'origin'; | ||
script.type = 'application/javascript'; | ||
script.src = url; | ||
script.onload = () => { | ||
cb(); | ||
}; | ||
if (doc.head) doc.head.appendChild(script); | ||
}; | ||
const load = (doc: Document, url: string, callback: () => void) => { | ||
if (state.scriptLoaded) { | ||
callback(); | ||
} else { | ||
state.listeners.push(callback); | ||
// check we can access doc | ||
if (!state.injected) { | ||
injectScript(state.scriptId, doc, url, () => { | ||
state.listeners.forEach((fn) => fn()); | ||
state.scriptLoaded = true; | ||
}); | ||
} | ||
} | ||
}; | ||
return { | ||
load | ||
}; | ||
}; | ||
let scriptLoader = createScriptLoader(); | ||
</script> | ||
|
||
<script lang="ts"> | ||
import { onMount, createEventDispatcher, onDestroy } from 'svelte'; | ||
import { bindHandlers } from './Utils'; | ||
export let id: string = uuid('tinymce-svelte'); // default values | ||
export let inline: boolean | undefined = undefined; | ||
export let disabled: boolean = false; | ||
// export let apiKey: string = 'no-api-key'; | ||
// export let channel: string = '6'; | ||
// export let scriptSrc: string | undefined = undefined; | ||
export let conf: any = {}; | ||
export let modelEvents: string = 'change input undo redo'; | ||
export let value: string = ''; | ||
export let text: string = ''; | ||
export let cssClass: string = 'tinymce-wrapper'; | ||
let container: HTMLElement; | ||
let element: HTMLElement; | ||
let editorRef: any; | ||
let lastVal = value; | ||
let disablindCache = disabled; | ||
const dispatch = createEventDispatcher(); | ||
$: { | ||
if (editorRef && lastVal !== value) { | ||
editorRef.setContent(value); | ||
text = editorRef.getContent({ format: 'text' }); | ||
} | ||
if (editorRef && disabled !== disablindCache) { | ||
disablindCache = disabled; | ||
if (typeof editorRef.mode?.set === 'function') { | ||
editorRef.mode.set(disabled ? 'readonly' : 'design'); | ||
} else { | ||
editorRef.setMode(disabled ? 'readonly' : 'design'); | ||
} | ||
} | ||
} | ||
const getTinymce = () => { | ||
const getSink = () => { | ||
return typeof window !== 'undefined' ? window : global; | ||
}; | ||
const sink = getSink(); | ||
return sink && sink.tinymce ? sink.tinymce : null; | ||
}; | ||
const init = () => { | ||
// | ||
const finalInit = { | ||
...conf, | ||
target: element, | ||
inline: inline !== undefined ? inline : conf.inline !== undefined ? conf.inline : false, | ||
readonly: disabled, | ||
setup: (editor: any) => { | ||
editorRef = editor; | ||
editor.on('init', () => { | ||
editor.setContent(value); | ||
// bind model events | ||
editor.on(modelEvents, () => { | ||
lastVal = editor.getContent(); | ||
if (lastVal !== value) { | ||
value = lastVal; | ||
text = editor.getContent({ format: 'text' }); | ||
} | ||
}); | ||
}); | ||
bindHandlers(editor, dispatch); | ||
if (typeof conf.setup === 'function') { | ||
conf.setup(editor); | ||
} | ||
} | ||
}; | ||
element.style.visibility = ''; | ||
getTinymce().init(finalInit); | ||
}; | ||
onMount(() => { | ||
if (getTinymce() !== null) { | ||
init(); | ||
} else { | ||
const script = window.location.origin + '/js/tinymce/tinymce.min.js'; | ||
scriptLoader.load(container.ownerDocument, script, () => { | ||
init(); | ||
}); | ||
} | ||
}); | ||
onDestroy(() => { | ||
if (editorRef) { | ||
getTinymce()?.remove(editorRef); | ||
} | ||
}); | ||
</script> | ||
|
||
<div bind:this={container} class={cssClass}> | ||
{#if inline} | ||
<div {id} bind:this={element}></div> | ||
{:else} | ||
<textarea {id} bind:this={element} style="visibility:hidden"></textarea> | ||
{/if} | ||
</div> | ||
|
||
<style> | ||
:global(.tox .tox-promotion) { | ||
display: none !important; | ||
} | ||
</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
5 changes: 0 additions & 5 deletions
5
apps/dashboard/src/routes/courses/[id]/lessons/+layout.svelte
This file was deleted.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 @@ | ||
This is where language files should be placed. | ||
|
||
Please DO NOT translate these directly, use this service instead: https://crowdin.com/project/tinymce |
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,6 @@ | ||
# Software License Agreement | ||
|
||
**TinyMCE** – [<https://github.com/tinymce/tinymce>](https://github.com/tinymce/tinymce) | ||
Copyright (c) 2024, Ephox Corporation DBA Tiny Technologies, Inc. | ||
|
||
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.