public MarkdownEditor() { InitializeComponent(); NameScope.SetNameScope(EditorContextMenu, NameScope.GetNameScope(this)); Editor.TextArea.SelectionChanged += SelectionChanged; Editor.PreviewMouseLeftButtonUp += HandleMouseUp; Editor.MouseMove += HandleEditorMouseMove; Editor.PreviewMouseLeftButtonDown += HandleEditorPreviewMouseLeftButtonDown; Editor.MouseMove += (s, e) => e.Handled = true; Editor.TextArea.TextEntering += TextAreaTextEntering; CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleBold, (x, y) => ToggleBold(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleItalic, (x, y) => ToggleItalic(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCode, (x, y) => ToggleCode(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCodeBlock, (x, y) => ToggleCodeBlock(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.SetHyperlink, (x, y) => SetHyperlink(), CanEditDocument)); var overtypeMode = new OvertypeMode(); var autoPairedCharacters = new AutoPairedCharacters(); editorPreviewKeyDownHandlers = new IHandle<EditorPreviewKeyDownEvent>[] { new CopyLeadingWhitespaceOnNewLine(), new PasteImageIntoDocument(), new PasteURLIntoDocument(), new ControlRightTweakedForMarkdown(), new HardLineBreak(), overtypeMode, new AutoContinueLists(), new IndentLists(()=>IndentType), autoPairedCharacters }; editorTextEnteringHandlers = new IHandle<EditorTextEnteringEvent>[] { overtypeMode, autoPairedCharacters }; Editor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush( Color.FromRgb(0xA4, 0xA4, 0xA4)); }
public MarkdownEditor() { InitializeComponent(); NameScope.SetNameScope(EditorContextMenu, NameScope.GetNameScope(this)); Editor.TextArea.SelectionChanged += SelectionChanged; Editor.PreviewMouseLeftButtonUp += HandleMouseUp; Editor.MouseMove += HandleEditorMouseMove; Editor.PreviewMouseLeftButtonDown += HandleEditorPreviewMouseLeftButtonDown; Editor.MouseMove += (s, e) => e.Handled = true; Editor.TextArea.TextEntering += TextAreaTextEntering; CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleBold, (x, y) => ToggleBold(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleItalic, (x, y) => ToggleItalic(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCode, (x, y) => ToggleCode(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.ToggleCodeBlock, (x, y) => ToggleCodeBlock(), CanEditDocument)); CommandBindings.Add(new CommandBinding(FormattingCommands.SetHyperlink, (x, y) => SetHyperlink(), CanEditDocument)); var overtypeMode = new OvertypeMode(); var autoPairedCharacters = new AutoPairedCharacters(); editorPreviewKeyDownHandlers = new IHandle <EditorPreviewKeyDownEvent>[] { new CopyLeadingWhitespaceOnNewLine(), new PasteImageIntoDocument(), new PasteURLIntoDocument(), new ControlRightTweakedForMarkdown(), new HardLineBreak(), overtypeMode, new AutoContinueLists(), new IndentLists(() => IndentType), autoPairedCharacters }; editorTextEnteringHandlers = new IHandle <EditorTextEnteringEvent>[] { overtypeMode, autoPairedCharacters }; Editor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush( Color.FromRgb(0xA4, 0xA4, 0xA4)); }