import { DocsMarkdownEditor, editorTag } from '../models/editor-model';

export function getWebEditorAttributes(): {
	repo: string;
	org: string;
	path: string;
	branch: string;
} {
	const docsMarkdownEditor = document.getElementsByTagName(editorTag);
	if (docsMarkdownEditor?.length > 0) {
		const editorElement = docsMarkdownEditor[0] as DocsMarkdownEditor;
		const {
			gitHubAttributes: { repo, org, path, branch }
		} = editorElement;
		return { repo, org, path, branch };
	}
	return null;
}
