Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
0842639f
Commit
0842639f
authored
10 years ago
by
Marijn Haverbeke
Browse files
Options
Downloads
Patches
Plain Diff
[merge demo] Describe aligning and collapsing functionality
parent
5d74cb02
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
demo/merge.html
+18
-10
18 additions, 10 deletions
demo/merge.html
with
18 additions
and
10 deletions
demo/merge.html
+
18
−
10
View file @
0842639f
...
...
@@ -41,33 +41,41 @@
<p>
The
<a
href=
"../doc/manual.html#addon_merge"
><code>
merge
</code></a>
addon provides an interface for displaying and merging diffs,
either
<span
class=
clicky
onclick=
"initUI(2)"
>
two-way
</span>
or
<span
class=
clicky
onclick=
"initUI(3)"
>
three-way
</span>
. The left
(or center) pane is editable, and the differences with the other
pane(s) are
<span
class=
clicky
onclick=
"toggleDifferences()"
>
optionally
</span>
shown live as you edit it.
</p>
either
<span
class=
clicky
onclick=
"panes = 2; initUI()"
>
two-way
</span>
or
<span
class=
clicky
onclick=
"panes = 3; initUI()"
>
three-way
</span>
.
The left (or center) pane is editable, and the differences with the
other pane(s) are
<span
class=
clicky
onclick=
"toggleDifferences()"
>
optionally
</span>
shown live as you edit
it. In the two-way configuration, there are also options to pad changed
sections to
<span
class=
clicky
onclick=
"connect = connect ? null :
'align'; initUI()"
>
align
</span>
them, and to
<span
class=
clicky
onclick=
"collapse = !collapse; initUI()"
>
collapse
</span>
unchanged
stretches of text.
</p>
<p>
This addon depends on
the
<a
href=
"https://code.google.com/p/google-diff-match-patch/"
>
google-diff-match-patch
</a>
library to compute the diffs.
</p>
<script>
var
value
,
orig1
,
orig2
,
dv
,
h
i
light
=
true
;
function
initUI
(
panes
)
{
var
value
,
orig1
,
orig2
,
dv
,
panes
=
2
,
hig
hlight
=
true
,
connect
=
null
,
collapse
=
false
;
function
initUI
()
{
if
(
value
==
null
)
return
;
var
target
=
document
.
getElementById
(
"
view
"
);
target
.
innerHTML
=
""
;
dv
=
CodeMirror
.
MergeView
(
target
,
{
value
:
value
,
origLeft
:
panes
==
3
?
orig1
:
null
,
origLeft
:
panes
==
3
&&
!
collapse
&&
!
connect
?
orig1
:
null
,
orig
:
orig2
,
lineNumbers
:
true
,
mode
:
"
text/html
"
,
highlightDifferences
:
hilight
highlightDifferences
:
highlight
,
connect
:
connect
,
collapseIdentical
:
collapse
});
}
function
toggleDifferences
()
{
dv
.
setShowDifferences
(
hilight
=
!
hilight
);
dv
.
setShowDifferences
(
hi
gh
light
=
!
hi
gh
light
);
}
window
.
onload
=
function
()
{
...
...
@@ -75,7 +83,7 @@ window.onload = function() {
orig1
=
value
.
replace
(
/
\.\.\/
/g
,
"
codemirror/
"
).
replace
(
"
yellow
"
,
"
orange
"
);
orig2
=
value
.
replace
(
/
\u
003cscript/g
,
"
\
u003cscript type=text/javascript
"
)
.
replace
(
"
white
"
,
"
purple;
\n
font: comic sans;
\n
text-decoration: underline;
\n
height: 15em
"
);
initUI
(
2
);
initUI
();
};
function
mergeViewHeight
(
mergeView
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment