Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 1x 1x 1x 2x 2x 1x 1x 2x 1x 1x 2x 2x 1x 1x | import { ChangeSource } from 'roosterjs-content-model-dom'; import { fixupHiddenProperties } from './fixupHiddenProperties'; import type { IEditor, PluginEvent, EditorPlugin } from 'roosterjs-content-model-types'; import type { HiddenPropertyOptions } from './HiddenPropertyOptions'; /** * HiddenPropertyPlugin helps editor to maintain hidden properties in DOM after editor content is reset using HTML */ export class HiddenPropertyPlugin implements EditorPlugin { private editor: IEditor | null = null; /** * Construct a new instance of FormatPlugin class * @param option The editor option */ constructor(private option: HiddenPropertyOptions) {} /** * Get name of this plugin */ getName() { return 'HiddenProperty'; } /** * The first method that editor will call to a plugin when editor is initializing. * It will pass in the editor instance, plugin should take this chance to save the * editor reference so that it can call to any editor method or format API later. * @param editor The editor object */ initialize(editor: IEditor) { this.editor = editor; } /** * The last method that editor will call to a plugin before it is disposed. * Plugin can take this chance to clear the reference to editor. After this method is * called, plugin should not call to any editor method since it will result in error. */ dispose() { this.editor = null; } /** * Core method for a plugin. Once an event happens in editor, editor will call this * method of each plugin to handle the event as long as the event is not handled * exclusively by another plugin. * @param event The event to handle: */ onPluginEvent(event: PluginEvent) { Iif (!this.editor) { return; } if (event.eventType == 'contentChanged' && event.source == ChangeSource.SetContent) { fixupHiddenProperties(this.editor, this.option); } } } |