Skip to content

Commit 836667c

Browse files
author
clarencepalmer
committed
Merge remote-tracking branch 'origin/main' into chore/spike/new-loader-mark
2 parents 4cc619c + 52a9bbd commit 836667c

32 files changed

Lines changed: 176 additions & 110 deletions

File tree

packages/super-editor/src/assets/styles/elements/prosemirror.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ img.ProseMirror-separator {
108108
margin: 0 !important;
109109
}
110110

111-
.ProseMirror .super-doc-tab {
111+
.ProseMirror .sd-editor-tab {
112112
display: inline-block;
113113
vertical-align: text-bottom;
114114
}
115115

116-
.ProseMirror u .super-doc-tab:not(.pagination-inner .super-doc-tab) {
116+
.ProseMirror u .sd-editor-tab:not(.pagination-inner .sd-editor-tab) {
117117
white-space: pre;
118118
border-bottom: 1px solid #000;
119119
margin-bottom: 1.5px;
@@ -311,7 +311,7 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
311311
z-index: -1;
312312
}
313313

314-
.super-doc-dropcap {
314+
.sd-editor-dropcap {
315315
float: left;
316316
display: flex;
317317
align-items: baseline;
@@ -323,4 +323,4 @@ https://github.com/ProseMirror/prosemirror-tables/blob/master/demo/index.html
323323
}
324324
.ProseMirror-active-search-match {
325325
background-color: #ff6a0054;
326-
}
326+
}

packages/super-editor/src/assets/styles/elements/toolbar.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
}
1010

11-
.n-dropdown-option .dropdown-select-icon {
11+
.sd-editor-toolbar-dropdown .n-dropdown-option .dropdown-select-icon {
1212
display: flex;
1313
width: 12px;
1414
height: 12px;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.comment-highlight {
1+
.sd-editor-comment-highlight {
22
transition: background-color 250ms ease;
33
}
44

5-
.comment-highlight:hover {
5+
.sd-editor-comment-highlight:hover {
66
background-color: #1354FF55;
77
}

packages/super-editor/src/assets/styles/extensions/mention.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.super-editor-mention {
1+
.sd-editor-mention {
22
background-color: #1355ff15;
33
color: #222;
44
font-weight: 400;

packages/super-editor/src/assets/styles/extensions/pagination.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
Workaround to display pagination in footer
4646
on the right if it is inside shape textbox.
4747
*/
48-
.pagination-section-footer .pm-shape-container:has(
48+
.pagination-section-footer .sd-editor-shape-container:has(
4949
[data-id="auto-page-number"],
5050
[data-id="auto-total-pages"]
5151
) {

packages/super-editor/src/assets/styles/extensions/placeholder.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.super-editor-placeholder::before {
1+
.sd-editor-placeholder::before {
22
content: attr(data-placeholder);
33
color: #aaa;
44
pointer-events: none;
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.popover {
1+
.sd-editor-popover {
22
background-color: #fff;
33
border-radius: 8px;
44
-webkit-box-shadow: 0px 4px 12px 0px rgba(50, 50, 50, 0.15);
@@ -12,28 +12,24 @@
1212
z-index: 1000;
1313
}
1414

15-
.popover-header {
15+
.sd-editor-popover .popover-header {
1616
font-weight: bold;
1717
margin-bottom: 8px;
1818
}
1919

20-
.tippy-content {
21-
padding: 0;
22-
}
23-
24-
.tippy-box[data-theme~='popover'] {
20+
.tippy-box[data-theme~='sd-editor-popover'] {
2521
background-color: #fff;
2622
border-radius: 8px;
2723
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
28-
border: none;
24+
border: none !important;
25+
padding: 0 !important;
2926
}
3027

31-
.tippy-box[data-theme~='popover'] .tippy-arrow {
28+
.tippy-box[data-theme~='sd-editor-popover'] .tippy-arrow {
3229
color: #fff;
3330
border: 1px solid #dbdbdb;
3431
}
3532

36-
.tippy-box[data-theme~='popover'] {
37-
border: none !important;
38-
padding: none !important;
33+
.tippy-box[data-theme~='sd-editor-popover'] .tippy-content {
34+
padding: 0;
3935
}
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
.disabled {
2-
opacity: 0.5;
3-
cursor: not-allowed;
4-
pointer-events: none;
5-
}
6-
7-
.input-active {
1+
.sd-input-active {
82
border: 1px solid #1355ff !important;
93
}
104

@@ -15,4 +9,4 @@
159
height: 100%;
1610
width: 100%;
1711
outline: none;
18-
}
12+
}

packages/super-editor/src/components/toolbar/ButtonGroup.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const handleClickOutside = (e) => {
101101
:show="item.expand.value"
102102
size="medium"
103103
placement="bottom-start"
104-
class="toolbar-button toolbar-dropdown"
104+
class="toolbar-button toolbar-dropdown sd-editor-toolbar-dropdown"
105105
@select="(key, option) => handleSelect(item, option)"
106106
@clickoutside="handleClickOutside"
107107
:style="item.dropdownStyles.value"
@@ -121,7 +121,7 @@ const handleClickOutside = (e) => {
121121
</n-tooltip>
122122
</n-dropdown>
123123

124-
<n-tooltip trigger="hover" v-else-if="isButton(item)">
124+
<n-tooltip trigger="hover" v-else-if="isButton(item)" class="sd-editor-toolbar-tooltip">
125125
<template #trigger>
126126
<ToolbarButton
127127
:toolbar-item="item"
@@ -146,26 +146,26 @@ const handleClickOutside = (e) => {
146146
</template>
147147

148148
<style lang="postcss">
149-
.n-dropdown {
149+
.sd-editor-toolbar-dropdown {
150150
border-radius: 8px;
151151
min-width: 80px;
152+
cursor: pointer;
152153
}
153-
.n-tooltip,
154-
.n-popover {
155-
background-color: #333333 !important;
156-
font-size: 14px;
157-
border-radius: 8px !important;
158-
}
159-
.n-dropdown-option-body {
154+
155+
.sd-editor-toolbar-dropdown .n-dropdown-option-body {
160156
&:hover {
161157
&::before,
162158
&::after {
163159
background-color: #d8dee5 !important;
164160
}
165161
}
166162
}
167-
.toolbar-dropdown {
168-
cursor: pointer;
163+
164+
.sd-editor-toolbar-tooltip,
165+
.sd-editor-toolbar-tooltip.n-popover {
166+
background-color: #333333 !important;
167+
font-size: 14px;
168+
border-radius: 8px !important;
169169
}
170170
</style>
171171

packages/super-editor/src/core/super-converter/exporter.js

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,17 +1731,25 @@ function prepareCheckboxAnnotation(params) {
17311731
*/
17321732
function prepareHtmlAnnotation(params) {
17331733
const {
1734-
node: { attrs = {} },
1734+
node: { attrs = {}, marks = [] },
1735+
editorSchema,
17351736
} = params;
17361737

17371738
const parser = new window.DOMParser();
17381739
const paragraphHtml = parser.parseFromString(attrs.rawHtml || attrs.displayLabel, 'text/html');
1740+
const marksFromAttrs = translateFieldAttrsToMarks(attrs);
1741+
const allMarks = [...marks, ...marksFromAttrs]
17391742

1740-
const state = EditorState.create({
1741-
doc: PMDOMParser.fromSchema(params.editorSchema).parse(paragraphHtml),
1743+
let state = EditorState.create({
1744+
doc: PMDOMParser.fromSchema(editorSchema).parse(paragraphHtml),
17421745
});
17431746

1747+
if (allMarks.length) {
1748+
state = applyMarksToHtmlAnnotation(state, allMarks);
1749+
}
1750+
17441751
const htmlAnnotationNode = state.doc.toJSON();
1752+
17451753
return {
17461754
name: 'htmlAnnotation',
17471755
elements: translateChildNodes({
@@ -1896,6 +1904,20 @@ function translateFieldAnnotation(params) {
18961904
'w:val': attrs.multipleImage,
18971905
},
18981906
},
1907+
{
1908+
name: 'w:fieldFontFamily',
1909+
attributes: {
1910+
'xmlns:w': customXmlns,
1911+
'w:val': attrs.fontFamily,
1912+
},
1913+
},
1914+
{
1915+
name: 'w:fieldFontSize',
1916+
attributes: {
1917+
'xmlns:w': customXmlns,
1918+
'w:val': attrs.fontSize,
1919+
},
1920+
},
18991921
],
19001922
},
19011923
{
@@ -2103,3 +2125,46 @@ function resizeKeepAspectRatio(width, height, maxWidth) {
21032125
}
21042126
return { width, height };
21052127
}
2128+
2129+
function applyMarksToHtmlAnnotation(state, marks) {
2130+
const { tr, doc, schema } = state;
2131+
const allowedMarks = ['fontFamily', 'fontSize'];
2132+
2133+
if (
2134+
!marks.some((m) => allowedMarks.includes(m.type))
2135+
) {
2136+
return state;
2137+
}
2138+
2139+
const fontFamily = marks.find((m) => m.type === 'fontFamily');
2140+
const fontSize = marks.find((m) => m.type === 'fontSize');
2141+
2142+
doc.descendants((node, pos) => {
2143+
if (!node.isText) return;
2144+
2145+
const found = node.marks.find((m) => m.type.name === 'textStyle');
2146+
const textStyleType = schema.marks.textStyle;
2147+
2148+
if (!found) {
2149+
tr.addMark(pos, pos + node.nodeSize, textStyleType.create({
2150+
...fontFamily?.attrs,
2151+
...fontSize?.attrs,
2152+
}));
2153+
return;
2154+
}
2155+
2156+
if (!found?.attrs.fontFamily && fontFamily) {
2157+
tr.addMark(pos, pos + node.nodeSize, textStyleType.create({
2158+
...found?.attrs,
2159+
...fontFamily.attrs,
2160+
}));
2161+
} else if (!found?.attrs.fontSize && fontSize) {
2162+
tr.addMark(pos, pos + node.nodeSize, textStyleType.create({
2163+
...found?.attrs,
2164+
...fontSize.attrs,
2165+
}));
2166+
}
2167+
});
2168+
2169+
return state.apply(tr);
2170+
};

0 commit comments

Comments
 (0)