Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update slate and others dependencies to latest version #246

Merged
merged 4 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/app/huge-document/huge-document.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild, TemplateRef, AfterViewInit, NgZone } from '@angular/core';
import faker from 'faker';
import { faker } from '@faker-js/faker';
import { createEditor } from 'slate';
import { withAngular } from 'slate-angular';
import { take } from 'rxjs/operators';
Expand Down
14 changes: 7 additions & 7 deletions demo/app/inlines/inlines.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class DemoInlinesComponent implements OnInit {
valueChange(value: Element[]) {}
}

const withInlines = editor => {
const withInlines = (editor: Editor) => {
const { insertData, insertText, isInline } = editor;

editor.isInline = element => ['link', 'button'].includes(element.type) || isInline(element);
Expand Down Expand Up @@ -134,33 +134,33 @@ const insertLink = (editor, url) => {
}
};

const insertButton = editor => {
const insertButton = (editor: Editor) => {
if (editor.selection) {
wrapButton(editor);
}
};

const isLinkActive = editor => {
const isLinkActive = (editor: Editor) => {
const [link] = Editor.nodes(editor, {
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === 'link'
});
return !!link;
};

const isButtonActive = editor => {
const isButtonActive = (editor: Editor) => {
const [button] = Editor.nodes(editor, {
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === 'button'
});
return !!button;
};

const unwrapLink = editor => {
const unwrapLink = (editor: Editor) => {
Transforms.unwrapNodes(editor, {
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === 'link'
});
};

const unwrapButton = editor => {
const unwrapButton = (editor: Editor) => {
Transforms.unwrapNodes(editor, {
match: n => !Editor.isEditor(n) && SlateElement.isElement(n) && n.type === 'button'
});
Expand All @@ -187,7 +187,7 @@ const wrapLink = (editor, url: string) => {
}
};

const wrapButton = editor => {
const wrapButton = (editor: Editor) => {
if (isButtonActive(editor)) {
unwrapButton(editor);
}
Expand Down
6 changes: 3 additions & 3 deletions demo/app/markdown-shorcuts/markdown-shortcuts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const withShortcuts = editor => {
if (text === ' ' && selection && Range.isCollapsed(selection)) {
const { anchor } = selection;
const block = Editor.above<Element>(editor, {
match: n => Editor.isBlock(editor, n)
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
});
const path = block ? block[1] : [];
const start = Editor.start(editor, path);
Expand All @@ -142,7 +142,7 @@ const withShortcuts = editor => {
if (type) {
Transforms.select(editor, range);
Transforms.delete(editor);
Transforms.setNodes(editor, { type }, { match: n => Editor.isBlock(editor, n) });
Transforms.setNodes(editor, { type }, { match: n => Element.isElement(n) && Editor.isBlock(editor, n) });

if (type === 'list-item') {
const list: BulletedListElement = {
Expand All @@ -166,7 +166,7 @@ const withShortcuts = editor => {

if (selection && Range.isCollapsed(selection)) {
const match = Editor.above<Element>(editor, {
match: n => Editor.isBlock(editor, n)
match: n => Element.isElement(n) && Editor.isBlock(editor, n)
});

if (match) {
Expand Down
Loading