text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|>import {Component} from './component'; export class TriLayout extends Component { private container!: HTMLElement; private tabs!: HTMLElement[]; private sidebarScrollContainers!: HTMLElement[]; private lastLayoutType = 'none'; private onDestroy: (()=>void)|null = null; private sc...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>, 'click', this.selectUser.bind(this)); } selectUser(event, userEl) { event.preventDefault(); this.input.value = userEl.getAttribute('data-id'); this.userInfoContainer.innerHTML = userEl.innerHTML; this.input.dispatchEvent(new Event('change', {bubbles: true})); ...
fim
BookStackApp/BookStack
javascript
<|fim_suffix|>checkboxes) { if (checkbox !== this.allCheckbox) { checkbox.checked = false; } } } } <|fim_prefix|>/** * Webhook Events * Manages dynamic selection control in the webhook form interface. */ import {Component} from './component'; export class Webhook...
fim
BookStackApp/BookStack
javascript
<|fim_prefix|>import {buildForEditor as buildEditorConfig} from '../wysiwyg-tinymce/config'; import {Component} from './component'; export class WysiwygEditorTinymce extends Component { setup() { this.elem = this.$el; this.tinyMceConfig = buildEditorConfig({ language: this.$opts.langu...
fim
BookStackApp/BookStack
javascript
<|fim_suffix|> = false; this.input.form.addEventListener('submit', event => { if (!this.editor) { return; } if (!handlingFormSubmit) { event.preventDefault(); handlingFormSubmit = true; this.editor.getContentAsH...
fim
BookStackApp/BookStack
javascript
<|fim_suffix|>torInstance(container as HTMLElement, this.elem.value, { darkMode: document.documentElement.classList.contains('dark-mode'), textDirection: this.textDirection, translations: (window as unknown as Record<string, Object>).editor_translations, }); this.wys...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>declare mod<|fim_suffix|>}<|fim_middle|>ule '*.svg' { const content: string; export default content; <|endoftext|>
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>ort('./code/index.mjs'));<|fim_prefix|>import {ComponentStore} from "./services/components"; import {EventManager} from "./services/events"; import {HttpManager} from "./services/http"; import {Translator} from "./services/translations"; declare global { const __DEV__: boolean; interface Window ...
fim
BookStackApp/BookStack
typescript
import * as DrawIO from '../services/drawio'; import {MarkdownEditor} from "./index.mjs"; import {EntitySelectorPopup, ImageManager} from "../components"; import {MarkdownEditorInputSelection} from "./inputs/interface"; interface ImageManagerImage { id: number; name: string; thumbs: { display: string; }; ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>ewUpdate) { if (v.docChanged) { onChange(); } } const cm = Code.markdownEditor( input, onViewUpdate, domEventHandlers, shortcutsToKeyBindings(shortcuts), ); // Add editor view to the window for easy access/debugging. // Not ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {MarkdownEditor} from "./index.mjs"; export interface HtmlOrMarkdown { html: string; markdown: string; } function getContentToInsert({html, markdown}: {html: string, markdown: string}): string <|fim_suffix|>kdown = getContentToInsert(eventContent); editor.actions.appendContent(mar...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import { patchDomFromHtmlString } from '../services/vdom'; import {MarkdownEditor} from "./index.mjs"; export class Display { protected editor: MarkdownEditor; protected container: HTMLIFrameElement; protected doc: Document | null = null; protected lastDisplayClick: number = 0; const...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> drop: (event: DragEvent) => { if (!event.dataTransfer) { return; } const templateId = event.dataTransfer.getData('bookstack/template'); if (templateId) { event.preventDefault(); editor.actions.insertTemplate...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>ForLineContaining(text: string): MarkdownEditorInputSelection | null { const docText = this.cm.state.doc; let lineCount = 1; let scrollToLine = -1; for (const line of docText.iterLines()) { if (line.includes(text)) { scrollToLine = lineCount; ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|> export interface MarkdownEditorInputSelection { from: number; to: number; } export interface MarkdownEditorInput { /** * Focus on the editor. */ focus(): void; /** * Get the current selection range. */ getSelection(): MarkdownEditorInputSelection; /** ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>font = inputStyles.font; el.style.lineHeight = inputStyles.lineHeight; el.style.padding = '0px'; el.style.display = 'inline-block'; el.style.visibility = 'hidden'; el.style.position = 'absolute'; el.style.whiteSpace = 'pre'; this.input.after(el); ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> render(markdown: string): string { return this.renderer.render(markdown); } } <|fim_prefix|>im<|fim_middle|>port MarkdownIt from 'markdown-it'; // @ts-ignore import mdTasksLists from 'markdown-it-task-lists'; export class Markdown { protected renderer: MarkdownIt; constructor() { ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>type ChangeListener = (value: boolean|number) => void; export class Settings { protected changeListeners: Record<string, ChangeListener[]> = {}; protected settingMap: Record<string, boolean|number> = { scrollSync: true, showPreview: true, editorWidth: 50, plainEdi...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>or.actions.replaceLineStart('###'); shortcuts['Mod-3'] = () => editor.actions.replaceLineStart('####'); shortcuts['Mod-4'] = () => editor.actions.replaceLineStart('#####'); shortcuts['Mod-5'] = () => editor.actions.replaceLineStart(''); shortcuts['Mod-d'] = () => editor.actions.replaceLine...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> `turtle`, }, ]; for (const testCase of cases) { const output = $trans.choice(testCase.translation, testCase.count, {}); expect(output).toEqual(testCase.expected); } }); test('it replaces as expected', ()...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Used in the function below to store references of clean-up functions. * Used to ensure only one transitionend function exists at any time. */ const animateStylesCleanupMap: WeakMap<object, any> = new WeakMap(); /** * Animate the css styles of an element using FLIP animation techniques. * Style...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>export class Clipboard { protected data: DataTransfer; constructor(clipboardData: DataTransfer) { this.data = clipboardData; } /** * Check if the clipboard has any items. */ hasItems(): boolean { return Boolean(this.data) && Boolean(this.data.types) && this...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {kebabToCamel, camelToKebab} from './text'; import {Component} from "../components/component"; /** * Parse out the element references within the given element * for the given component name. */ function parseRefs(name: string, element: HTMLElement): {refs: Record<string, HTMLElement>, many<...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>onst date = new Date(timestamp * 1000); const hours = date.getHours(); const mins = date.getMinutes(); return `${(hours > 9 ? '' : '0') + hours}:${(mins > 9 ? '' : '0') + mins}`; } <|fim_prefix|>export function getCurrentDay(): string { const date = new Date(); c<|fim_middle|>onst mont...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>rom HTML'); } return firstChild; } /** * For the given node and offset, return an adjusted offset that's relative to the given parent element. */ export function normalizeNodeTextOffsetToParent(node: Node, offset: number, parentElement: HTMLElement): number { if (!parentElement.contains(no...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>RL(drawioUrl)).origin; } export async function upload(imageData: string, pageUploadedToId: string): Promise<{id: number, url: string}> { const data = { image: imageData, uploaded_to: pageUploadedToId, }; const resp = await window.$http.post(window.baseUrl('/images/drawio'), da...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Service for helping manage common dual-list scenarios. * (Shelf book manager, sort set manager). */ type ListActionsSet = Record<string, ((item: HTMLElement) => void)>; export function buildListActions( availableList: HTMLElement, configuredList: HTMLElement, ): ListActionsSet { ret...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {HttpError} from "./http"; type Listener = (data: any) => void; export class EventManager { protected listeners: Record<string, Listener[]> = {}; protected stack: {name: string, data: {}}[] = []; /** * Emit a custom event for any handlers to pick-up. */ emit(eventName: ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>type ResponseData = Record<any, any>|string; type RequestOptions = { params?: Record<string, string>, headers?: Record<string, string> }; type FormattedResponse = { headers: Headers; original: Response; data: ResponseData; redirected: boolean; status: number; statusText: ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {isHTMLElement} from "./dom"; type OptionalKeyEventHandler = ((e: KeyboardEvent) => any)|null; /** * Handle common keyboard navigation events within a given container. */ export class KeyboardNavigationHandler { protected containers: HTMLElement[]; protected onEscape: OptionalKeyEventH...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>expor<|fim_suffix|> <|fim_middle|>t {get, set, del} from 'idb-keyval';<|endoftext|>
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>t function camelToKebab(camelStr: string): string { return camelStr.replace(/[A-Z]/g, (str, offset) => (offset > 0 ? '-' : '') + str.toLowerCase()); } <|fim_prefix|>/** * Convert a kebab-case string to camelCase */ export function kebabToCamel(kebab: string): string { const ucFirst = (word: stri...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>t match of replaceMatches) { const key = match.substring(1); if (typeof replacements[key] === 'undefined') { continue; } updatedString = updatedString.replace(match, replacements[key]); } return updatedString; } } <|fim_...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Returns a function, that, as long as it continues to be invoked, will not * be triggered. The function will be called after it stops being called for * N milliseconds. If `immediate` is passed, trigger the function on the * leading edge, instead of the trailing. * @attribution https://davidwals...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import { init, attributesModule, datasetModule, toVNode, } from 'snabbdom'; import {VN<|fim_suffix|>ttributesModule, datasetModule, ]); return patcher; } export function patchDomFromHtmlString(domTarget: Element, html: string): void { const contentDom = document.creat...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>or: context.editor}; }<|fim_prefix|>import {createTestContext} from "lexical/__tests__/utils"; import {EditorApi} from "../api"; import {EditorUiContext} from "../../ui/framework/core"; import {LexicalEditor} from "lexical"; /** * Create an instance of the EditorApi and EditorUiContext. */ export func...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {createEditorApiInstance} from "./api-test-utils"; import {$createParagraphNode, $createTextNode, $getRoot, IS_BOLD, LexicalEditor} from "lexical"; import {expectNodeShapeToMatch} from "lexical/__tests__/utils"; describe('Editor API: Content Module', () => { describe('insertHtml()', () => { ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {createEditorApiInstance} from "./api-test-utils"; import {EditorApiButton, EditorApiToolbar, EditorApiToolbarSection} from "../ui"; import {getMainEditorFullToolbar} from "../../ui/defaults/toolbars"; import {EditorContainerUiElement} from "../../ui/framework/core"; import {EditorOverflowContainer...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {EditorApiUiModule} from "./ui"; impor<|fim_suffix|> {EditorUiContext} from "../ui/framework/core"; import {EditorApiContentModule} from "./content"; export class EditorApi { public ui: EditorApiUiModule; public content: EditorApiContentModule; constructor(context: EditorUiContext) {...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> const validPositions = ['start', 'end', 'selection']; if (!validPositions.includes(position)) { throw new Error(`Invalid position: ${position}. Valid positions are: ${validPositions.join(', ')}`); } if (position === 'start') { prependHtmlToEditor(th...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> constructor(toolbar: EditorContainerUiElement) { this.#toolbar = toolbar; } getSections(): EditorApiToolbarSection[] { const sections = this.#toolbar.getChildren(); return sections.filter(section => { return section instanceof EditorOverflowContainer; ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>itor(this.context.editor); } remove() { this.context.manager.teardown(); this.context.containerDOM.remove(); if (this.editorListenerTeardown) { this.editorListenerTeardown(); } } protected startListeningToChanges(): void { if (this.edit...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>lNode classes registered on the editor. * Normally, you'd get an Array of BaseSerialized nodes from {@link $generateJSONFromSelectedNodes} * * @param serializedNodes an Array of objects conforming to the BaseSerializedNode interface. * @returns an Array of Lexical Node objects. */ export function $ge...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** *<|fim_suffix|>e in the root directory of this source tree. * */ export { $generateJSONFromSelectedNodes, $generateNodesFromSerializedNodes, $getClipboardDataFromSelection, $getHtmlContent, $getLexicalContent, $insertDataTransferForPlainText, $insertDataTransferForRichText, $insert...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type { BaseSelection, LexicalCommand, LexicalNode, TextFormatType, } from 'lexical'; export typ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type { TextDetailType, TextFormatType, TextModeType, } from './nodes/LexicalTextNode'<|fim_suffix|...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {EditorState, SerializedEditorState} from './LexicalEditorState'; import type { DOMConversion, ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>ode} from './LexicalNode'; import type {BaseSelection} from './LexicalSelection'; import type {SerializedElementNode} from './nodes/LexicalElementNode'; import type {SerializedRootNode} from './nodes/LexicalRootNode'; import invariant from 'lexical/shared/invariant'; import {readEditorState} from './Lex...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>ormat = lastFormat; selection.style = lastStyle; } else { if (anchor.type === 'text') { invariant( $isTextNode(anchorNode), 'Point.getNode() must return TextNode when type is text', ); selection.format = anchorNode...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {ElementNode} from '.'; import type {LexicalEditor} from './LexicalEditor'; import type {EditorState} from './Lex...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> } } parentDOM.removeChild(addedDOM); } } const removedDOMs = mutation.removedNodes; const removedDOMsLength = removedDOMs.length; if (removedDOMsLength > 0) { let unremovedBRs = 0; ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>xt(anchorOffset?: number, focusOffset?: number): RangeSelection { errorOnReadOnly(); const nextSibling = this.getNextSibling(); const parent = this.getParentOrThrow(); if (nextSibling === null) { return parent.select(); } if ($isElementNode(nextSibling)) { return nextSi...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {RangeSelection, TextNode} from '.'; import type {PointType} from './LexicalSelection'; import {$i...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>lement: ElementNode, nextElement: ElementNode, dom: HTMLElement, ): void { subTreeTextFormat = null; subTreeTextStyle = ''; $reconcileChildren(prevElement, nextElement, dom); reconcileParagraphFormat(nextElement); reconcileParagraphStyle(nextElement); } function createChildrenArray( eleme...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {LexicalEditor} from './LexicalEditor'; import type {EditorState} from './LexicalEditorState'; impo...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {SerializedEditorState} from './LexicalEditorState'; import type {LexicalNode, SerializedLexicalNode} from './Lex...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>ction scrollIntoViewIfNeeded( editor: LexicalEditor, selectionRect: DOMRect, rootElement: HTMLElement, ): void { const doc = rootElement.ownerDocument; const defaultView = doc.defaultView; if (defaultView === null) { return; } let {top: currentTop, bottom: currentBottom} = selectionRe...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import {$insertDataTransferForRichText} from '@lexical/clipboard'; import { $createParagraphNode, $getRoot,...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import {$generateHtmlFromNodes, $generateNodesFromDOM} from '@lexical/html'; import { $createTableCellNode, ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { $createParagraphNode, $createTextNode, $getEditor, $getRoot, ParagraphNode, TextNode, } fr...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>phNode(); block2 = new ParagraphNode(); block3 = new ParagraphNode(); text1 = new TextNode('A'); text2 = new TextNode('B'); text3 = new TextNode('C'); block1.append(text1); block2.append(text2); block3.append(text3); ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { $createParagraphNode, $createTextNode, $getRoot, RangeSelection, } from 'lexical'; import {$n...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import {$createLinkNode, $isLinkNode} from '@lexical/link'; import { $createParagraphNode, $createTextNode,...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import {$createLinkNode} from '@lexical/link'; import {$createListItemNode, $createListNode} from '@lexical/list'; import {$c...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { $getNodeByKey, $getRoot, $isTokenOrSegmented, $nodesOfType, emptyFunction, generateRandomKey, getCache...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import {createHeadlessEditor} from '@lexical/headless'; import {AutoLinkNode, LinkNode} from '@lexical/link'; import {ListIte...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ export type {PasteCommandType} from './LexicalCommands'; export type { CommandListener, CommandListenerPrio...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the<|fim_suffix|>tNode} from './LexicalElementNode'; // TODO: Cleanup ArtificialNode__DO_NOT_USE #5966 export class ArtificialNode__DO_NOT_USE extends ElementNode { static getType(): string { return '...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> const self = this.getWritable(); self.__id = id; } getId(): string { const self = this.getLatest(); return self.__id; } setAlignment(alignment: CommonBlockAlignment) { const self = this.getWritable(); self.__alignment = alignment; } ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the r<|fim_suffix|>ed, ): node is DecoratorNode<T> { return node instanceof DecoratorNode; } <|fim_middle|>oot directory of this source tree. * */ import ...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {NodeKey, SerializedLexicalNode} from '../LexicalNode'; import type { BaseSelection, PointType, RangeSelect...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {KlassConstructor} from '../LexicalEditor'; import type { DOMConversionMap, DOMConversionOutput, NodeKey, ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>).trim() === '') ) { const nextSibling = this.getNextSibling(); if (nextSibling !== null) { this.selectNext(); this.remove(); return true; } const prevSibling = this.getPreviousSibling(); if (prevSibling !== null) { this.selectPrevious(); ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>ort function $createRootNode(): RootNode { return new RootNode(); } export function $isRootNode( node: RootNode | LexicalNode | null | undefined, ): node is RootNode { return node instanceof RootNode; } <|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code i...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {DOMConversionMap, NodeKey} from '../LexicalNode'; import invariant from 'lexical/shared/invariant...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>: null}; } if (textContent[0] === ' ') { // Traverse backward while in the same line. If content contains new line or tab -> pontential // delete, other elements can borrow from this one. Deletion depends on whether it's also the // last space (see next condition: textContent[textContent.l...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>e next)', start: 0, }, { deleteCount: 4, deleteOnly: true, expectedSelection: () => { return { anchor: { key: block.__key, offset: 0, type: 'element', }, focus: { ...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { $createParagraphNode, $createTextNode, $getNodeByKey, $getRoot, $isElementNode, } from 'lexi...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>nt()).toEqual('\n'); }); }); test('LineBreakNode.exportJSON() should return and object conforming to the expected schema', async () => { const {editor} = testEnv; await editor.update(() => { const node = $createLineBreakNode(); // If you broke this test, you ch...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { $createParagraphNode, $getRoot, $isParagraphNode, ParagraphNode, RangeSelection, } from 'lexical'; import...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { $createParagraphNode, $createTextNode, $getRoot, $getSelection, $isRangeSelection, $isRoot...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>style="color: rgb(0, 0, 0);" data-lexical-text="true">world</span></p><p><span style="color: rgb(0, 0, 0);" data-lexical-text="true">Hello</span><span data-lexical-text="true">\t</span><span style="color: rgb(0, 0, 0);" data-lexical-text="true">world</span></p>', ); }); test('can type betwe...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|><code spellcheck="false"><em class="my-code-class my-italic-class">My text node</em></code>', ], [ 'code + underline + strikethrough', IS_CODE | IS_UNDERLINE | IS_STRIKETHROUGH, 'My text node', '<code spellcheck="false"><span class="my-underline-strikethrough-cl...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import {sizeToPixels} from "../../../utils/dom"; import {SerializedCommonBlockNode} from "lexical/nodes/CommonBlockNode"; export type CommonBlockAlignment = 'left' | 'right' | 'center' | 'justify' | ''; const validAlignments: CommonBlockAlignment[] = ['left', 'right', 'center', 'justify']; type EditorNo...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>s special-cased // in flow itself, so we can't name it anything else. export default function invariant( cond?: boolean, message?: string, ...args: string[] ): asserts cond { if (cond) { return; } throw new Error( args.reduce((msg, arg) => msg.replace('%s', String(arg)), message || ''...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ export const CAN_USE_DOM: boolean = typeof window !== 'undefined' && typeof window.document !== 'undefined'...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ export default function caretFromPoint( x: number, y: number, ): null | { offset: number; node: Node; } { if (typeo...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import {CAN_USE_DOM} from 'lexical/shared/canUseDOM'; declare global { interface Document { documentMode...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ // invariant(condition, message) will refine types based on "condition", and /<|fim_suffix|> if "condition" is ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> } } } return rval; } <|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ export default function normalizeClassNames( ...classNames: Arr...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> let left = 0; // number of same characters counting from left let right = 0; // number of same characters counting from right // Iterate left to the right until we find a changed character // First iteration considers the current cursor position while ( left < aLength && left < bLength &&...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|> } <|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ export default function warnOnlyOnce(message: string) { if (!__DEV__) { return; } le...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>tion setupDom() { const jsdom = new JSDOM(); const _window = global.window; const _document = global.document; // @ts-expect-error global.window = jsdom.window; global.document = jsdom.window.document; return () => { global.window = _window; global.document = _do...
fim
BookStackApp/BookStack
typescript
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {CreateEditorArgs, LexicalEditor} from 'lexical'; import {createEditor} from 'lexical'; /** * Generates a head...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>e); return true; }, COMMAND_PRIORITY_EDITOR, ), editor.registerCommand( CLEAR_EDITOR_COMMAND, () => { clearHistory(historyState); return false; }, COMMAND_PRIORITY_EDITOR, ), editor.registerCommand( CLEAR_HISTORY_COMMAND, ...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>parser.parseFromString( rightAlignedParagraphInDiv, 'text/html', ); const nodes = $generateNodesFromDOM(editor, dom); root.append(...nodes); }, {discrete: true}, ); let html = ''; editor.update(() => { html = $generateHtmlFromNode...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type { BaseSelection, DOMChildConversion, DOMConversion, DOMConversionFn, LexicalEditor, Lex...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>import { DecoratorNode, DOMConversion, DOMConversionMap, DOMConversionOutput, type EditorConfig, LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from "lexical"; import {EditorDecoratorAdapter} from "../../ui/framework/decorator"; export type SerializedMentionNode =...
fim
BookStackApp/BookStack
typescript
<|fim_prefix|>/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { $createAutoLinkNode, $isAutoLinkNode, $toggleLink, AutoLinkNode, SerializedAutoLinkNode, } f...
fim
BookStackApp/BookStack
typescript
<|fim_suffix|>); linkNode.setTarget('_self'); expect(linkNode.getTarget()).toBe('_self'); }); }); test('LinkNode.getRel()', async () => { const {editor} = testEnv; await editor.update(() => { const linkNode = new LinkNode('https://example.com/foo', { rel: ...
fim
BookStackApp/BookStack
typescript