Skip to content

Commit

Permalink
Merge branch 'staging' into refactor/remove-editorContent
Browse files Browse the repository at this point in the history
  • Loading branch information
elbotho committed Feb 26, 2025
2 parents 7a595f6 + 53fac13 commit a1d4641
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 32 deletions.
16 changes: 15 additions & 1 deletion apps/web/src/components/auth/login-button-vidis.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { UiNodeInputAttributes } from '@ory/client'
import { type FormEvent } from 'react'
import { useRouter } from 'next/router'
import { useEffect, useRef, type FormEvent } from 'react'

import VidisLogo from '@/assets-webkit/img/auth/vidis-logo.svg'
import { cn } from '@/helper/cn'
Expand All @@ -15,10 +16,23 @@ export function LoginButtonVidis({
onSubmit,
disabled,
}: NodeProps) {
const router = useRouter()
const buttonRef = useRef<HTMLButtonElement | null>(null)

useEffect(() => {
if (!router.isReady) return

const { vidis_idp_hint } = router.query
if (vidis_idp_hint && buttonRef.current) {
buttonRef.current.click()
}
}, [router.isReady, router.query])

return (
<div className="-mb-8 mt-10">
<hr />
<button
ref={buttonRef}
className={cn(`
mt-10 w-full items-center border border-transparent px-[22px] py-2 text-center
text-lg font-bold shadow-menu transition-all hover:border-black focus-visible:border-black
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/serlo-editor-integration/serlo-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function SerloEditor({
isProductionEnvironment={isProduction}
initialState={initialState}
styleReset={false}
showUndoRedoButtons
extraSerloPlugins={extraSerloPlugins}
extraSerloRenderers={extraSerloRenderers}
onChange={(state) => {
Expand Down
8 changes: 6 additions & 2 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ See below for the current API specification.

- **`onChange` (optional)**: To receive state changes of the editor and persist the content into your own infrastructure, use the `onChange` callback of the `SerloEditor` component. It's a function with the signature `(state: StorageFormat) => void`.

- **`language` (optional)**: The default language is `de`.
- **`language` (optional)**: The default language is `de`. Currently the only other option is `en`.

- **`editorVariant`**: The variant (integration) of the Serlo editor. For example `edusharing` or `serlo-org`. The editor adds this information to the `StorageFormat` that will be saved. Might become useful for example if we need to apply a migration only to one variant of the editor.

- **`_testingSecret` (optional)**: A key used by integrations for uploading files into the serlo-editor-testing bucket, while testing the Editor. **To be deprecated once a long term solution is agreed on.**
- **`isProductionEnvironment`(optional)**: Tell the editor if it runs in an production environment. In all other environments there will be a warning and experimental features might be active.

- **`showUndoRedoButtons`(optional)**: Set to true to show the default undo/redo buttons. (Defaults to false).

- **`_testingSecret` (optional)**: A key used by integrations for uploading files into the serlo-editor-testing bucket, while testing the Editor. **Deprecated**

- **`_ltik` (optional)**: Required by the custom plugin `edusharingAsset` only used in `serlo-editor-for-edusharing`. **To be removed once a better solution is found or the plugin is removed.**

Expand Down
12 changes: 5 additions & 7 deletions packages/editor/src/core/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ export function Editor(props: EditorProps) {
<ReduxProvider store={store}>
<DndWrapper>
<HotkeysProvider initiallyActiveScopes={['global']}>
{props.showUndoRedoButtons ? <EditorToolbar /> : null}
{/* only on serlo for now */}
{isSerlo && !isSerloEditorPreviewPage ? (
<>
<EditorToolbar />
<LocalStorageNotice
useStored={useStored}
setUseStored={setUseStored}
/>
</>
<LocalStorageNotice
useStored={useStored}
setUseStored={setUseStored}
/>
) : null}
{/* For non serlo environments, we need to render the toaster
(already gets rendered in the web project) */}
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface EditorProps {
state?: unknown
}
onChange: OnEditorChange
showUndoRedoButtons?: boolean
}

export type EditorRenderProps = ReactNode | ((editor: BaseEditor) => ReactNode)
Expand Down
26 changes: 4 additions & 22 deletions packages/editor/src/editor-integration/create-plugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ export interface ExtraSerloPlugins {
image: EditorPlugin<ImagePluginState, ImagePluginConfig>
}

function isLocalOrDevOrStaging() {
if (process.env.NEXT_PUBLIC_ENV === 'staging') return true

if (typeof window === 'undefined') return false
const host = window.location.hostname

return (
process.env.NODE_ENV === 'development' ||
host === 'editor.serlo.dev' ||
host === 'editor.serlo-staging.dev' ||
host === 'localhost'
)
}

export function createPlugins(
plugins: (EditorPluginType | TemplatePluginType)[],
testingSecret?: string | null,
Expand Down Expand Up @@ -160,14 +146,10 @@ export function createPlugins(
type: EditorPluginType.DropzoneImage,
plugin: createDropzoneImagePlugin(),
},
...(isLocalOrDevOrStaging()
? [
{
type: EditorPluginType.InteractiveVideo,
plugin: interactiveVideoPlugin,
},
]
: []),
{
type: EditorPluginType.InteractiveVideo,
plugin: interactiveVideoPlugin,
},

// Special plugins, never visible in suggestions
// ===================================================
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/package/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export interface SerloEditorProps {
isProductionEnvironment?: boolean
userId?: string
styleReset?: boolean
/** Shows default Undo/Redo UI. Defaults to false for now */
showUndoRedoButtons?: boolean
/** @deprecated Please do not use for new setups */
_testingSecret?: string | null
_ltik?: string
/** @deprecated Only temporarily allowed for serlo.org. */
Expand All @@ -62,6 +65,7 @@ export function SerloEditor(props: SerloEditorProps) {
isProductionEnvironment,
userId,
styleReset,
showUndoRedoButtons,
_testingSecret,
_ltik,
extraSerloPlugins,
Expand Down Expand Up @@ -107,6 +111,7 @@ export function SerloEditor(props: SerloEditorProps) {
<Editor
initialState={migratedState.document}
onChange={handleDocumentChange}
showUndoRedoButtons={showUndoRedoButtons}
>
{children}
</Editor>
Expand Down

0 comments on commit a1d4641

Please sign in to comment.