From 6e2b1cd24cab358233506ee8eb2c6d93fa8391f2 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Wed, 14 Jul 2021 16:35:52 +0300 Subject: [PATCH] fix strong --- .../src/marks/strongMark.js | 23 ++++++++--------- .../StrongService/StrongService.js | 25 ++++++++----------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/wax-prosemirror-schema/src/marks/strongMark.js b/wax-prosemirror-schema/src/marks/strongMark.js index bea068b29..e1fc8ea10 100644 --- a/wax-prosemirror-schema/src/marks/strongMark.js +++ b/wax-prosemirror-schema/src/marks/strongMark.js @@ -1,19 +1,18 @@ const strong = { parseDOM: [ - { tag: "strong" }, + { tag: 'strong' }, + // This works around a Google Docs misbehavior where + // pasted content will be inexplicably wrapped in `<b>` + // tags with a font-weight normal. + { tag: 'b', getAttrs: node => node.style.fontWeight !== 'normal' && null }, { - tag: "b", - getAttrs: node => node.style.fontWeight != "normal" && null - } - // { - // style: "font-weight", - // getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null - // } + style: 'font-weight', + getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null, + }, ], - toDOM(hook, next) { - hook.value = ["strong", 0]; - next(); - } + toDOM() { + return ['strong', 0]; + }, }; export default strong; diff --git a/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js b/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js index 21d9ad3d4..44f66b6ec 100644 --- a/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js +++ b/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js @@ -1,23 +1,20 @@ -import Service from "../../Service"; -import { toggleMark } from "prosemirror-commands"; -import { strongMark } from "wax-prosemirror-schema"; -import Strong from "./Strong"; +import Service from '../../Service'; +import { toggleMark } from 'prosemirror-commands'; +import { strongMark } from 'wax-prosemirror-schema'; +import Strong from './Strong'; class StrongService extends Service { boot() { - const shortCuts = this.container.get("ShortCuts"); - shortCuts.addShortCut({ "Mod-b": toggleMark(this.schema.marks.strong) }); + const shortCuts = this.container.get('ShortCuts'); + shortCuts.addShortCut({ 'Mod-b': toggleMark(this.schema.marks.strong) }); } register() { - this.container.bind("Strong").to(Strong); - const createMark = this.container.get("CreateMark"); - createMark( - { - strong: strongMark - }, - { toWaxSchema: true } - ); + this.container.bind('Strong').to(Strong); + const createMark = this.container.get('CreateMark'); + createMark({ + strong: strongMark, + }); } } -- GitLab